-
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-46253 Add support for subPath to all volume types #1031
base: master
Are you sure you want to change the base?
Conversation
92b7695
to
a6928ef
Compare
Includes work from Miguel Campos (jenkinsci#1024) refs JENKINS-46253
a6928ef
to
92fc68c
Compare
Dear Hameno, I created a new constructor but I maintained the old one that calls the new one: If I'm not seeing wrong you changed the constructor but did not maintain the old one for compatibility purpose that might be a reason for the pull request to be rejected. Thanks. |
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.
Please revert any hunk unrelated to the change you want to accomplish.
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
import java.nio.file.Paths; | ||
import java.util.*; |
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.
Don't use wildcard imports in production code. Please revert.
import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.combine; | ||
import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.isNullOrEmpty; | ||
import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.substituteEnv; | ||
import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.*; |
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.
Ditto above.
import java.util.List; | ||
|
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.
Please revert
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; |
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.
Please avoid this kind of change that is just making reviews and blaming more complex.
// We need to normalize the subPath, or we can end up in really hard to debug issues Just in case. | ||
final String subPath = substituteEnv(Paths.get(volumeSubPath).normalize().toString().replace("\\", "/")); |
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.
Is that normalization really needed? What happens if the agent is on Windows?
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.
Hello Viatombe,
I'm answering this because this piece of code is also in my original PR wich was intended only for ConfigMap volumes.
I think the answer applies on both.
To be honest I do not know what will happen in a windows container.
But what I can see is that that normalization is there since 4 years ago. in commit: 43afca4c3209dc6b1d8b768b157ab53cc12da052 made by Alex Johnson ajohnson@bombora.com
The only modification I did was to surround it with an if to control whether the new parameter is empty or not.
So I guess that piece of code is as secure or insecure as it was before and is out of the intention of this PR to modify/evaluate that.
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.
It's fine, I didn't see that the same code was applied to mountPath.
@DataBoundConstructor | ||
public ConfigMapVolume(String mountPath, String configMapName, Boolean optional, String subPath) { |
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.
Instead of this, you could add a setter for subPath
annotated with @DataBoundSetter
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.
Hello, viatombe,
I'm going to need a bit more explanation on why this is not the correct way of doing things. or how you preffer me to do it
I do not know why is wrong the go from 3 parameters in the constructor to 4.
I do not know the difference between @DataBoundConstructor and @DataboundSetter.
however @DataBoundSetter was not used anywhere in the previous code.
and I'm just adding a new parameter to the constructor. keeping the old one for compatibility issues.
I do not know where is the issue. please explain.
I'm very happy to learn the right way of doing things.
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.
You can read the explanation here -- Constructor vs. setters.
In that case ideally only mountPath
and configMapName
should be left in the constructor since they are mandatory, and optional
and subPath
should be set using setters.
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.
@hameno : would you be able to progress this further after the comments ? This is a great feature that is direly missing |
Unfortunately I won't have capacity until next year. I found a workaround which works for us so this currently doesn't have priority |
May I ask what workaround you're using ? (right now, I'm just mounting the whole volume and hardcoding paths ... that will work, but if there's better, I wouldn't mind ;) ) |
(On mobile right now, so not exactly sure how it's called) |
Hello, any chance this pull request will be finalized ? |
Includes work from Miguel Campos (#1024)
refs JENKINS-46253