Skip to content

[WIP] Set labels and taints on nodes via the MCO - #845

Closed
eparis wants to merge 1 commit into
openshift:masterfrom
eparis:labels-taints-mc
Closed

eparis wants to merge 1 commit into
openshift:masterfrom
eparis:labels-taints-mc

Conversation

@eparis

@eparis eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member

This provides a declarative API to drive the setting and removing of labels and taints. It does not work.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 12, 2019
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eparis
To complete the pull request process, please assign jlebon
You can assign the PR to them by writing /assign @jlebon in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details 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

@eparis
eparis force-pushed the labels-taints-mc branch from 8e62c1a to b498b0c Compare June 12, 2019 12:07
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2019
@eparis
eparis force-pushed the labels-taints-mc branch from b498b0c to 2a3b87c Compare June 12, 2019 12:10
@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

@derekwaynecarr mwahahahaha

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@eparis: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws-op 2a3b87c link /test e2e-aws-op

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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/test-infra repository. I understand the commands that are listed here.

@cgwalters

Copy link
Copy Markdown
Member

It does not work.

😆

@cgwalters

cgwalters commented Jun 12, 2019 •

Copy link
Copy Markdown
Member

What other components would write MachineConfig objects using this?
AIUI we need labels like the node-role to be set via the CLI for the initial setup, but doesn't it work just fine for other components to use the Kubernetes API to update the node object via a merge?

I remember a while ago we had an issue where cluster/machine API was entirely overwriting taints but that was just a bug, right?

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

ok, weird, maybe it does work? unexpected on the first try....

return err
}

newNode := oldNode.DeepCopy()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you need a fresh copy of the node object here at every iteration if there's a conflict?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Happened to notice the mcd has updateNodeRetry().

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

My/The problem is that adding and removing labels and taints is an imperative action on top of what is supposed to be a declarative system. This means that it's not possible for us to create a working 3-node cluster declaratively (since the masters are created with the master taint). Yes imperative code can run and then remove the taint, but that is not kube like.

This would allow us to create an MC which explicitly removed the master taint. Such a thing is a requirement for 3-node clusters and for the RHHI/foundation initiative.

https://jira.coreos.com/browse/PROD-1207

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

ok, weird, maybe it does work? unexpected on the first try....

well, i'm not plumbing the MC into the RenderConfig yet, so I guess it doesn't work yet.

What would be the team's thought on putting the 'role' into the renderConfig? It would allow me to cut down the number of kubelet templates at least...

@runcom

runcom commented Jun 12, 2019

Copy link
Copy Markdown
Member

What would be the team's thought on putting the 'role' into the renderConfig?

I can't see anything against it to drive this (as it requires differentiating between roles anyway) - I'll keep reading and understanding this though

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

What would be the team's thought on putting the 'role' into the renderConfig?

I can't see anything against it to drive this (as it requires differentiating between roles anyway) - I'll keep reading and understanding this though

It might make the code a little simpler. Not sure. I'll probably keep slowly poking. Thank you!

@cgwalters

Copy link
Copy Markdown
Member

This means that it's not possible for us to create a working 3-node cluster declaratively (since the masters are created with the master taint).

OK so you're trying to fix #763 - a Closes: here would be appropriate. Also I think some design discussion in that issue before a big code change would have been a good idea.

Such a thing is a requirement for 3-node clusters and for the RHHI/foundation initiative.

(Also a requirement for Code Ready Containers)

@cgwalters

Copy link
Copy Markdown
Member

With respect to implementation, did you have any opinions on my other suggestions in that issue?

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

I like to show up with PoC code to show something is possible. I don't care if this code is completely rejected. Probably my years in the kernel where it is normal. I understand and can have a design discussion a heck of a lot better having coded (most of) it.

I think it's more than 763, but agree, that is the current thing forcing me to look at the space. The declarative management of labels and taints, instead of imperative, is a meaningful win to me.

--container-runtime=remote \
--container-runtime-endpoint=/var/run/crio/crio.sock \
--node-labels=node-role.kubernetes.io/master,node.openshift.io/os_id=${ID} \
--node-labels={{masterLabels .}} \

@cgwalters cgwalters Jun 12, 2019 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing I discovered is that --node-labels docs clearly says:

Labels to add when registering the node in the cluster

So changing it post-registration won't do anything. Hence I think we shouldn't template this; the systemd unit should register with the default labels/taints (as the code is today). And then the MCO comes by later and updates them dynamically.

