Skip to content

Commit

Permalink
Fix fetching Server details from registry
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Apr 26, 2024
1 parent d8e7417 commit 6fba843
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/controller/server_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,13 @@ func (r *ServerReconciler) pxeBootServer(ctx context.Context, log logr.Logger, s
func (r *ServerReconciler) extractServerDetailsFromRegistry(ctx context.Context, server *metalv1alpha1.Server) error {
resp, err := http.Get(fmt.Sprintf("%s/systems/%s", r.RegistryURL, server.Spec.UUID))
if err != nil {
if resp != nil && resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("could not find server details: %s", resp.Status)
}
return fmt.Errorf("failed to fetch server details: %w", err)
}

if resp != nil && resp.StatusCode == http.StatusNotFound {
return fmt.Errorf("could not find server details: %s", resp.Status)
}

serverDetails := &registry.Server{}
if err := json.NewDecoder(resp.Body).Decode(serverDetails); err != nil {
return fmt.Errorf("failed to decode server details: %w", err)
Expand Down

0 comments on commit 6fba843

Please sign in to comment.