-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Allow None value maximum_timeout for gitlab_runner #11174
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
base: main
Are you sure you want to change the base?
Conversation
russoz
left a comment
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.
Hi @colin93 thanks for your contribution.
Some initial comments.
|
Hi @russoz , have updated changelog with suggestion. As for the type there seems to be strict type matching, I can do some further testing to see if there's a better method to allow null for just the maximum_timeout field.
|
|
The standard way of saying "no timeout" for timeout parameters that accept a number is to provide 0 or a negative number. The module can transform that into whatever the API accepts. Care must be taken for idempotency, since |
|
Have changed to instead convert 0 to None. The API itself only accepts positive values greater than 600 and None https://gitlab.com/gitlab-org/gitlab/-/blob/766d796437571129ded2bdcbdce3421547e776c6/app/models/ci/runner.rb#L272 |
felixfontein
left a comment
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 the PR looks good now. I have a small suggestion for the docs though:
plugins/modules/gitlab_runner.py
Outdated
| maximum_timeout: | ||
| description: | ||
| - The maximum time that a runner has to complete a specific job. | ||
| - The maximum time that a runner has to complete a specific job. Use V(0) to disable the timeout. |
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'd mention when this got added:
| - The maximum time that a runner has to complete a specific job. Use V(0) to disable the timeout. | |
| - The maximum time that a runner has to complete a specific job. | |
| - Use V(0) to disable the timeout. This is available since community.general 12.1.0. |
|
|
||
| for arg_key, arg_value in arguments.items(): | ||
| if arg_value is not None: | ||
| if arg_value is not None or arg_key == "maximum_timeout": |
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.
After changing the disable value to 0, I think the change in this line has become redundant, but I have not checked it thoroughly.
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.
Since the value of maximum_timeout is already converted to None at this stage without this check a value of 0 would end up being skipped for updates.
|
And I am curious now, what does the module do when that parameter is indeed |
|
Ansible won't let you pass |

SUMMARY
Allow maximum_timeout for gitlab_runner to be set to None.
ISSUE TYPE
COMPONENT NAME
gitlab_runner
ADDITIONAL INFORMATION
Currently trying to do this with null results in the below error.
fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument 'maximum_timeout' is of type NoneType and we were unable to convert to int: \"None\" cannot be converted to an int"}Values less than 600 are also rejected by the API, this PR converts 0 to None to allow for disabling timeout at the runner level as covered in example 2 of https://docs.gitlab.com/ci/runners/configure_runners/#how-maximum-job-timeout-works