rundeck / terraform-provider-rundeck

Terraform Rundeck provider
https://www.terraform.io/docs/providers/rundeck/
Mozilla Public License 2.0
52 stars 61 forks source link

Bug: Project update and create operations fail in Rundeck 4.16.0 #93

Open rich-boyce opened 1 year ago

rich-boyce commented 1 year ago

Starting with some release between 4.13.0 and 4.16.0, project update and create operations using terraform-provider-rundeck fail. The bug seems to be with the configuration step, since a create operation will result in a project being created but not configured.

Terraform reports this error:

│ Error: rundeck.BaseClient#ProjectConfigUpdate: Failure responding to request: StatusCode=500 -- Original Error: autorest/azure: error response cannot be parsed: "{\"error\":\"A server error occurred\"}<html>\n<head>\n    <title>\n\nRundeck - Error</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n    <meta name=\"layout\" content=\"base\"/>\n</head>\n\n<body>\n\n\n<div class=\"content\">\n<div id=\"layoutBody\">\n<div class=\"container-fluid\">\n  <div class=\"row\">\n    <div class=\"col-sm-12\">\n      <div class=\"card \">\n        <div class=\"card-header\">\n          <h2 class=\"card-title \">An Error Occurred</h2>\n        </div>\n        <div class=\"card-content text-da" error: json: cannot unmarshal string into Go struct field RequestError.error of type azure.serviceError2

Rundeck reports errors like this:

[2023-09-20T14:32:21,631] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [PUT] /api/38/project/test/config
Cannot invoke method leftShift() on null object. Stacktrace follows:
java.lang.NullPointerException: Cannot invoke method leftShift() on null object

Rundeck reports warnings like this:

[2023-09-20T14:33:21,765] WARN  config.NavigableMap - Accessing config key '[errorpage]' through dot notation is deprecated, and it will be removed in a future release. Use 'config.getProperty(key, targetClass)' instead.
[2023-09-20T14:33:21,765] WARN  config.NavigableMap - Accessing config key '[errorpage, hidestacktrace]' through dot notation is deprecated, and it will be removed in a future release. Use 'config.getProperty(key, targetClass)' instead.

Rolling the Rundeck container back to 4.13.0 allows the changes to be applied successfully.

fdevans commented 1 year ago

I believe there were some bugs fixed in the 4.17 release that might address this. Can you try that version please?

rich-boyce commented 1 year ago

@fdevans Thanks for the reply. I've tried 4.17 and it doesn't address the issue I was seeing.

After a lot more investigation it became clear that the root cause of the problem I describe was as follows: A project setting, for a job execution plugin, had always been omitted from the configuration applied by terraform. That setting has a default in the plugin, which previous versions of Rundeck would use without error. Starting with the 4.15 release, however, Rundeck started throwing the errors given in my post above, when project configuration was set by terraform.

The solution I've applied was to modify the terraform provider to include the default for that project setting in the settings it applies, unless overridden.

Feel free to close this, however I would like to point out that the errors thrown by Rundeck in this situation could have been a lot more helpful.

fdevans commented 1 year ago

What setting needed a better default value? I can look into whether it's a product side or provider side issue.

rich-boyce commented 1 year ago

That wasn't the issue here - the default value was correct, the failure was that Rundeck was rejecting (with status 500) any attempt at setting project configuration via the API that did not include an explicit value for that key. It's worth noting that the UI shows the default value when creating a new project, so that information was being propagated through to Rundeck successfully; the error was just when attempting to configure a project via the API.

The actual job execution plugin in question is one we've put together ourselves.

Zwordi commented 6 months ago

Hi,

I’m facing quite the same issue. Could you give an example of what you did added on your provider ? 

Thanks,

fdevans commented 1 month ago

@rich-boyce Is there still an issue to be figured out here?

rich-boyce commented 1 week ago

@fdevans Apologies for the late reply - no, this seems to have been resolved one way or another.