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

pkg/controller: resync on unavailable #601

Closed
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
7 changes: 4 additions & 3 deletions pkg/controller/node/node_controller_test.go
Expand Up @@ -784,7 +784,7 @@ func TestShouldMakeProgress(t *testing.T) {
expMcp.Status = expStatus
f.expectUpdateMachineConfigPoolStatus(expMcp)

f.run(getKey(mcp, t))
f.runExpectError(getKey(mcp, t))
}

func TestEmptyCurrentMachineConfig(t *testing.T) {
Expand Down Expand Up @@ -816,7 +816,7 @@ func TestPaused(t *testing.T) {
expMcp.Status = expStatus
f.expectUpdateMachineConfigPoolStatus(expMcp)

f.run(getKey(mcp, t))
f.runExpectError(getKey(mcp, t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we now have a successful test where f.run just runs? (mocking machines len)

}

func TestShouldUpdateStatusOnlyUpdated(t *testing.T) {
Expand Down Expand Up @@ -858,11 +858,12 @@ func TestShouldUpdateStatusOnlyNoProgress(t *testing.T) {
}

expStatus := calculateStatus(mcp, nodes)
t.Logf("expStatus: %v", expStatus)
expMcp := mcp.DeepCopy()
expMcp.Status = expStatus
f.expectUpdateMachineConfigPoolStatus(expMcp)

f.run(getKey(mcp, t))
f.runExpectError(getKey(mcp, t))
}

func TestShouldDoNothing(t *testing.T) {
Expand Down
10 changes: 9 additions & 1 deletion pkg/controller/node/status.go
Expand Up @@ -29,7 +29,15 @@ func (ctrl *Controller) syncStatusOnly(pool *mcfgv1.MachineConfigPool) error {
newPool := pool
newPool.Status = newStatus
_, err = ctrl.client.MachineconfigurationV1().MachineConfigPools().UpdateStatus(newPool)
return err
if err != nil {
return err
}

if newPool.Status.UnavailableMachineCount != 0 ||
newPool.Status.UpdatedMachineCount != newPool.Status.MachineCount {
return fmt.Errorf("resync needed: unavailable machines or un-updated machine present")
}
return nil
}

func calculateStatus(pool *mcfgv1.MachineConfigPool, nodes []*corev1.Node) mcfgv1.MachineConfigPoolStatus {
Expand Down