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

fix race condition #52

Merged
merged 13 commits into from
Oct 16, 2022
Merged

fix race condition #52

merged 13 commits into from
Oct 16, 2022

Conversation

hyang200
Copy link
Contributor

@hyang200 hyang200 commented Oct 7, 2022

This PR fixes race conditions where nodes are terminated (i.e by cluster-autoscaler) while in the progress of cycling nodes, which is identify in:

  • Cordon Phase - Trying to cordon a node that has been removed from k8s api, CNR failed with
Node "xxxx" not found
  • Healing Phase - Trying to re-attach a ec2 instance to ASG that's in terminated/shutting down

To simulate the senario we can insert below to each of the transition phases

// simulate unexpected termination 
for _, node := range t.cycleNodeRequest.Status.CurrentNodes {
err := t.rm.CloudProvider.TerminateInstance(node.ProviderID)
t.rm.LogEvent(t.cycleNodeRequest, "TestTerminate", "Terminating: %v, err: %v", node.Name, err)
_, err = t.rm.GetNode(node.Name)
	}

@atlassian-cla-bot
Copy link

atlassian-cla-bot bot commented Oct 7, 2022

Hooray! All contributors have signed the CLA.

@@ -303,8 +303,8 @@ func (t *CycleNodeRequestTransitioner) transitionScalingUp() (reconcile.Result,

// Check we have waited long enough - give the node some time to start up
if time.Since(scaleUpStarted.Time) <= scaleUpWait {
t.rm.LogEvent(t.cycleNodeRequest, "ScalingUpWaiting", "Waiting for new nodes to be ready")
return reconcile.Result{Requeue: true, RequeueAfter: requeueDuration}, nil
t.rm.LogEvent(t.cycleNodeRequest, "ScalingUpWaiting", "Waiting for new nodes to be warmed up")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

reduce the number of unnecessary requeue

@@ -160,7 +160,7 @@ func (t *CycleNodeRequestTransitioner) finalReapChildren() (shouldRequeue bool,
}

switch t.cycleNodeRequest.Status.Phase {
case v1.CycleNodeRequestInitialised:
case v1.CycleNodeRequestInitialised, v1.CycleNodeRequestFailed:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix Failed CNR in infinity loop of re-queue

@vincentportella
Copy link
Member

Change the version in the makefile to 1.8.2

@dtnyn
Copy link
Collaborator

dtnyn commented Oct 7, 2022

Change the version in the makefile to 1.8.2

We can wait to cut release in a separate PR to not mix this issue changes with the release cut trigger

@vincentportella
Copy link
Member

You are correct 🤦‍♂️

@hyang200 hyang200 marked this pull request as ready for review October 10, 2022 05:09
pkg/k8s/node.go Outdated Show resolved Hide resolved
dtnyn
dtnyn previously approved these changes Oct 11, 2022
@hyang200
Copy link
Contributor Author

closing to investigate intermediate failure in pre-termination trigger

@hyang200 hyang200 closed this Oct 11, 2022
- soft fail pretermination trigger and checks
@hyang200 hyang200 reopened this Oct 12, 2022
dtnyn
dtnyn previously approved these changes Oct 13, 2022
Copy link
Collaborator

@dtnyn dtnyn left a comment

Choose a reason for hiding this comment

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

LGTM

@hyang200
Copy link
Contributor Author

hyang200 commented Oct 13, 2022

@vincentportella there're many other places where %v is used for string values, i don't really know what difference would %s make, but feel free to raise another PR if you wish to get rid of all of them. please let me know if you have any other feedback.

Copy link
Member

@vincentportella vincentportella left a comment

Choose a reason for hiding this comment

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

lgtm

@hyang200 hyang200 merged commit eaf643c into atlassian-labs:master Oct 16, 2022
@hyang200 hyang200 deleted the fix-race-condition branch October 16, 2022 22:49
hyang200 added a commit that referenced this pull request Oct 25, 2022
- improvement for race condition handling #52
@hyang200 hyang200 mentioned this pull request Oct 25, 2022
hyang200 added a commit that referenced this pull request Oct 25, 2022
- improvement for race condition handling #52
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.

3 participants