Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/graylog] Fix issue #13328, adjusting journal directory permissions #13329

Closed
wants to merge 1 commit into from
Closed

Conversation

juliohm1978
Copy link
Contributor

This should fix #13328, by allowing the initContainer to correctly adjust permissions on the journal directory before the main graylog container starts.

@helm-bot helm-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 27, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @juliohm1978. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 27, 2019
@helm-bot helm-bot added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Apr 27, 2019
@juliohm1978 juliohm1978 changed the title Fix issue #13328, adjusting journal directory permissions [stable/graylog] Fix issue #13328, adjusting journal directory permissions Apr 27, 2019
@helm-bot helm-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). labels Apr 27, 2019
@jlegrone
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 28, 2019
## If UID:GID is changed future graylog images, this can be corrected here as well.
initContainers:
graylogUID: 1100
graylogGID: 1100
Copy link
Member

Choose a reason for hiding this comment

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

I believe it is a pretty common convention to have something like this in values.yaml:

securityContext:
  enabled: false
  fsGroup: 1100
  runAsUser: 1100

Then in your pod template:

{{- if .Values.securityContext.enabled }}
securityContext:
  fsGroup: {{ .Values.securityContext.fsGroup }}
  runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}

Any reason not to set securityContext on the statefulset? It seems like this would avoid drift between expected and actual user/group IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

securityContext changes the user that runs inside the container. But that's not the cause of problem.

The graylog container itself already runs with 1100:1100, and that's why it fails to access a journal directory owned by another uid:gid. If the initContainer from this chart gets the same uid:gid, it won't be able to chown the journal directory. It won't be able to do that with the same user as the graylog container.

The chown operation is not always possible, or easily accomplished from outside the cluster in some cases.

I suppose the names used in values.yaml deserve consideration, but my intention was to make it clear that we are not running the initContainer with a different uid:gid, but rather using those values to fix permissions.

Copy link
Member

Choose a reason for hiding this comment

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

securityContext changes the user that runs inside the container. But that's not the cause of problem.

Right, what I'm wondering though is whether there would be a reason not to also make uid/gid configurable for the graylog container as part of this PR. If the graylog image switches to a different uid/gid (or if we wanted to make this configurable), then following convention now would prevent breaking changes in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good point.

However, the graylog image creates its user at build (Dockerfile). I doubt this can be changed at runtime without side effects. That is a more complicated PR on their side.

This is not a critical issue, and it's particular to some use cases only. It can be troubling to workaround, but it's not impossible.

Maybe better comments on values.yaml would avoid confusion. But I'm open to putting this PR on hold until we find a better way to implement this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cross relating this concern with the Graylog repo, issue #76 on their side.

I'm still not sure about the proper way to resolve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. I should be able to commit this later tonight.

Thank you, Jacob!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If PR #78 gets approved on their side, this one becomes unecessary. Let's see how that goes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jlegrone

Would it make sense to chmod 777 /usr/share/graylog/data/journal? That would make the journal directory writable to anyone, and there would no be a need to hardcode the uid:gid in the chart template. Keep in mind that would chmod only the root journal directory, and not its data and subdirectories.

Choose a reason for hiding this comment

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

@juliohm1978 's chmod 777 might sound wrong from a security perspective, but since no one aside the system admins has access to the journal volume and also thinking the journal data is ephemeral I think it is a good solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was able to rebase the PR with the chmod solution. Let me know if anything else is required.

@juliohm1978
Copy link
Contributor Author

/test pull-charts-e2e

@helm-bot helm-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). and removed Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2019
@juliohm1978
Copy link
Contributor Author

/retest

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: juliohm1978
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: kongz

If they are not already assigned, you can assign the PR to them by writing /assign @kongz in a comment when ready.

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

@helm-bot helm-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 30, 2019
@jlegrone
Copy link
Member

jlegrone commented May 3, 2019

Hold until Graylog2/graylog-docker#78 is reviewed by graylog folks.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 3, 2019
Signed-off-by: juliohm1978 <jhm@juliohm.com.br>
@juliohm1978
Copy link
Contributor Author

I'm closing this PR because of the conflict created by #12983. Apparently, that PR already pushed changes that include chown -R 1100:1100 ${GRAYLOG_HOME}/data/, which is the reason this one was created in the first place.

Thank you for the support!
Best regards.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
5 participants