Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/httpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

const (
_defaultReadTimeout = 15 * time.Second
_defaultWriteTimeout = 15 * time.Second
_defaultWriteTimeout = 60 * time.Second
_defaultAddr = ":80"
_defaultShutdownTimeout = 3 * time.Second

Expand Down
6 changes: 2 additions & 4 deletions redfish/internal/controller/http/v1/handler/systems.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ func (s *RedfishServer) handleGetSystemError(c *gin.Context, err error, systemID
NotFoundError(c, "System", systemID)
default:
if s.Logger != nil {
s.Logger.Error("Failed to retrieve computer system",
"systemID", systemID,
"error", err)
s.Logger.Error("Failed to retrieve computer system: systemID=%s error=%v", systemID, err)
}

InternalServerError(c, err)
Expand All @@ -118,7 +116,7 @@ func (s *RedfishServer) GetRedfishV1Systems(c *gin.Context) {
systemIDs, err := s.ComputerSystemUC.GetAll(ctx)
if err != nil {
if s.Logger != nil {
s.Logger.Error("Failed to retrieve computer systems collection", "error", err)
s.Logger.Error("Failed to retrieve computer systems collection: error=%v", err)
}

InternalServerError(c, err)
Expand Down
4 changes: 2 additions & 2 deletions redfish/internal/controller/http/v1/handler/systems_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ func TestSystemsHandler_GetSystemsCollection_WithLogger(t *testing.T) {
assert.Equal(t, http.StatusInternalServerError, w.Code)
// Verify logger was called
assert.Len(t, testLogger.ErrorCalls, 1)
assert.Equal(t, "Failed to retrieve computer systems collection", testLogger.ErrorCalls[0][0])
assert.Equal(t, "Failed to retrieve computer systems collection: error=%v", testLogger.ErrorCalls[0][0])
}

// TestSystemsHandler_GetSystemByID_WithLogger tests logging paths
Expand Down Expand Up @@ -973,7 +973,7 @@ func TestSystemsHandler_GetSystemByID_WithLogger(t *testing.T) {
assert.Equal(t, http.StatusInternalServerError, w.Code)
// Verify logger was called
assert.Len(t, testLogger.ErrorCalls, 1)
assert.Equal(t, "Failed to retrieve computer system", testLogger.ErrorCalls[0][0])
assert.Equal(t, "Failed to retrieve computer system: systemID=%s error=%v", testLogger.ErrorCalls[0][0])
}

// createTestSystemEntityDataWithMemory creates a test system entity with MemorySummary
Expand Down
21 changes: 16 additions & 5 deletions redfish/internal/usecase/computer_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const (

// Default system type.
DefaultSystemType = "Physical"

// WSMAN boot settings call timeout for system GET responses.
bootSettingsTimeout = 2 * time.Second
)

// Resource Health constants.
Expand Down Expand Up @@ -124,6 +127,8 @@ func (uc *ComputerSystemUseCase) GetAll(ctx context.Context) ([]string, error) {
}

// GetComputerSystem retrieves a ComputerSystem by its systemID and converts it to the generated API type.
//
//nolint:funlen // This method assembles many optional Redfish fields and handles best-effort fallbacks in one flow.
func (uc *ComputerSystemUseCase) GetComputerSystem(ctx context.Context, systemID string) (*generated.ComputerSystemComputerSystem, error) {
// Get device information from repository - this gives us basic device data
system, err := uc.Repo.GetByID(ctx, systemID)
Expand Down Expand Up @@ -186,11 +191,17 @@ func (uc *ComputerSystemUseCase) GetComputerSystem(ctx context.Context, systemID
}
}

// Fetch boot settings
boot, err := uc.Repo.GetBootSettings(ctx, systemID)
if err != nil {
// Log error but don't fail the entire request - boot settings may not be available
boot = nil
var boot *generated.ComputerSystemBoot

if system.PowerState == redfishv1.PowerStateOn {
// Fetch boot settings from WSMAN with a bounded timeout to avoid long-tail latency.
bootCtx, bootCancel := context.WithTimeout(ctx, bootSettingsTimeout)
defer bootCancel()

boot, err = uc.Repo.GetBootSettings(bootCtx, systemID)
if err != nil {
boot = nil
}
}
// Create Actions for this system using the generated Actions type
actions := uc.createActionsStruct(systemID)
Expand Down
Loading
Loading