Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGMT-15349: Don't attempt to contact spoke while unbinding a day2 host #5383

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/controller/controllers/agent_controller.go
Expand Up @@ -758,7 +758,8 @@ func (r *AgentReconciler) updateStatus(ctx context.Context, log logrus.FieldLogg
if h.Progress != nil && h.Progress.CurrentStage != "" {
// In case the node didn't reboot yet, we get the stage from the host (else)
if swag.StringValue(h.Kind) == models.HostKindAddToExistingClusterHost &&
funk.Contains([]models.HostStage{models.HostStageRebooting, models.HostStageJoined, models.HostStageConfiguring}, h.Progress.CurrentStage) {
funk.Contains([]models.HostStage{models.HostStageRebooting, models.HostStageJoined, models.HostStageConfiguring}, h.Progress.CurrentStage) &&
agent.Spec.ClusterDeploymentName != nil {

spokeClient, err = r.spokeKubeClient(ctx, agent.Spec.ClusterDeploymentName)
if err != nil {
Expand Down
34 changes: 34 additions & 0 deletions internal/controller/controllers/agent_controller_test.go
Expand Up @@ -1148,6 +1148,40 @@ var _ = Describe("agent reconcile", func() {
Expect(result).To(Equal(ctrl.Result{}))
})

It("Agent status update does not panic when running unbind during day2 install", func() {
hostId := strfmt.UUID(uuid.New().String())
infraEnvId := strfmt.UUID(uuid.New().String())
logCollectionTime, _ := strfmt.ParseDateTime("2022-02-17T21:41:51Z")
hostKind := models.HostKindAddToExistingClusterHost
host := &common.Host{
Host: models.Host{
ID: &hostId,
Kind: &hostKind,
ClusterID: &sId,
InfraEnvID: infraEnvId,
Inventory: common.GenerateTestDefaultInventory(),
Status: swag.String(models.HostStatusInstallingInProgress),
StatusInfo: swag.String("Some status info"),
LogsCollectedAt: logCollectionTime,
Progress: &models.HostProgressInfo{
CurrentStage: models.HostStageConfiguring,
InstallationPercentage: 44,
},
},
}
agent := newAgent(hostId.String(), testNamespace, v1beta1.AgentSpec{ClusterDeploymentName: nil})
Expect(c.Create(ctx, agent)).To(BeNil())

mockInstallerInternal.EXPECT().GetHostByKubeKey(gomock.Any()).Return(host, nil).AnyTimes()
mockInstallerInternal.EXPECT().GetClusterInternal(gomock.Any(), installer.V2GetClusterParams{ClusterID: sId}).Return(backEndCluster, nil).AnyTimes()
mockInstallerInternal.EXPECT().UnbindHostInternal(gomock.Any(), gomock.Any(), false, bminventory.NonInteractive).Return(host, fmt.Errorf("no condition found to run transition"))
allowGetInfraEnvInternal(mockInstallerInternal, infraEnvId, "infraEnvName")

result, err := hr.Reconcile(ctx, newHostRequest(agent))
Expect(err).To(BeNil())
Expect(result).To(Equal(ctrl.Result{RequeueAfter: defaultRequeueAfterOnError}))
})

It("Agent bind", func() {
hostId := strfmt.UUID(uuid.New().String())
infraEnvId := strfmt.UUID(uuid.New().String())
Expand Down