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

Make parallel restart of already bootstrapped nodes the default - CASS-79 #733

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

burmanm
Copy link
Contributor

@burmanm burmanm commented Nov 18, 2024

What this PR does:
The previous fastpath is now made the default behavior. User can disable the fastpath by setting `cassandra.datastax.com/allow-parallel-starts: "false"``

Which issue(s) this PR fixes:
Fixes #731

Checklist

  • Changes manually tested
  • Automated Tests added/updated
  • Documentation added/updated
  • CHANGELOG.md updated (not required for documentation PRs)
  • CLA Signed: DataStax CLA

@burmanm burmanm requested a review from a team as a code owner November 18, 2024 13:20
@adejanovski adejanovski changed the title Make parallel restart of already bootstrapped nodes the default Make parallel restart of already bootstrapped nodes the default - CASS-79 Nov 19, 2024
Copy link
Member

@Miles-Garnsey Miles-Garnsey left a comment

Choose a reason for hiding this comment

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

I've left a few comments here, I'd love to see a test that shows the pods restarting concurrently.

@@ -672,6 +672,10 @@ func (rc *ReconciliationContext) checkSeedLabels() (int, error) {
return seedCount, nil
}

func shouldUseFastPath(dc *api.CassandraDatacenter, seedCount int) bool {
return seedCount > 0 && !(metav1.HasAnnotation(dc.ObjectMeta, api.AllowParallelStartsAnnotations) && dc.Annotations[api.AllowParallelStartsAnnotations] == "false")
Copy link
Member

Choose a reason for hiding this comment

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

Question: Would it be possible to still have concurrent restarts for nodes which aren't seed nodes?

Issue: Can we modify the changelog to reflect that concurrent starts only applies if there is more than one seed (if not).

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: I had to think about this logic for a few minutes. It might be clearer to read if you remove the parenthese, distribute the negation and split it over multiple lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has nothing to do with being a seed node or not, we bootstrap all the nodes. That count is the amount of available seed nodes in the cluster. The seed node is not what user sets or controls. If there are 0 seed nodes, that means there are 0 nodes up or 0 bootstrapped nodes. We will never start multiple nodes that need bootstrapping at the same time so having 0 seed nodes would not really be useful scenario.

The only case this can happen is that the cluster was Stopped and then resumed. In that case, we need to first start one node -> which is then the seed and then start the rest after that one has started.

Removing the parenthese would change the logic and make it at least for me more difficult to read. Now it's two part logic (either we fail in the first one or next ones are true), removing parenthese would make it 3 parts to keep in mind.

Especially since the last two have to be tied together with && or we get a nil pointer (we can't evaluate the value if the annotations are not set).

I'm not entirely sure even what is your suggestion for the alternative logic. Can you code it?

Copy link
Member

Choose a reason for hiding this comment

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

I'm suggesting:

return seedCount > 0 && 
  !metav1.HasAnnotation(dc.ObjectMeta, api.AllowParallelStartsAnnotations) &&
  !dc.Annotations[api.AllowParallelStartsAnnotations] == "false"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That code wouldn't even compile. What you probably meant was:

return seedCount > 0 && 
  !metav1.HasAnnotation(dc.ObjectMeta, api.AllowParallelStartsAnnotations) &&
  dc.Annotations[api.AllowParallelStartsAnnotations] != "false"

And that changes the logic. Not just because dc.Annotations could be nil in this case (as HasAnnotation checks it's not nil or it would return false, yet now we get false false -> true), but also because the check is different. The test even revealed this.

If dc.Annotations[api.AllowParallelStartsAnnotations] == "true", then we should use the fastpath. The code you proposed returns false in this case, since the annotation has been set and in that case the proposed code would return false. And it's allowed to be set, we should only reject the fastpath if it's set to false, no other case.

pkg/reconciliation/reconcile_racks_test.go Show resolved Hide resolved
pkg/reconciliation/reconcile_racks_test.go Show resolved Hide resolved
pkg/reconciliation/reconcile_racks_test.go Show resolved Hide resolved
pkg/reconciliation/reconcile_racks_test.go Show resolved Hide resolved
Copy link
Member

@Miles-Garnsey Miles-Garnsey left a comment

Choose a reason for hiding this comment

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

I've left one suggestion in place, please implement it if you think it is worthwhile. If not I'm approving in any event.

@burmanm burmanm merged commit e580f21 into k8ssandra:master Nov 25, 2024
47 checks passed
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.

Concurrent restarts of previously bootstrapped nodes should be the default
2 participants