Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get systemeventlog #376

Merged
merged 6 commits into from
Dec 7, 2023
Merged

Conversation

mattcburns
Copy link
Contributor

What does this PR implement/change/remove?

This PR adds the ability to retrieve the System Event Log from the target BMC using either IPMI or Redfish. There is an opinionated method that returns the entries as an array of entries in array format and a raw method that returns the raw output from the BMC.

Checklist

  • Tests added
  • Similar commits squashed

The HW vendor this change applies to (if applicable)

N/A

The HW model number, product name this change applies to (if applicable)

N/A

The BMC firmware and/or BIOS versions that this change applies to (if applicable)

N/A

What version of tooling - vendor specific or opensource does this change depend on (if applicable)

N/A

Description for changelog/release notes

Added GetSystemEventLog and GetSystemEventLogRaw. These methods retrieve the SEL of the target BMC. The former uses an opinionated format, retrieving the ID, Timestamp, Description, Message in an array format. The latter returns the raw output as a string. Both IPMI and Redfish are supported.

@mattcburns mattcburns marked this pull request as ready for review November 30, 2023 00:11
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 68 lines in your changes are missing coverage. Please review.

Comparison is base (1063371) 43.37% compared to head (f7408e4) 43.47%.

Files Patch % Lines
internal/redfishwrapper/sel.go 0.00% 42 Missing ⚠️
client.go 0.00% 12 Missing ⚠️
bmc/sel.go 85.29% 8 Missing and 2 partials ⚠️
providers/ipmitool/ipmitool.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #376      +/-   ##
==========================================
+ Coverage   43.37%   43.47%   +0.10%     
==========================================
  Files          59       59              
  Lines        5144     5274     +130     
==========================================
+ Hits         2231     2293      +62     
- Misses       2696     2762      +66     
- Partials      217      219       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work here, left a few comments

err = cl.ClearSystemEventLog(ctx)
if err != nil {
l.WithError(err).Fatal(err, "failed to clear System Event Log")
if *action == "get" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be turned into a switch case block?

@@ -656,3 +656,17 @@ func (c *Client) FirmwareInstallUploaded(ctx context.Context, component, uploadV

return installTaskID, err
}

// GetSystemEventLog queries for the SEL and returns the entries in an opinionated format.
func (c *Client) GetSystemEventLog(ctx context.Context) (entries bmc.SystemEventLogEntries, err error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include tracing here, for an example, see -

ctx, span := c.traceprovider.Tracer(pkgName).Start(ctx, "Close")

bmc/sel.go Outdated
continue
}

for i, v := range selRawEntries {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this block be pushed down into the provider implementations, since these 'boilerplate' methods should just be iterating over the providers and returning the result

return nil, err
}

log.Println(len(logServices))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug print?

}

// ID, Timestamp (date time), Description, Message (message : assertion)
entries = append(entries, []string{line[0], fmt.Sprintf("%s %s", line[1], line[2]), line[3], fmt.Sprintf("%s : %s", line[4], line[5])})
Copy link
Member

@joelrebel joelrebel Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this references elems in the slice line[3], line[4], line[5] - it would be worth adding a len() check before referencing those elem indexes.

line[i] = strings.TrimSpace(line[i])
}

// ID, Timestamp (date time), Description, Message (message : assertion)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you include some fixture data for this, along with a test for the parsing (move this scanner block into another method if that makes it easier to test)

@mattcburns mattcburns requested a review from joelrebel December 6, 2023 16:27
Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes and implementation!

Copy link
Member

@joelrebel joelrebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes and implementation!

(creds to GH vscode UI for the dup comment)

@joelrebel joelrebel merged commit b299d27 into bmc-toolbox:main Dec 7, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants