Skip to content

Commit

Permalink
Handle the situation where we pass a single host to inventory and it …
Browse files Browse the repository at this point in the history
…responds with a 404
  • Loading branch information
dehort committed Feb 20, 2024
1 parent 8311244 commit 3059857
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/api/connectors/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (this *inventoryConnectorImpl) getHostDetails(
return nil, err
}

if response.StatusCode() == http.StatusNotFound {
return []HostOut{}, nil
}

if response.JSON200 == nil {
return nil, utils.UnexpectedResponse(response.HTTPResponse)
}
Expand Down Expand Up @@ -184,7 +188,7 @@ func (this *inventoryConnectorImpl) GetHostConnectionDetails(ctx context.Context
}

if len(hostResults) == 0 {
return nil, nil
return []HostDetails{}, nil
}

systemProfileResults, err := this.getSystemProfileDetails(ctx, IDs, order_by, order_how, limit, offset)
Expand Down
7 changes: 7 additions & 0 deletions internal/api/controllers/private/highlevelConnectionStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ func (this *controllers) ApiInternalHighlevelConnectionStatus(ctx echo.Context)
return ctx.NoContent(http.StatusBadRequest)
}

if len(hostConnectorDetails) == 0 {
// FIXME: I'm not sure that this is right. Basically, we need to return a response that says the host was not available....
// This could happen if the host was deleted from inventory or an error (404) came back from inventory
// Think through this a bit more and build a test around this at the API level
return ctx.JSON(http.StatusOK, noRHCResponses)
}

satellite, directConnected, noRhc := sortHostsByRecipient(hostConnectorDetails)

// Return noRHC If no Satellite or Direct Connected hosts exist
Expand Down

0 comments on commit 3059857

Please sign in to comment.