Skip to content

Commit

Permalink
MGMT-13132: Respond with 409 when rejecting registration (#4858)
Browse files Browse the repository at this point in the history
Currently when an agent tries to register while the cluster is
installing the service will return a 400 response code. As a result the
agent will retry the request after one minute. To avoid that this patch
changes the response code to 409, which will cause the agent to freeze.

Related: https://issues.redhat.com/browse/MGMT-13132
Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>

Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>
  • Loading branch information
jhernand committed Jan 4, 2023
1 parent b952a3c commit 2d215c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/bminventory/inventory.go
Expand Up @@ -4999,7 +4999,7 @@ func (b *bareMetalInventory) V2RegisterHost(ctx context.Context, params installe
params.NewHostParams.HostID, params.InfraEnvID.String(), err.Error())
eventgen.SendHostRegistrationFailedEvent(ctx, b.eventsHandler, *params.NewHostParams.HostID, params.InfraEnvID, cluster.ID, err.Error())

return common.NewApiError(http.StatusBadRequest, err)
return common.NewApiError(http.StatusConflict, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/bminventory/inventory_test.go
Expand Up @@ -485,7 +485,7 @@ var _ = Describe("RegisterHost", func() {
By("verifying returned response")
apiErr, ok := reply.(*common.ApiErrorResponse)
Expect(ok).Should(BeTrue())
Expect(apiErr.StatusCode()).Should(Equal(int32(http.StatusBadRequest)))
Expect(apiErr.StatusCode()).Should(Equal(int32(http.StatusConflict)))
Expect(apiErr.Error()).Should(Equal(err.Error()))
})

Expand Down
4 changes: 2 additions & 2 deletions subsystem/cluster_test.go
Expand Up @@ -1772,7 +1772,7 @@ var _ = Describe("cluster install", func() {
HostID: strToUUID(uuid.New().String()),
},
})
Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterHostBadRequest()))
Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterHostConflict()))
})

It("register host while cluster in error state", func() {
Expand All @@ -1786,7 +1786,7 @@ var _ = Describe("cluster install", func() {
HostID: strToUUID(uuid.New().String()),
},
})
Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterHostBadRequest()))
Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterHostConflict()))
})

It("fail installation if there is only a single worker that manages to install", func() {
Expand Down

0 comments on commit 2d215c9

Please sign in to comment.