Skip to content

Commit

Permalink
Handle LogService v1.3.0 ClearLog payload
Browse files Browse the repository at this point in the history
Starting with the 1.3.0 schema, the ClearLog call expects to have the
etag of the LogEntryCollection as an argument.

This adds a retry to make sure we cover both the pre-1.3 and post-1.3
methods.

Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
  • Loading branch information
stmcginnis committed May 23, 2024
1 parent 8061ec5 commit a40c211
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions redfish/logservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/json"
"fmt"
"reflect"
"strings"

"github.com/stmcginnis/gofish/common"
)
Expand Down Expand Up @@ -241,6 +242,29 @@ func (logservice *LogService) FilteredEntries(options ...common.FilterOption) ([
// ClearLog shall delete all entries found in the Entries collection for this
// Log Service.
func (logservice *LogService) ClearLog() error {
err := logservice.Post(logservice.clearLogTarget, struct{}{})
if err == nil {
return nil
}

// As of LogService 1.3.0, need to pass the LogEntryCollection etag. If our first attempt failed, try that.
entryCollection := &struct {
ETag string `json:"@odata.etag"`
}{}

retryErr := logservice.Get(logservice.GetClient(), logservice.entries, entryCollection)
if retryErr == nil {
payload := struct {
LogEntriesETag string
}{LogEntriesETag: strings.Trim(entryCollection.ETag, "\"")}

retryErr = logservice.Post(logservice.clearLogTarget, payload)
if retryErr == nil {
return nil
}
}

// Fall back to broken implementation to workaround vendor bug
t := struct {
Action string
}{
Expand Down

0 comments on commit a40c211

Please sign in to comment.