-
Notifications
You must be signed in to change notification settings - Fork 30
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
Use triple dashes at the end of the build args. #86
Conversation
👍 that's the first thing to try. Can you provide a job that proves that it fixes the problem ? |
Sorry just saw that this is still in progress. Hopefully this will fix #51 as well |
I think that deploying a test job on the farm with these settings and try to pass it various parameters is a good way to test it. Note that the logic of https://github.com/ros2/ci/blob/master/job_templates/ci_job.xml.em#L279-L284 and its derivation (for test args and for windows) will need to be updated accordingly as well |
@mikaelarguedas I'm testing with the code I just pushed here now. Thoughts about this approach of always doing it in the job? |
create_jenkins_job.py
Outdated
@@ -77,7 +77,7 @@ def main(argv=None): | |||
'use_osrf_connext_debs_default': 'false', | |||
'use_fastrtps_default': 'true', | |||
'use_opensplice_default': 'false', | |||
'ament_build_args_default': '--parallel --cmake-args -DSECURITY=ON --', | |||
'ament_build_args_default': '--parallel --cmake-args -DSECURITY=ON', |
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 think this should stay, otherwise what happens to the next argument added ? it will be considered part of the cmake args ?
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.
Oh, right, I see. I misunderstood the intent of that.
This actually points out a weakness in this approach, which I don't quite know how to resolve yet. If the user has a parameter like --cmake-args -DSECURITY=ON --
, then the command-line ends up resolving to something like:
--cmake-args -DSECURITY=ON -- --- --ament-test-args
Which causes the run_ros2_batch.py command-line parser to explode. We could fix that in the parser, but it doesn't quite seem to be the correct thing to do; that -- --- is gibberish, and probably shouldn't be allowed. I'm not sure how to handle it yet.
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.
Which causes the run_ros2_batch.py command-line parser to explode.
The -- ---
doesn't make sense, but --- --
would. So I'd say we need to fix the input, not the parsing in run_ros2_batch.py
. But that's just my opinion without looking into the details very much.
In case you're wondering how this is handled in the build tool, see:
- https://github.com/ament/ament_tools/blob/master/ament_tools/verbs/build_pkg/cli.py#L67
- https://github.com/ament/ament_tools/blob/master/ament_tools/build_types/cmake.py#L93
- https://github.com/osrf/osrf_pycommon/blob/master/osrf_pycommon/cli_utils/common.py#L65-L163
- http://osrf-pycommon.readthedocs.io/en/latest/cli_utils.html#osrf_pycommon.cli_utils.common.extract_argument_group
I agree with your assessment that we need to fix the input, not the parsing (I'm working on that now). I'm just curious about why you think |
|
6e2d649
to
79316fd
Compare
I just pushed what I'm currently working with. This piece of code mostly works on Linux, I have not yet tested Windows. However, it does not work in the situation that @wjwwood described in his last post; namely, if you pass It's starting to feel like this is the wrong path; but that being said, I don't have a better idea on what I should do at the moment. Suggestions are welcome, otherwise I'll sleep on it and give it another try tomorrow. |
Why not just Maybe it would be helpful to list the steps it goes through (something like Let me know if I can help. |
@wjwwood Thanks, that was a helpful way to go about it. There are actually a lot of steps that the whole thing goes through to get to the ament command-line. Just so I have it written down, here is a basic list:
Fundamentally, it seems to me like the problem lies in the double-parsing of the command-line options between run_ros2_batch.py and ament. One way we could get around this is by not passing the ament build/test arguments on the run_ros2_batch.py command-line, and instead have entry_point.sh write them to a file. Then run_ros2_batch.py would read in this file and pass those options unmolested through to ament, and things would work better (the same basic idea would be used on OSX and Windows, though the details would be different). Thoughts on this approach? |
I did do an implementation of the above on the pass-args-in-files branch. It seems to work OK (I've only tested Linux so far), though it introduces a bit more coupling between the Dockerfile and the ros2_batch_job script. If we like that approach better, I'll make that one work for Windows and OSX, give up on this branch, and open a different PR over there. |
@clalancette I actually think that the double parsing of the arguments, while somewhat hard to read, is not untenable. The whole point of being able to escape the
Which means that anytime a bare Again, maybe I'm missing some piece of the puzzle, but this seems like it should just work if we use the escaping mechanism correctly. |
It is possible to make it work with the escaping mechanism as you suggest, by replacing all -- on the command-line with ---. However, I'm not sure it's a general mechanism; what if the user puts --- in the Jenkins parameter? Do we then escape that with a ---- , etc? It just seems to me that having run_ros2_batch.py parse arguments that are not intended for it is a recipe for pain. By putting the ament Jenkins parameters into a file, we avoid all of that and give ament exactly the arguments the user intended. |
Yes, it's a relatively simple find/replace (maybe not with batch, but we could call out to Python if needed).
I think the escaping of the terminating character, i.e. |
Yeah, I agree about the visibility part; I can definitely have it print out (though in some sense, it already is because it ends up on the ament command-line, which is printed out). I actually don't feel that strongly about it. If you feel like there aren't further issues that we'll encounter down the road, then I can go with the simpler alternative of just escaping things. I'll update this PR to do that instead of the file, and see how things turn out. |
Sure, as I said, it's up to you. The escaping seems like a smaller change to me, but on the other hand it might be less robust long term. Let me know if I can help. |
According to https://social.technet.microsoft.com/Forums/scriptcenter/en-US/a009485a-046b-4dca-afd3-20555305e617/batch-variable-not-updating-as-expected?forum=ITCG and empirical evidence, variable expansion is done at read time, not execute time, by default in batch. The way to make it work at execute time is to setlocal enableDelayedExpansion (which we have), and use ! for all variables (which we don't have). Switch all of these to ! so that we get expansion at execute time. I can't say I understand why this worked before; it should have always had this problem. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This ensures that the -- makes it onto the command-line, and should fix jobs that sometimes gets the arguments embedded into the directory names. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
79316fd
to
58e7070
Compare
Regular for loops always split on space and equals signs, and there is nothing you can do about it. Switch to /f instead and do the loop ourselves, which is more ugly but actually works. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
All right, I've gone back and done what @wjwwood suggested and did the escaping inline. It does seem like it is going to work, and I'm running some test builds now. I'll set this back to review once I'm happy with those tests (and I'll link to them). |
all these test cases were working with the current implementation. Is it possible to test configurations that break the current one (e.g. http://ci.ros2.org/job/ci_osx/1901/parameters/ from the original issue)? |
Yeah, I'll do those additional tests as well. I just wanted to make sure all of the combinations were going to work, particularly on Windows (since I did a lot of batch hackery there, and I've never really done that before). |
I'm still running an additional test or two, but I'm pretty happy with this. So I think this is ready for review; I won't merge anything until the tests are complete. |
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 had two questions, otherwise lgtm.
set "PATH=!PATH:"=!" | ||
set "CI_ARGS=--force-ansi-color --workspace-path !WORKSPACE!" | ||
if "!CI_BRANCH_TO_TEST!" NEQ "" ( | ||
set "CI_ARGS=!CI_ARGS! --test-branch !CI_BRANCH_TO_TEST!" |
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.
Why did you need to replace all of the %...%
with !...!
? Is there a new double expansion?
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.
Ah, it's an interesting question. Windows batch files are kind of dumb; they expand any %...% variables at the time the statement is read, not at the time it is executed. Thus, constructs where you append arguments don't generally work like you expect. I saw this while I was testing on a local Windows instance. The workaround for this behavior is to specify setlocal enableDelayedExpansion
, but that doesn't change the behavior of %...% variables; it just introduces the concept of delayed expansion to !...! variables. Thus, since we are indeed doing appending on some of the variables, I just switched them all to !...!. One of the main references I used for this is here: https://ss64.com/nt/delayedexpansion.html
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 just switched them all to !...!.
I was a bit concerned about this, because you're change their behavior just because. I was always trying to use !...!
sparingly, defaulting to %...%
, because that is what you want after all.
It might not break anything, and it might even been necessary if there is a new mechanism for expanding that requires them all to be, but just switching them for consistency is not right imo.
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.
As the code stands now, you are right in that it is not strictly necessary for the vast majority of them (CI_ARGS is the obvious one that needs to be !...!). My motivation for converting them all is that this whole %...% vs. !...! business isn't really intuitive, particularly in the Jenkins environment. If someone ever tries to make another change where they change the value of the variable, they'll have to re-discover the correct mechanism. By switching them all, following the pattern becomes easier, and the variables will more-or-less always do what you expect.
That being said, if you still think we should leave them as %...%, I can switch it back (except for the ones that need to be !...!). Thoughts?
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 don't mind them being left as your patch is, but I just have no way of knowing (as a reviewer) if this will produce undesired behavior in some currently untested scenario. For all I know one or more of those should have been %...%
. It's a bit like replacing all ++x
with x++
because its function is confusing. I don't disagree that this mechanism in batch is confusing, but anyone who wants to touch any batch code needs to understand that difference when it is important.
As I said, in this case I'm fine to leave it, but in the future I'd avoid changing them unless there is a need to do so.
@@ -12,8 +12,6 @@ export ORIG_GID=$(echo $ORIGPASSWD | cut -f4 -d:) | |||
export UID=${UID:=$ORIG_UID} | |||
export GID=${GID:=$ORIG_GID} | |||
|
|||
ARCH=`uname -i` |
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.
Are you sure this is not needed anymore? Maybe it was used by dpkg
or in one of the later scripts? I don't know if either is the case, but I was wondering if you knew specifically that it wasn't.
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.
Hm, you know, I'm not 100% certain. I should probably just leave it alone for now. I'll revert that part.
We don't know for sure it is not needed anymore, so just leave it alone for now. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
All right, I'm going to merge this, and then I'll have to deploy it (which I haven't done before). I've read the README.md about running the |
All you have to do is run that script, but for it to work you have to setup your credentials for Jenkins locally. I think the instructions to do that are linked to from the readme. |
Thanks, deployed now, and running a test job to make sure everything is good. |
They get put literally into the result. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
This ensures that the -- makes it onto the command-line,
and should fix jobs that sometimes gets the arguments
embedded into the directory names.
I believe this will fix: ros2/build_farmer#33