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

Reuse the same upscaleState across StatefulSets #2339

Merged
merged 3 commits into from
Jan 3, 2020

Conversation

sebgl
Copy link
Contributor

@sebgl sebgl commented Jan 3, 2020

We had a bug where the second StatefulSet containing master nodes would
have its replicas set to 0, because it is not allowed to add additional
masters.

Turns out that's because we pass the upscaleState by value, so any mutation
we do on it is not preserved at the next call for the next StatefulSet. Moreover
it contains a sync.Once initialization not reused the second time. The first
StatefulSet is allowed master nodes creation thanks to the upscale state
initialization, but the second StatefulSet isn't because its
upscaleState is zeroed-out and not re-initialized.

This commit fixes it by passing around a StatefulSet pointer, and adds a
unit test that fails without the fix.

Fixes #2338.

We had a bug where the second StatefulSet containing master nodes would
have its replicas set to 0, because it is not allowed to add additional
masters.

Turns out that's because we passed a new upscaleState (by value), whose
innitialization to allow masters creation only happens once. The first
StatefulSet is allowed master nodes creation thanks to the upscale
initialization, but the second StatefulSet isn't because its
upscaleState is zeroed-out and not re-initialized.

This commit fixes it by passing around a StatefulSet pointer, and adds a
unit test that fails without the fix.
@sebgl sebgl added >bug Something isn't working v1.0.0 labels Jan 3, 2020
Copy link
Contributor

@barkbay barkbay left a comment

Choose a reason for hiding this comment

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

lgtm

@sebgl sebgl merged commit 9d771b3 into elastic:master Jan 3, 2020
barkbay pushed a commit to barkbay/cloud-on-k8s that referenced this pull request Jan 3, 2020
* Reuse the same upscaleState across StatefulSets

We had a bug where the second StatefulSet containing master nodes would
have its replicas set to 0, because it is not allowed to add additional
masters.

Turns out that's because we passed a new upscaleState (by value), whose
innitialization to allow masters creation only happens once. The first
StatefulSet is allowed master nodes creation thanks to the upscale
initialization, but the second StatefulSet isn't because its
upscaleState is zeroed-out and not re-initialized.

This commit fixes it by passing around a StatefulSet pointer, and adds a
unit test that fails without the fix.

* Add a comment to adjustStatefulSetReplicas

* Unit test upscaleState mutation in adjustStatefulSetReplicas
barkbay added a commit that referenced this pull request Jan 3, 2020
…tate across StatefulSets (#2315)(#2339) (#2344)

* Fix how cluster.initial_master_nodes is set (#2315)

Co-authored-by: Michael Morello <michael.morello@gmail.com>

* Reuse the same upscaleState across StatefulSets (#2339)

Co-authored-by: Sebastien Guilloux <contact.sebgl@gmail.com>
mjmbischoff pushed a commit to mjmbischoff/cloud-on-k8s that referenced this pull request Jan 13, 2020
* Reuse the same upscaleState across StatefulSets

We had a bug where the second StatefulSet containing master nodes would
have its replicas set to 0, because it is not allowed to add additional
masters.

Turns out that's because we passed a new upscaleState (by value), whose
innitialization to allow masters creation only happens once. The first
StatefulSet is allowed master nodes creation thanks to the upscale
initialization, but the second StatefulSet isn't because its
upscaleState is zeroed-out and not re-initialized.

This commit fixes it by passing around a StatefulSet pointer, and adds a
unit test that fails without the fix.

* Add a comment to adjustStatefulSetReplicas

* Unit test upscaleState mutation in adjustStatefulSetReplicas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug Something isn't working v1.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create master nodes if not in the first StatefulSet (E2E test TestReversalIllegalConfig fails)
3 participants