Skip to content

Commit

Permalink
CASMHMS-6236: Add debug to help diagnose
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlv committed Jul 29, 2024
1 parent 1007818 commit 11d94c9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.33.0
2.34.0
5 changes: 4 additions & 1 deletion cmd/hmcollector/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ package main
import (
"bytes"
"fmt"
"go.uber.org/zap"
"io/ioutil"
"net/http"

rf "github.com/Cray-HPE/hms-smd/pkg/redfish"
"go.uber.org/zap"
)

func doHTTPAction(endpoint *rf.RedfishEPDescription, method string,
Expand Down Expand Up @@ -103,6 +104,8 @@ func doHTTPAction(endpoint *rf.RedfishEPDescription, method string,
return
}
}
} else if resp.StatusCode == http.StatusNotFound {
endpointLogger.Error("Got 404 response from endpoint")
}

// Get the payload.
Expand Down
6 changes: 6 additions & 0 deletions cmd/hmcollector/rf_subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ func isDupRFSubscription(endpoint *rf.RedfishEPDescription, registryPrefixes []s
fullURL := fmt.Sprintf("%s/redfish/v1/EventService/Subscriptions", baseEndpointURL)
payloadBytes, _, err := doHTTPAction(endpoint, http.MethodGet, fullURL, nil)
if err != nil {
logger.Error("JW_DEBUG: isDupRFSubscription: doHTTPAction() (1) failed: %v", zap.Error(err))
return false, err
}

var subList hmcollector.EventSubscriptionCollection
err = json.Unmarshal(payloadBytes, &subList)
if err != nil {
logger.Error("JW_DEBUG: isDupRFSubscription: json.Unmarshal() (1) failed: %v", zap.Error(err))
return false, err
}

Expand All @@ -243,12 +245,14 @@ func isDupRFSubscription(endpoint *rf.RedfishEPDescription, registryPrefixes []s

payloadBytes, _, err := doHTTPAction(endpoint, http.MethodGet, fullURL, nil)
if err != nil {
logger.Error("JW_DEBUG: isDupRFSubscription: doHTTPAction() (2) failed: %v", zap.Error(err))
return false, err
}

var eventSub hmcollector.EventSubscription
err = json.Unmarshal(payloadBytes, &eventSub)
if err != nil {
logger.Error("JW_DEBUG: isDupRFSubscription: json.Unmarshal() (2) failed: %v", zap.Error(err))
return false, err
}
if eventSub.Destination == getDestination(endpoint) {
Expand Down Expand Up @@ -297,6 +301,7 @@ func isDupRFSubscription(endpoint *rf.RedfishEPDescription, registryPrefixes []s
// context (can happen when a node changes xname CASMHMS-3200). If
// successfully updated return as a valid match. If the update was unsuccessful
// it attempted to delete the subscription, so return no match.
logger.Error("JW_DEBUG: isDupRFSubscription: match=%v", zap.Bool("match", match))
return match, nil
}
} else {
Expand All @@ -306,6 +311,7 @@ func isDupRFSubscription(endpoint *rf.RedfishEPDescription, registryPrefixes []s
}
}
}
logger.Error("JW_DEBUG: isDupRFSubscription: no matching subscription found")
return false, nil
}

Expand Down

0 comments on commit 11d94c9

Please sign in to comment.