We also want to avoid using MachineConfig for this because e.g. changing a MC today involves rebooting and we clearly don't need to reboot for removing the master taint.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This part was intended to make the NEXT node join correctly. Instead of getting 1 set of labels and then later having that set get updated. For existing nodes I update those:
https://github.com/openshift/machine-config-operator/pull/845/files#diff-a44cd14a0381ca49bcbaaf967b3cc9b0R556

The fact that an MC change requires a reboot is kinda stinky....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This part was intended to make the NEXT node join correctly.

Doesn't hurt to have a master start !schedulable briefly. For workers...we may indeed need support for adding user-specified custom labels on bringup for special hardware and the like, but I think most cases of that end up adding taints instead post-registration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding labels and removing taints post-join is reasonable. But adding a taint post join isn't really the best in my mind, since an inappropriate workload may have landed before the taint was added. So I sort of feel like the right taints should be added by the kubelet at join.

We could add every node with some megataint in the template. But then removing that taint would be required for every new pool. Which of course we can get right for our defaults, but is a likely bad stumbling block for users who aren't super savy.

I guess that means I feel like I can drop this part for labels, but the complete story seems weak if I drop it for taints....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But adding a taint post join isn't really the best in my mind, since an inappropriate workload may have landed before the taint was added.

True.

@cgwalters

cgwalters commented Jun 12, 2019 •

Copy link
Copy Markdown
Member

How about having the taints be part of MachineConfigPool? (We can't have the node-role as part of the pool as that'd be circular, but we could have additional labels be part of the pool).

@cgwalters

Copy link
Copy Markdown
Member

I haven't fully traced through your logic here but I suspect we have "ownership" problems. This is quite analogous to kernel arguments which are an array of key=value strings too. Today the way the MCD handles this is to diff two MCs but I don't see your code doing a similar diff.

If we don't diff, then we can't easily know which args we wrote versus which args were written by a user or other code.

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

I haven't fully traced through your logic here but I suspect we have "ownership" problems. This is quite analogous to kernel arguments which are an array of key=value strings too.

If we don't diff, then we can't easily know which args we wrote versus which args were written by a user or other code.

I tried to create an API that didn't suffer from these difficulties. The API I'm proposing has an explicit 'these labels must exist' and 'these labels must not exist' concept. The hope being that I don't need to track previous state or user changes, and i'm only going to make sure the specified labels are either present or not present.

@cgwalters

Copy link
Copy Markdown
Member

The API I'm proposing has an explicit 'these labels must exist' and 'these labels must not exist' concept.

Mmm. OK, I think that's workable.

So where that leaves us then is whether or not this should go through MachineConfig (which also goes into whether we template as above). I still feel like it shouldn't, because of the MC-reboot issue but also because I think it's cleaner to just have one thing reacting to state rather than two (template controller and node controller).

Having the node controller do this is by far the easiest code wise but it makes the architecture uglier - this label stuff is a "sidecar" to what it is currently doing and isn't correctly tracked via status e.g.

@eparis

eparis commented Jun 12, 2019

Copy link
Copy Markdown
Member Author

How about having the taints be part of MachineConfigPool? (We can't have the node-role as part of the pool as that'd be circular, but we could have additional labels be part of the pool).

We can probably do something here, yes (and that would avoid a reboot). But I admittedly really like the MC merging concept.

@cgwalters

Copy link
Copy Markdown
Member

I did an alternative (subset) in #849

(I don't want to discourage a new contributor but this is also a new nontrivial API surface)

Let me know what you think about it!

If we move forward with this PR, one thing to consider is doing what I do in 849 and have the MCD own updating the node. That makes everything much clearer I think; the spec/status of the pool will automatically include updates to labels/taints, node controller's role will be unchanged, etc.

cgwalters added a commit to cgwalters/machine-config-operator that referenced this pull request Jun 13, 2019
If a user or code adds the `worker` role to the masters, automatically
remove our `NoSchedule` taint.

Alternative to openshift#845

Closes: openshift#763
@eparis

eparis commented Jun 14, 2019

Copy link
Copy Markdown
Member Author

I'm going to close this generic label/taint management PR. After discussion with the other openshift architects they thought this work was too far ahead of itself and we should wait for more users to want generic taint/label reconciler before we do more here.

Instead they want to do something more directed (sorta like in #849) but they thought that the scheduler operator should be what implements that. Not the MC* codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants