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
Replace ownership change init container with K8s FSGroup #1078
Replace ownership change init container with K8s FSGroup #1078
Conversation
0a34bf5
to
9a82c3c
Compare
|
Hello 👋 Ukarsh, You have described test scenarios verbosely, however all reuse the existing PV. I'm wondering about clean install scenario in OpenShift environment. Is DB pod without ownership change init container able to use a fresh PV which was just provisioned for it? For instance, for the "2. Normal NooBaa deployment in OpenShift" what happens if we change "ii. Delete the DB Pod." to "ii. Delete the DB Pod and PVC" making sure DB gets a fresh PV? |
|
Hi @baum! That's a good test! I haven't performed it yet. Lemme get back to you once I am done testing this. Please lemme know if there are more tests that I should perform here. |
|
|
faccdf7
to
6a64533
Compare
36a01c7
to
721645d
Compare
|
I don't think that golangci-lint is upset with the PR rather something related to actions/runner-images#7188? 🤔 |
721645d
to
9dcfb0e
Compare
Please rebase, hope #1088 fixes the golangci-lint issue |
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com> fix fsgroup Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
9dcfb0e
to
a15e2e5
Compare
|
Thank you @baum! It fixed the test. |
Explain the changes
This PR attempts to replace FS ownership change init container with K8s FSGroup in an attempt to:
FSGroup unfortunately is not a silver bullet:
fsGrouppassed in pod spec. Kubelet does this simply by runningos.Lchown(file, -1, int(*fsGroup))which is run as arootuser. This should work most of the time HOWEVER in the issue linked above, it WILL fail because any operation performed by the root user will be executed asnobody:nogroupby NFS. This does NOT causes any issues however because kubelet just logs the error instead of erroring out. This works out in our favor in THIS case.0660 | os.ModeSetgid | 0110which ensures that we getdrwxdrwx--permission on the mounted directory which is good enough for us because we run group ID0whileos.ModeSetgidset the first octal to4implying that directories and files created within this directory will inherit the group ownership. This suffers the same problem in NFS (root_squash) mounts but because kubelet will not error out, it should work just fine.So this does NOT exactly fixes out problems with NFS mounts but makes sure that our DB pod doesn't ends up in CLBO because of permission issues but will crash if our second init container fails to do its thing (which it will if NFS mount does not provide enough permissions - which I think are available in the above issue's environment)
Reference: Kubernetes FSGroup Source Code
Tests Performed
drwxdrwxdrwxmount permissions androot_squashenabled).Issues: Fixed #xxx / Gap #xxx
Fixes noobaa/noobaa-core#7030.
Testing Instructions:
Passing pre-existing CLI tests should be good enough indication as only deployment has changed.