rundeck icon indicating copy to clipboard operation
rundeck copied to clipboard

Unable to use global variable in Remote Option URL port number

Open gschueler opened this issue 9 years ago • 13 comments

Bug report

My Rundeck detail

  • Rundeck version: 2.6.11 and 2.7.1
  • install type: any
  • OS Name/version: any

Expected Behavior

Using global variable in the port number of an option values URL should work.

Actual Behavior

GUI fails to save the change. javascript error:

POST http://ecto1.local:4440/editOpts/save?project=ctest&jobWasScheduled=false 500 (Server Error)
send @ jquery.js?compile=false:8706
ajax @ jquery.js?compile=false:8136
_optsave @ jobedit.js?compile=false:525
onclick @ 280a8afb-5fa9-451d-a2bc-df5852b06cfe:1

Yaml upload fails to validate:

$ rd jobs load -p ctest -f 280a8afb-5fa9-451d-a2bc-df5852b06cfe.yaml --format yaml
Error: Jobs Document was invalid for format yaml: rundeck.controllers.JobXMLException: Unable to create Job: For input string: "${globals.service_port}"
[code: api.error.jobs.import.invalid; APIv18]

How to reproduce Behavior

Set the remote option value URL for an option to something like: http://localhost:${globals.test_port}/path

gschueler avatar Feb 01 '17 23:02 gschueler

Took a brief look at the code.

I guess the issue is that the java.net.URL strictly validates (and requires RFC2396 addresses), and thus validates on construction (attempting to convert the context variable syntax to an int; fails). Other context variables (outside of the port itself) are technically valid RFC2396.

I guess the solution is to use String rather than URL here in Options.groovy and convert to URL when needed (in TBA locations!). This sounds like a chunk of work. Do you think that's the right solution? If so I might pursue it, as this is quite important for my project.

puremourning avatar Feb 16 '17 15:02 puremourning

@puremourning yes i think we need to change to use a string instead of URL to store the value. For grails db update purposes (until we have db-migration set up), it might work to simply change the field to String. If that doesn't work, could add a new String field, and have some logic in the Options class to use that field instead of the URL field.

URL was only used I think for the validation purposes in the first place, so the validation would have to be revamped. The place where the URL is used is only in the code which loads the remote json.

gschueler avatar Feb 16 '17 19:02 gschueler

FYI I have changed this locally (from URL type to String) and it seems to work.

puremourning avatar Mar 21 '17 16:03 puremourning

just to confirm, can I not do something like setting a globals to project.globals.options_server=localhost:5555/options ? would I have to set the port and path separately?

(it seems to urlencode and I get localhost%3A5555%2Foptions)

mumblez avatar Feb 10 '18 21:02 mumblez

you can do this:

project.globals.options_server=localhost:5555

then you can set the option provider to:

valuesUrl: http://${globals.options_server}/options/....

Which is what we ended up doing.

What you can't do is just configure the port in a global.

puremourning avatar Feb 10 '18 21:02 puremourning

@puremourning thanks for the quick response, that works 👍

mumblez avatar Feb 10 '18 21:02 mumblez

you're welcome.

puremourning avatar Feb 10 '18 21:02 puremourning

I tried this in a global variable instead and I do have a port configured (i.e.: server:port). I'm finding that the colon gets URL encoded for version 3.2.8 (i.e.: server%3Aport).

mcassaniti avatar Jul 15 '20 06:07 mcassaniti

Using global still works for me on rundeck 3.2.8. The only problem with this approach is that if/when the request fails of times out, the URL printed to the UI is url encoded, so you have to manually edit to add the colon if you want to manually run the request to check the output. This is fairly minor.

puremourning avatar Jul 15 '20 07:07 puremourning

Ahhh, that might explain something. Let me do a bit more testing and I will confirm. If it does I've suddenly saved a whole bunch of time trying to separate out our TEST and PROD environments.

mcassaniti avatar Jul 16 '20 04:07 mcassaniti

So I've successfully tested on 3.2.8 and got the expected results. I did hit the failure issue @puremourning mentioned, but I am successfully hitting the URL.

mcassaniti avatar Jul 21 '20 03:07 mcassaniti

In an effort to focus on bugs and issues that impact currently supported versions of Rundeck, we have elected to notify GitHub issue creators if their issue is classified as stale and close the issue. An issue is identified as stale when there have been no new comments, responses or other activity within the last 12 months. If a closed issue is still present please feel free to open a new Issue against the current version and we will review it. If you are an enterprise customer, please contact your Rundeck Support to assist in your request. Thank you, The Rundeck Team

stale[bot] avatar Jul 21 '21 04:07 stale[bot]

In an effort to focus on bugs and issues that impact currently supported versions of Rundeck, we have elected to notify GitHub issue creators if their issue is classified as stale and close the issue. An issue is identified as stale when there have been no new comments, responses or other activity within the last 12 months. If a closed issue is still present please feel free to open a new Issue against the current version and we will review it. If you are an enterprise customer, please contact your Rundeck Support to assist in your request. Thank you, The Rundeck Team

stale[bot] avatar Aug 01 '22 00:08 stale[bot]