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
OCPBUGS-31376: kubelet: restorecon necessary files on kubelet's prestart #4287
OCPBUGS-31376: kubelet: restorecon necessary files on kubelet's prestart #4287
Conversation
@rphillips: This pull request references Jira Issue OCPBUGS-31376, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. In response to this: 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 openshift-eng/jira-lifecycle-plugin repository. |
@rphillips: This pull request references Jira Issue OCPBUGS-31376, which is valid. 3 validation(s) were run on this bug
In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
/cherry-pick release-4.15 |
@rphillips: once the present PR merges, I will cherry-pick it on top of release-4.15 in a new PR and assign it to you. In response to this:
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. |
/lgtm I think long-term it makes sense to move the kubenswrapper and kubensenter binaries to the kubelet rpm so we don't need to do this, but this is fine for now |
/approve |
On firstboot ignition writes this, and in subsequent boots the MCD writes the file pre-reboot. Since the old service ran before Looking at the bug, I assume this is an install time issue, which, now I thin about it, is probably because of https://issues.redhat.com/browse/MCO-536 I'm fine with fixing it this way but technically I think this is an underlying issue in the MCO (which is a bit harder to fix). Edit: thinking about this a bit more, I think this fix will end up with the same result. The files gets written without a service restart so it will break regardless |
@yuqi-zhang Thanks for the explanation. Agreed. We are seeing MCD update the files on the node, which then have the wrong selinux label. To fix this with the systemd units, we would have to create a restart dependency chain. Instead, I opted to fix this inline with the kubelet unit file for simplicity. We hope to migrate these scripts to the hyperkube rpm at some point, which would not have this problem. Kevin is going to work on a openshift/origin integration test to make sure we don't hit this problem in the future. |
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.
Ok, the understanding here is that the selinux labels can be overwritten after the kubelet already starts running, and that's not a problem. This is only a problem iff the kubelet restarts for some reason and the file has the wrong selinux label at that point, which I think should be covered by this.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: haircommander, rphillips, yuqi-zhang 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 |
/retest-required |
@rphillips: The following tests failed, say
Full PR test history. Your PR dashboard. 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. |
a9112cf
into
openshift:master
@rphillips: Jira Issue OCPBUGS-31376: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-31376 has been moved to the MODIFIED state. In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
@rphillips: #4287 failed to apply on top of branch "release-4.15":
In response to this:
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. |
[ART PR BUILD NOTIFIER] This PR has been included in build ose-machine-config-operator-container-v4.16.0-202403290310.p0.ga9112cf.assembly.stream.el8 for distgit ose-machine-config-operator. |
Fix included in accepted release 4.16.0-0.nightly-2024-03-30-033956 |
@@ -10,6 +10,7 @@ contents: | | |||
[Service] | |||
Type=notify | |||
ExecStartPre=/bin/mkdir --parents /etc/kubernetes/manifests | |||
ExecStartPre=-/usr/sbin/restorecon /usr/local/bin/kubenswrapper /usr/bin/kubensenter |
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.
Belated review but and I know this is just moving the original code but there is a giant difference between /usr/local/bin
and /usr/bin
: It's only the former that the MCO writes.
The files in /usr/bin
are written by ostree, and are immutable at runtime and will always have their labels correct (barring corruption).
Whoever added the code originally here probably added the -
to the ExecStart because they got EROFS, but we should have never needed to do that restorecon in the first place.
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.
We have to do the restorecon because MCD is laying down files after boot (about 5 minutes later). The overwritten files (that contain the same content) do not have the correct label written via MCD.
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'm not questioning the restorecon for /usr/local/bin
(though it is unfortunate). I'm saying the /usr/bin/
one should be unnecessary.
MCD will write the scripts after the kubelet relabel systemd unit is run, effectively resetting the selinux label. Let's restorecon the scripts within the kubelet systemd unit to guarantee the label when the kubelet systemd unit starts.