-
Notifications
You must be signed in to change notification settings - Fork 32
Add cluster size validation marker #116
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
Conversation
Hi @frederiko. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
@frederiko: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
2ccf9d4
to
4745981
Compare
Thanks for the contribution, but I think it makes more sense to align with K8s's behaviour: set the minimum value as 0 instead of 1.
|
So, what happens right now if you apply a cluster of size 0 is that we have a cluster object with no pods. Which seems desireable; I can think of a number of circumstances where you might (temporarily) want a cluster with no members. So, +1 on @ahrtr's proposal |
@jberkus @ahrtr Not a problem at all. I just happened to have a different view from user's perspective. If I create a cluster with 0 members and I have no information about what happened, but have the resource persisted, I wouldn't like to have to tap into controller log for extra information. I couldn't also see a use case where an user may need a cluster with members. I will make the adjustments. |
In my opinion, we should start adding events to the EtcdCluster so the users can understand the current state of the CR. |
"If that is not desirable, other mechanisms would entail to write an event or update the status. However, more logic would be required.". I wouldn't oppose to that. :-) |
We will need to update/make use of the status regardless. What's the behaviour of some existing controller when the replica is 0, i.e. StatefulSet? |
tbh, I don't recall a controller that presents this behavior. I would have to check. |
83e5506
to
59e3c3b
Compare
I mean the Kubernetes built-in controller, i.e. StatefulSet. As mentioned above #116 (comment), the minimum replica is 0. Not sure whether the status will have some message or warning to indicate the 0 replica. We will need to do some experiments. |
@frederiko this PR is basing on a very old commit, please rebase this PR. thx |
deed49b
to
e6f3650
Compare
Yes, sts supports that. I meant more in the context of non-k8s controllers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good with two minor comments, thx.
Also it would be better if we have an e2e test to verify the minimum size.
/ok-to-test |
@frederiko have you manually verified this PR and confirmed a negative value (for the size) will raise an error? If yes, I think it's OK to merge it and add e2e test in followup PR; but it's also OK if you want to add the test in this PR. Please let me know your thought. |
3e83dd2
to
987e9e3
Compare
Signed-off-by: Frederiko Costa <[email protected]>
987e9e3
to
3b36917
Compare
I have just added a basic test to ensure that, when an Etcdcluster is created with zero members, no statefulset is created. Let me know if you would like to something else. |
func TestZeroMemberCluster(t *testing.T) { | ||
feature := features.New("zero-member-cluster") | ||
etcdClusterName := "etcd-cluster-zero" | ||
size := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size of 0 should work, but it doesn't work for now due to a bug (although a minor one) #125.
Since we explicitly require the minimum size is 0, so I think we should have two cases (i.e. table-driven sub tests):
- create a EtcdCluster with size of negative value (i.e. -1), it should fail.
- create a EtcdCluster with size 0, it should succeed. But it doesn't work for now due to the bug mentioned above, so as we comment it out for now (and link to the issue Operator should support scaling down to 0 ... maybe? #125).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahrtr yes, I am aware of the bug. What I tried to address in this PR was the 0 size behavior (aware of the bug). I am going to work on that bug later, on a separate PR, which should make this test to go away (remember my first commit was actually removing that block of code, but I was asked to revert?).
As for the -1 size, do we really need to test it, since the api server will not persist the etcdcluster resource altogether? I can certainly add if this is a concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I was asked to revert?
Sorry, when I raised the comment #116 (comment), we didn't know the bug (#125) yet
I am going to work on that bug later, on a separate PR
Please feel free to deliver a PR for it. Thanks.
As for the -1 size, do we really need to test it, since the api server will not persist the etcdcluster resource altogether? I can certainly add if this is a concern.
The high level idea is that we create or apply an EtcdCluster with -1, we should get an error, which might not be returned by etcd-operator's Reconcile method. I think it'd better to have a test for each feature or restriction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I have added a test for negative cluster size as well. I have kept the 0 size cluster one, and I will address the bug later, if that's fine with you. ltmk your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thx
Signed-off-by: Frederiko Costa <[email protected]>
2e25fd8
to
4f267dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a minor comment
Thanks
Signed-off-by: Frederiko Costa <[email protected]>
4f267dd
to
4b2835e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Thanks for your work on this @frederiko
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, frederiko, jmhbnz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR adds: