Skip to content

Conversation

@britaniar
Copy link
Collaborator

@britaniar britaniar commented Dec 10, 2025

Description of your changes

I have:

  • Added a check to make sure no cluster start updating and let currently updating cluster finish within a stage before marking the stage and update run as stopped.

  • Update the stage condition status as stopping or stopped.

  • Update integration tests and added UTs.

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • Integration Test
  • Unit Test

Special notes for your reviewer

While waiting for cluster to finish updating, stage and update run will have a progressing unknown condition with the reason as stopping.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 87.41722% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/controllers/updaterun/stop.go 88.37% 11 Missing and 4 partials ⚠️
pkg/controllers/updaterun/controller.go 76.47% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
@britaniar britaniar marked this pull request as ready for review December 11, 2025 17:23
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
validateUpdateRunMetricsEmitted(wantMetrics...)
})

It("Should delete all the clusterResourceBindings in the delete stage and complete the update run", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a case where we stop in between the deletion stage ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried previously and we have no control over the clusters in the stage so the stop timing here is difficult.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can add a finalizer on the bindings so that they are not deleted.

validateUpdateRunMetricsEmitted(wantMetrics...)
})

It("Should wait for cluster to finish updating before update run is completely stopped", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This "It" section is redundant unless you want to check updateRun is in stopping state CONSISTENTLY.

validateUpdateRunMetricsEmitted(wantMetrics...)
})

It("Should delete all the clusterResourceBindings in the delete stage and complete the update run", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can add a finalizer on the bindings so that they are not deleted.

"github.com/kubefleet-dev/kubefleet/pkg/utils/condition"
)

var _ = Describe("UpdateRun stop tests", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a blocker to this PR, but this test is too complicated, including many unnecessary tests for stopping. If we can create a small number of updating/deleting clusters and a simpler strategy to just test the stop cases, that's better. We actually have one https://github.com/kubefleet-dev/kubefleet/blob/main/pkg/controllers/updaterun/controller_integration_test.go#L473C1-L490C2 This one does not have any to-be-deleted bindings though. Please feel free to add if you want to update.

@britaniar
Copy link
Collaborator Author

britaniar commented Dec 17, 2025

Will address any unresolved stop integration test specific comments in a follow up PR. Current integration test and UTs should have major coverage.
In the follow up PR I will reduce the integration so that we cover beforeStage -> stop -> cluster 1 -> stop -> afterStage -> stop -> deleteStage -> stop -> continue to complete.

Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
}
}

if allDeletingClustersDeleted || len(toBeDeletedBindings) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to check if len(toBeDeletedBindings), if len(toBeDeletedBindings) == 0 wouldn't allDeletingClustersDeleted be true ?

tt.updateRun.Status.StagesStatus[0].Conditions,
string(placementv1beta1.StageUpdatingConditionProgressing),
)
if progressingCond == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

cmp.Diff can handle nil values passed to it

},
},
},
UpdateStrategySnapshot: &placementv1beta1.UpdateStrategySpec{
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: do we need UpdateStrategySnapshot for this UT ?

}

// Check error expectations.
if tt.wantError {
Copy link
Collaborator

@Arvindthiru Arvindthiru Dec 18, 2025

Choose a reason for hiding this comment

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

Lets check the error similar to TestStopUpdatingStage, i.e. check the error msg instead of checking to see if error is errStagedUpdatedAborted, if we construct the wantErr correctly we don't need to use errors.Is ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants