-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JENKINS-60054: Add umask
option to container
step
#1500
Conversation
@jglick any chance you can take a look? |
@Vlatombe seems like you are merged a couple of PRs lately, any chance you can look into this one? |
Reading through the jira issue, it looks like an interesting idea, though I don't think you need a new user attribute for this. |
User doesn't always have control to set umask in the container if the step is not sh but a step implemented by another plugin. Not to mention the toil and having to remember that every script needs umask... I am pretty sure that in this scenario 002 umask should be default. In fact - any kubernetes scenario... there isn't multi user containers. But I tried to be least invasive and preserve current behavior by default with that new user input attribute. |
Well, container('whatever') {
sh 'umask 002'
otherStep()
} Anyway from the Jira description I suspect this is just a workaround for something more fundamental broken in your environment. |
What am I doing wrong? |
Running the |
What am I doing wrong now? |
With images not already designed to run as |
This is typical for a pipeline to switch between versions of software to test things. For example - I want to test my code with different versions of Python. With Docker/Kubernetes, it is as simple as picking a correct tag. There are hundreds of tags on https://hub.docker.com/_/python, and if I get what you are implying correctly - you want me to re-build every tag of every public image to comply with Jenkins' made up standards, and do it continuously since versions of packages get regular security patches. Do that for python, ruby, go, java, terraform etc. This is such a waste of compute resources, and I wonder how that alone contributes to the energy grid strain. I am starting to think that the only thing I am doing wrong here is - using Jenkins. Which we already established from our past conversations, and Jenkins is actively getting replaced at my current employer (all while saving costs on rebuilding images and so much costs/time on made-up artificial limitations!). All I wanted is to share a two-line fix for an ages old problem, and help out the community. But if help is not needed and a response is to do some insane magnitude level things on the user side instead of a 2-line fix in the plugin code - feel free to close the PR and thank you, as always, for re-affirming my past choices! |
Of course not. There are a variety of ways to adapt to the mismatch between how containers were designed to be used and how they get used in CI systems which expect to mount common volumes, including tricks which do not require a separate image. (Yet another not previously mentioned here: end the |
What are these "variety of ways" you are talking about?
And if the pipeline suddenly aborts before having a chance to run this step, a cache volume will be left forever broken and the next container to grab it might not be having same user as the last container had (or root). Not to mention other possible cases like sharing a socket via a volume or any sort of simultaneous volume access. Look, this is not a problem limited to Jenkins, you are right. In fact, I had a feature request to add |
Are you using permanent volumes? It does not look that way from your example—the workspace is ephemeral to the pod. Mounting volumes for caching purposes is possible but much trickier for various reasons (not just file ownership). Just trying to clarify the use case, as this is the first time I can recall hearing of anyone attempting to make a pod with multiple UIDs work by means of |
I tried to boil down to minimal reproducible example, because what I am demonstrating is true for ephemeral/workspace volumes too, and wether it is possible to work around that issue on ephemeral/workspace volumes or not in any other way - the argument to be made here is that with a proposed feature in this PR it is much cleaner and convenient for the user. I'd even go as far as to argue that it has to be included as a best practice in the docs. What default umask was meant for is not even applicable in containerized environment - multi user containers is not a thing (practically speaking). A concept of a group regain its meaning in a multi-container environment though, such as a pod. Which I would speculate was the exact intention with But yes, biggest problem I am having is with cache volumes that are persistent and configured with Retain policy. I have a little controller that goes over Released volumes and makes them Available without actually wiping them out based on a SC annotation (it's OSS btw but I don't want to self advertise here). So let's say I have a storage class for m2 cache, but my users are using so many different Java images (that there is such a great abundance of this days), and some of them happen to use different users. Most are using root but there are cases that root can't be used (for example, users may try to run postgress from junit - and it will refuse to start under root, so they have to use |
|
A more complete example would be something to the effect of:
Which btw something until recently I was unable to do for |
I have mixed feelings. I understand the problem here is to use off-the-shelf container images, using UIDs that can differ from the This leads to various issues, the most apparent one being that the durable-task log is not writable by UIDs other than As mentioned, there is also the problem that the workspace directory gets read/written by different UIDs and this can lead to inconsistent results when using the default umask Similar issues are documented in Tekton Noting that gitlab went through the route of tweaking umask inside their build image, and it went really bad (#57 then #632, issue #1736 ...), so this is really a slippery area. About the solution proposed here
The main problem with proposing this as a solution for containers with different UIDs is that people who will typically use these (container images on-the-shelf) are the same people who are susceptible to smash their fingers with a hammer because they forgot they used a non-default umask while building their website and then publishing it.
Would be the saner option but comes with a performance cost, especially in the current
We had numerous contributions in the past that were accepted a bit too easily and ended up being a burden to maintain. Once something is in, it becomes much harder to remove. Especially here we're dealing with a plugin with a large number of users and a new option that could affect security. I understand you've done your best for your patch to be unintrusive. |
Noting that GitLab genius idea was to use
That's actually a good point, indeed it will be easy to slip up if the contents of the workspace is packaged. But I would emphasize that this PR does not make it a default behavior, and users need to opt-in explicitly to do this, and I am hoping you are not trying to prescribe users what they should and shouldn't do "for their safety".
Not only that but like I said earlier - build pod can experience involuntary disruption at any moment. This is Kubernetes. This will leave broken garbage behind.
I really do not understand this comment. The change is fully backward compatible and does not change pre-existing behavior in any way. It does not change default behavior either. Even if the argument to be made that setting wrong |
Well, of those who had this problem to begin with. AFAICT no prior pull request nor Jira issue referred to umask at all. So everyone else either
For the last two cases, an option to the There is a need to completely rewrite As an aside, for CloudBees CI customers we would recommend using a cache/uncache step for things like the local Gradle repo, rather than using a PVC which can be error-prone. |
Well if |
I was running into this issue for 8 years now, since 2016. And by "I" - I mean hundreds and hundreds of developers of all kinds I serviced over that time. And they almost never was able to understand why that was happening to them. As you can tell, it took me personally at least 3+ years to even be able to formulate it properly into JENKINS-60054 in 2019 (in big part by means of learning English from scratch), and another 4 to learn enough to be able to send you this PR. Mind you, I was somehow surviving all these years. And I always have better things to do other than argue with someone on GitHub, which is what tends to happen every time I try to contribute to Jenkins. Be aware of your survivorship bias. If you fail to visually observe a phenomenon, doesn't disprove it or even as much as imply that it doesn't exist. |
https://issues.jenkins.io/browse/JENKINS-60054
Testing done
Tested using following pipeline:
Which gives:
Submitter checklist
This fixes https://issues.jenkins.io/browse/JENKINS-60054