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
[kubelet]: Reconcile OS and arch labels periodically #104613
[kubelet]: Reconcile OS and arch labels periodically #104613
Conversation
5d759df
to
cdad360
Compare
/retest |
cdad360
to
912cf74
Compare
/retest |
pkg/kubelet/kubelet.go
Outdated
// Set the OS label if there is mismatch | ||
osName, ok := newNode.Labels[v1.LabelOSStable] | ||
if !ok || osName != sysruntime.GOOS { | ||
if len(newNode.Labels) == 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.
Should we log a warning here if the labels are not in sync?
I think people might be interested if something is repeatedly changing node labels to incorrect values.
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.
I don't have a strong opinion one way or the other. The logs could cause unncessary spamming sometimes. However I can't think of an entity which changes the values apart from kubelet unless it is sort of rogue entity and which should be caught by other means like OPA or validating admission hooks.
pkg/kubelet/kubelet.go
Outdated
|
||
func (kl *Kubelet) syncOSAndArchLabels() { | ||
for { | ||
time.Sleep(100 * time.Millisecond) |
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.
Should this be configurable or less frequent than 100ms?
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.
I am keeping it in sync with other methods. I don't see them configurable there.
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.
A wait.Forever here makes sense... 100ms seems too quick.
0e9e352
to
ada53f2
Compare
cc @aravindhp |
/sig windows |
c2c872a
to
726ca3a
Compare
Tests passed when I ran them locally on fedora:
|
726ca3a
to
3af5d37
Compare
/retest |
return false, err | ||
} | ||
osLabel, ok := node.Labels[v1.LabelOSStable] | ||
if !ok || osLabel != runtime.GOOS { |
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.
I would expect these to be parameters to this function in case there are other labels we'd test like this (are there other labels we should be testing?)
/approve The test is fine, i had comments but that doesn't block approval for me |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, ravisantoshgudimetla, smarterclayton 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 |
/test pull-kubernetes-node-kubelet-serial |
xref kubernetes/enhancements#2802 |
Once kubernetes#104613 and kubernetes#104693 merge, we'll have OS field in pod spec. Kubelet should start rejecting pods where pod.Spec.OS and node's OS(using runtime.GOOS) won't match
t.Logf("No action yet") | ||
return false, nil | ||
} | ||
action := actions[1] |
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.
this is no gorutine free and can panic
//go:build cgo && linux | ||
// +build cgo,linux |
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.
curious why this test requires cgo ... cgo compilation of e2e_node tests is causing issues on go1.20 (xref #115613 and golang/go#58425)
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.
I think it was a copy-paste error wrt cgo. I'll remove it and open a PR.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Kubelet should reconcile OS and Arch
labels periodically.
Which issue(s) this PR fixes:
Fixes #
Partially fixes kubernetes/enhancements#2803
Special notes for your reviewer:
This ensures that the kubelet would reject pods that have mismatching OS label selector. I'll expand this to the OS field in the pod spec once I introduce that field.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
cc @liggitt @derekwaynecarr @marosset