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

test validateCluster twice to make sure it does not flap #8088

Merged
merged 1 commit into from
Dec 12, 2019

Conversation

zetaab
Copy link
Member

@zetaab zetaab commented Dec 10, 2019

fixes #8078

/kind bug

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 10, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zetaab

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 10, 2019
@johngmyers
Copy link
Member

I think this is just papering over the problem. If a node is briefly validating before starting to throw failures again, this will cause rolling update to start draining the next node before the previous one is truly ready.

I think that after a cluster validates after terminating a node, we might want to wait a few seconds and then validate again to make sure it isn't flapping.

Copy link
Member

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

There are no unit tests for the new functionality. There should be.

cmd/kops/rollingupdatecluster.go Outdated Show resolved Hide resolved
@zetaab
Copy link
Member Author

zetaab commented Dec 10, 2019

what happens when this happens:

  1. master1 instancegroup is updated and finally validated using validateClusterWithDuration()
  2. between two validations, the cloud-controller-manager will start in master which was just created
  3. master2 instancegroup starts updating validateCluster() and fails

I do not see how this problem can be avoided without retrying? How we could know beforehand what kind of pods we have there "starting soon"? Master service pods do not exist at all in cluster when we do rolling updates to master.

I just updated 15 cluster using 1.17.0-alpha.1. The problem existed about almost half of them, so it was needed to execute rolling-update command many times before all masters was rotated.

cc @mikesplain @justinsb

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 10, 2019
@zetaab zetaab changed the title add pre validation timeout for rolling update Loop validateCluster to make sure it does not flap Dec 10, 2019
@zetaab
Copy link
Member Author

zetaab commented Dec 10, 2019

@johngmyers what you think about this solution what I modified now? It is much simpler, but is it so good?

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 10, 2019
Copy link
Member

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

I think you could meld together the logic in failAfterOneNodeClusterValidator and failThreeTimesClusterValidator to write a unit test for this.

pkg/instancegroups/rollingupdate.go Outdated Show resolved Hide resolved
pkg/instancegroups/instancegroups.go Outdated Show resolved Hide resolved
pkg/instancegroups/instancegroups.go Outdated Show resolved Hide resolved
pkg/instancegroups/instancegroups.go Outdated Show resolved Hide resolved
pkg/instancegroups/instancegroups.go Show resolved Hide resolved
pkg/instancegroups/rollingupdate_test.go Outdated Show resolved Hide resolved
@johngmyers
Copy link
Member

For me, the Cilium pod gets created before the node goes into ready state and takes so long to become ready that all the other kube-system pods get created first. So I don't have a good feel for what's going on in your masters.

There is the possibility that a kube-system pod could just flap unready due to ambient chaos, coinciding with the initial validateCluster() for an instancegroup and thus causing the rolling update to fail. This is unlikely at any given time, but over multiple rolling updates could crop up noticeably.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 11, 2019
@zetaab zetaab changed the title Loop validateCluster to make sure it does not flap WIP: Loop validateCluster to make sure it does not flap Dec 11, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 11, 2019
@zetaab zetaab changed the title WIP: Loop validateCluster to make sure it does not flap Loop validateCluster to make sure it does not flap Dec 11, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 11, 2019
@zetaab
Copy link
Member Author

zetaab commented Dec 11, 2019

I tried to understand how these tests works without success. So I cannot write tests for this if someone does not tell what is the logic in these tests? How I could reproduce flapping behaviour in tests. Any of these validate function calls in tests is not called multiple times if I increase validation timeout

@johngmyers
Copy link
Member

The tests use a test-specific fake ClusterValidator to produce a specified series of results and assert that the rolling update proceeds as expected.

failAfterOneNodeClusterValidator has the logic to query the state of the AutoScalingGroups in order to figure out when to act. The fake ClusterValidator for a new test would probably wait until there is one node left in the master-1 group before engaging the rest of its logic.

failThreeTimesClusterValidator has the logic to change the results from subsequent calls from validateClusterWithDuration(). So once the rolling update gets to one node left in master-1, it could return a defined sequence such as fail, succeed, fail, succeed, fail, succeed, succeed, succeed, ... One would then need an assertion somewhere (possibly in the fake validator after the rolling update has zero nodes in master-1) that the validator had been called the expected number of times.

@zetaab zetaab changed the title Loop validateCluster to make sure it does not flap test validateCluster twice to make sure it does not flap Dec 12, 2019
@zetaab
Copy link
Member Author

zetaab commented Dec 12, 2019

it does not work like that. Validate() is only called once, no matter how many time I will call validate in tryvalidatecluster

@zetaab
Copy link
Member Author

zetaab commented Dec 12, 2019

/test pull-kops-e2e-kubernetes-aws

Copy link
Contributor

@joshbranham joshbranham left a comment

Choose a reason for hiding this comment

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

Seems like a sane change to me for added validation

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 12, 2019
@joshbranham
Copy link
Contributor

/test pull-kops-e2e-kubernetes-aws

@k8s-ci-robot k8s-ci-robot merged commit 8fce3a1 into kubernetes:master Dec 12, 2019
@zetaab zetaab deleted the fix/rolling branch December 12, 2019 20:40
k8s-ci-robot added a commit that referenced this pull request Dec 15, 2019
#8105-upstream-release-1.17

Automated cherry pick of #8088: validate cluster twice #8105: Add unit test for flapping validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rolling-update: cluster not validated correctly
4 participants