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

Add missing requeue to Datacenter decommission #322

Merged
merged 4 commits into from
Apr 21, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/kindIntegTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
- "3.11.7"
- "3.11.11"
- "4.0.0"
- "4.0.1"
- "4.0.3"
include:
- version: 3.11.7
serverImage: k8ssandra/cass-management-api:3.11.7-v0.1.24 # k8ssandra 1.1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti
* [CHANGE] [#264](https://github.com/k8ssandra/cass-operator/issues/264) Generate PodTemplateSpec in CassandraDatacenter with metadata
* [CHANGE] [#183](https://github.com/k8ssandra/cass-operator/issues/183) Move from PodDisruptionBudget v1beta1 to v1 (min. Kubernetes version 1.21)
* [ENHANCEMENT] [#292](https://github.com/k8ssandra/cass-operator/issues/292) Update to Go 1.17 with updates to dependencies: Kube 1.23.4 and controller-runtime 0.11.1
* [BUGFIX] [#322](https://github.com/k8ssandra/cass-operator/pull/322) Add missing requeue if decommissioned pods haven't been removed y et

## v1.10.3

Expand Down
2 changes: 2 additions & 0 deletions pkg/reconciliation/reconcile_datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func (rc *ReconciliationContext) ProcessDeletion() result.ReconcileResult {
// Exiting to let other parts of the process take care of the decommission
return result.Continue()
}
// How could we have pods if we've decommissioned everything?
return result.RequeueSoon(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you adding the requeue here to handle the scenario where len(dcs) == 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why would we requeue in that case? If len(dcs) == 1, we go and delete the DC.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not obvious to me why the need for the requeue here. Can you explain?

}
}

Expand Down
35 changes: 20 additions & 15 deletions pkg/reconciliation/reconcile_racks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2132,27 +2132,32 @@ func (rc *ReconciliationContext) cleanupAfterScaling() result.ReconcileResult {
}

if task != nil {
if task.Status.CompletionTime != nil {
// Job was completed, remove it from followed task
dc := rc.Datacenter
dcPatch := client.MergeFrom(dc.DeepCopy())
return rc.activeTaskCompleted(task)
}

rc.Datacenter.Status.RemoveTrackedTask(task.ObjectMeta)
// Create the cleanup task
err = rc.createTask("cleanup")
if err != nil {
return result.Error(err)
}

if err := rc.Client.Status().Patch(rc.Ctx, dc, dcPatch); err != nil {
return result.Error(err)
}
return result.RequeueSoon(10)
}

return result.Continue()
}
} else {
// Create the cleanup task
err := rc.createTask("cleanup")
if err != nil {
func (rc *ReconciliationContext) activeTaskCompleted(task *taskapi.CassandraTask) result.ReconcileResult {
if task.Status.CompletionTime != nil {
// Job was completed, remove it from followed task
dc := rc.Datacenter
dcPatch := client.MergeFrom(dc.DeepCopy())

rc.Datacenter.Status.RemoveTrackedTask(task.ObjectMeta)

if err := rc.Client.Status().Patch(rc.Ctx, dc, dcPatch); err != nil {
return result.Error(err)
}
}

return result.Continue()
}
return result.RequeueSoon(10)
}

Expand Down