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

Sync taints from machine spec to the node in additive fashion #154

Merged

Conversation

vikaschoudhary16
Copy link
Contributor

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 20, 2018
@@ -393,8 +393,22 @@ func (c *Controller) processNode(node *corev1.Node) error {
modNode.Labels[k] = v
}

// Taints are to be an authoritative list on the machine spec per cluster-api comments:
Copy link
Member

Choose a reason for hiding this comment

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

Nice!
Can you add a PR upstream even if it's to update the field comment and why we think should be additive?
Can you please add a validation for this machine/node taint reconciliation here https://github.com/openshift/machine-api-operator/blob/master/test/e2e/operator_expectations.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. how about handling e2e in follow-up PR?

Copy link
Member

Choose a reason for hiding this comment

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

please let's include it in this one, the point of having it in the same PR is that it prevent us from merging code which does not work as expected rather than having to fix later

@derekwaynecarr
Copy link
Member

Change looks good. Link to upstream feature for why it cannot be authoritative. See https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#taint-nodes-by-condition

modNode.Spec.Taints = matchingMachine.Spec.Taints
// Taints are to be an authoritative list on the machine spec per cluster-api comments.
// However, we believe many components can directly taint a node and there is no direct source of truth that should enforce a single writer of taints
for _, mTaint := range matchingMachine.Spec.Taints {
Copy link
Member

Choose a reason for hiding this comment

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

It'd be nice to create a function and unit test it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure.

}
}
if !alreadyPresent {
modNode.Spec.Taints = append(modNode.Spec.Taints, mTaint)
Copy link
Member

@enxebre enxebre Dec 20, 2018

Choose a reason for hiding this comment

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

we are appending here when nTaint.Key == mTaint.Key && nTaint.Effect != mTaint.Effect, so the final Taints
list will have duplicated keys. What will be the behaviour?

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 is list of taints and for a taint to be unique key and effect as a pair must be unique. PTAL at example here:
https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/#concepts

@vikaschoudhary16
Copy link
Contributor Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 20, 2018
@vikaschoudhary16 vikaschoudhary16 changed the title Sync taints from machine spec to the node in additive fashion [WIP]Sync taints from machine spec to the node in additive fashion Dec 20, 2018
@openshift-ci-robot openshift-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 20, 2018
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Dec 26, 2018
@vikaschoudhary16 vikaschoudhary16 changed the title [WIP]Sync taints from machine spec to the node in additive fashion Sync taints from machine spec to the node in additive fashion Dec 26, 2018
@openshift-ci-robot openshift-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 26, 2018
@vikaschoudhary16
Copy link
Contributor Author

vikaschoudhary16 commented Dec 26, 2018

/hold cancel

1 similar comment
@vikaschoudhary16
Copy link
Contributor Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 26, 2018
@vikaschoudhary16
Copy link
Contributor Author

/retest

glog.V(3).Infof("machine taint: %v", mTaint)
alreadyPresent := false
for _, nTaint := range node.Spec.Taints {
if nTaint.Key == mTaint.Key && nTaint.Effect == mTaint.Effect {
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we want to take into consideration the .value here?

}
machineList := capiv1alpha1.MachineList{}

if err := tc.client.List(context.TODO(), &listOptions, &machineList); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

this should be wrapped into wait.PollImmediate 186-195

}
node := &corev1.Node{}

if err := tc.client.Get(context.TODO(), nodeKey, node); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

this should be wrapped into wait.PollImmediate

}
glog.Info("Updated machine object with taint")
var expectedTaints = sets.NewString("not-from-machine", "from-machine")
err := wait.PollImmediate(1*time.Second, waitLong, func() (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

we could just return inline here

@enxebre
Copy link
Member

enxebre commented Jan 2, 2019

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enxebre

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 2, 2019
@enxebre enxebre added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 2, 2019
@enxebre
Copy link
Member

enxebre commented Jan 2, 2019

/test e2e-aws-operator

@enxebre
Copy link
Member

enxebre commented Jan 2, 2019

/test e2e-aws-gate

@enxebre
Copy link
Member

enxebre commented Jan 2, 2019

/test all

@enxebre enxebre removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 3, 2019
Copy link
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

One nit, but LGTM.

for _, taint := range node.Spec.Taints {
observedTaints.Insert(taint.Key)
}
if expectedTaints.Difference(observedTaints).HasAny("not-from-machine", "from-machine") == false {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use !<expression> and not == false.

@enxebre
Copy link
Member

enxebre commented Jan 3, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 3, 2019
@openshift-merge-robot openshift-merge-robot merged commit f24b3ef into openshift:master Jan 3, 2019
ingvagabund pushed a commit to ingvagabund/machine-api-operator that referenced this pull request Jul 11, 2019
Update namespace -> openshift-machine-api
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants