harlanbarnes / lita-rundeck

Lita handler for interacting with Rundeck server
MIT License
8 stars 6 forks source link

Comma separated options aren't parsing? #12

Open Jinkxed opened 8 years ago

Jinkxed commented 8 years ago

Hiyas!

Thanks so much for writing this gem, I have a lot of plans for it and I hope you are still maintaining it.

However I did run into an issue.

If I try to run a job that I have set options in that are required. None of them seem to get passed?

Example and logs:

rundeck run --project ExampleProject --job manage-applications [--options Environment=staging, Product=product1,Role=role1] [--report all]

Job options were not valid: Option 'Environment' is required.Option 'Product' is required.Option 'Role' is required.

In the logs I see:

ERROR ExecutionUtilService: Execution failed: 46: No matched nodes: NodeSet{includes={tags=${option.Environment}+${option.Product}+${option.Role}, dominant=false, }}

Which is where I'm setting the filtered nodes.

Please let me know if I can supply you with anything else, I'd love to get this working so I don't have to have single parameter jobs in Rundeck to work with this.

Thanks!

harlanbarnes commented 8 years ago

Hi there and thanks for using the gem.

Sorry, but this may be a dumb question ... but is the example you are using above EXACTLY what you are typing in?

If so, the problem is the brackets. Try it this way:

rundeck run --project ExampleProject --job manage-applications --options Environment=staging,Product=product1,Role=role1 --report all

The brackets are just in the help and such to say "these are optional".

Jinkxed commented 8 years ago

I tried just about every variation I could come up with.

rundeck run --project ExampleProject --job application-status --options Environment=staging,Product=product1,Role=role1 --report all
Job options were not valid: Option [Environment, staging,Product, [production, qa, staging]] value: {1} was not in the allowed values: {2}Option 'Product' is required.Option 'Role' is required.

Also the output of the logs only shows the execution of the job, it doesn't show the actual output from rundeck.

Example:

Execution 56 is running. Average job duration is 1.814 seconds.

Doesn't show the log output as shown in rundeck after.

I have a feeling both of these issues are related?

Thanks for looking into it!

Jinkxed commented 8 years ago

Oh also I did notice slack likes to convert -- into a single double dash. Maybe this has something to do with it?

Nevermind tried copy and pasting into a ide to remove the single double dash. Didn't make a difference.

harlanbarnes commented 8 years ago

I would bet, almost certainly, that the conversion of the double dash has something to do with it.

I also noticed in that last example that there's a space in the --outputs value ... that will DEFINITELY screw things up.

As some background, I'm using the keywords extension in this to get those values. While options looks like a list, it's actually just string that I then parse and submit to Rundeck as params. Thus, it will HAVE to be --options Something=With,No=Spaces.

Let me know if taking the space out of the one above (and convince Slack to keep the double-dash) has an impact.

Jinkxed commented 8 years ago

Tried both still does the same thing. :(

Jinkxed commented 8 years ago

I updated the example above to be with no spaces and the output.

Jinkxed commented 8 years ago

So figured this out.

Looks like it has to be bar separated

rundeck run --project ExampleProject --job application-status --options Environment=staging|Product=product1|Role=role1 --report all

Reason is this I think?: https://github.com/harlanbarnes/lita-rundeck/blob/master/lib/lita/handlers/rundeck.rb#L266

harlanbarnes commented 8 years ago

Okay, so it looks like it is not splitting the first value in the option key/value pair on the comma.

And now that I look at it, it's a bug. The delimiter in the code is a pipe, not a comma ... yet all the help and the docs say comma. And of course, all tests are "single option" (and that was only how I used it up until this point.) Brilliant.

Thus, the short term workaround is to change to this:

--options Environment=staging|Product=product1|Role=role1

and I'll try to patch and release today.

Sorry about all that.

Jinkxed commented 8 years ago

bar separated works fine for me if you want to leave it this way. Just would need to update docs?

Thanks for the help!

harlanbarnes commented 8 years ago

Yeah, you found it too! Again, sorry about that.

I'll just add in comma-delimited too. It A) shouldn't be that hard to do B) is more flexible and C) I need to update the tests for multi-options anyway.

Thanks for finding this!

Jinkxed commented 8 years ago

No problem at all, this is an awesome gem and I have lots of use cases for it. So very much appreciate you writing it!

Jinkxed commented 8 years ago

Moving to new feature!

harlanbarnes commented 8 years ago

Right. I'm almost positive that's because the "alias" feature only aliases the project+job. Spin up a new ticket for this and I'll figure out how to alias the options as well.