Skip to content

Conversation

@colin93
Copy link

@colin93 colin93 commented Nov 18, 2025

SUMMARY

Allow maximum_timeout for gitlab_runner to be set to None.

ISSUE TYPE
  • Feature Pull Request
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

- name: Create an instance-level runner
  community.general.gitlab_runner:
    api_url: https://gitlab.example.com/
    api_token: "{{ access_token }}"
    description: Docker Machine t1
    state: present
    active: true
    tag_list: ['docker']
    run_untagged: false
    locked: false
    maximum_timeout: 0
  register: runner # Register module output to run C(gitlab-runner register) command in another task

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added WIP Work in progress feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type) labels Nov 18, 2025
@colin93 colin93 marked this pull request as ready for review November 18, 2025 14:38
@ansibullbot ansibullbot removed the WIP Work in progress label Nov 18, 2025
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-12 Automatically create a backport for the stable-12 branch labels Nov 18, 2025
Copy link
Collaborator

@russoz russoz left a 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.

@colin93
Copy link
Author

colin93 commented Nov 18, 2025

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.
Otherwise as in below screenshot, without the changes (1st run) the module fails with type mismatch when using null vs with the changes (2nd run) it passes and correctly creates the runner.

ansible-playbook-error

@felixfontein
Copy link
Collaborator

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 None in the module code usually means "don't change this parameter".

@colin93
Copy link
Author

colin93 commented Nov 19, 2025

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

@colin93 colin93 changed the title Allow null maximum_timeout for gitlab_runner Allow None value maximum_timeout for gitlab_runner Nov 21, 2025
Copy link
Collaborator

@felixfontein felixfontein left a 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:

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.
Copy link
Collaborator

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:

Suggested change
- 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":
Copy link
Collaborator

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.

Copy link
Author

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.

@russoz
Copy link
Collaborator

russoz commented Nov 24, 2025

And I am curious now, what does the module do when that parameter is indeed null (None)?

@felixfontein
Copy link
Collaborator

Ansible won't let you pass null here, since the parameter has a default value and is of type int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-12 Automatically create a backport for the stable-12 branch check-before-release PR will be looked at again shortly before release and merged if possible. feature This issue/PR relates to a feature request module module new_contributor Help guide this first time contributor plugins plugin (any type)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants