Skip to content
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

Module update removes registered runner but does not create a new runner #1074

Closed
jonpas opened this issue Jan 26, 2024 · 5 comments · Fixed by #1115
Closed

Module update removes registered runner but does not create a new runner #1074

jonpas opened this issue Jan 26, 2024 · 5 comments · Fixed by #1115

Comments

@jonpas
Copy link

jonpas commented Jan 26, 2024

Describe the bug

Updating GitLab Runner version by re-deploying a Terraform project using this module with the new "Next GitLab Runner Token Architecture", as the new EC2 instance is created, GitLab Runner is removed from the GitLab instance, but a new one is not registered.

Before "Next GitLab Runner Token Architecture", the GitLab Runner was simply updated.

To Reproduce

Steps to reproduce the behavior:

  1. Update runner_gitlab = { runner_version = "16.7.0" } to a newer version (eg. 16.8.0)
  2. terraform plan + terraform apply
  3. Observe new master runner instance being created on EC2 and old one destroyed
  4. Observe runner being deleted from GitLab instance
  5. Wait and observe no new runner being created on the GitLab instance
  6. Have no runner

Expected behavior

A GitLab Runner to either be recreated or re-use the existing runner registration.

Additional context

Upgrade to "Next GitLab Runner Token Architecture" was performed with a completely fresh setup, no old SSM parameters remained. We deploy using and GitLab's Terraform state handling through GitLab's CI (running on a instance completely separated from any auto-deployed ones from this module).

We have to fully destroy the runner and recreate it to get the runner re-registered. EC2 system logs show nothing different from the past, but I can supply a log if no other ideas are available.

@kayman-mk
Copy link
Collaborator

kayman-mk commented Feb 15, 2024

Having old SSM parameters with old tokens is usually the problem, yes. But this shouldn't be the case here.

What you should observe in the logs is, that a new token is fetched from GitLab and stored as SSM parameter. The Runner should be shown in GitLab.

Just checked my configuration

  runner_gitlab = {
    # this is the token used for the API call allowing the Runner to register
    access_token_secure_parameter_store_name = var.gitlab_group_access_token_ssm_name
  }

  runner_gitlab_registration_config = {
   # needed for the new registration process
   type              = "group" # instance or group or project
    group_id          = "1234"
  }

The Runner creates a SSM parameter holding the glrt- token returned in the registration process. Is the SSM parameter present and holding the token?

@jonpas
Copy link
Author

jonpas commented Feb 19, 2024

There are multiple SSM parameter tokens created:

  • *-access-token holding the glpat-* token (GitLab Access Token for registering Runners)
  • *-<name>-runner-token holding the glrt- token (no description)
  • *-<name>-sentry-dsn holding null (no description)

My configuration is similar except it's an instance runner.

  runner_gitlab = {
    runner_version                           = "16.8.0"
    url                                      = "https://gitlab...."
    access_token_secure_parameter_store_name = "gitlab-runner-access-token"
  }

  runner_gitlab_registration_config = {
    type              = "instance"
    tag_list          = "tag1,tag2"
    description       = "name"
    locked_to_project = "false"
    run_untagged      = "true"
    maximum_timeout   = "3600"
  }

Anyways, after updating to 7.3.1, it has re-registered itself correctly first try. I wonder if #1058 fixed the issue in this case.

@jonpas jonpas closed this as completed Feb 19, 2024
@jonpas
Copy link
Author

jonpas commented Mar 26, 2024

This has happened again with simple update of VPC module to 5.7.0 and GitLab Runner version to 16.10.0, no update to this project.

SSM Parameter Store shows all tokens, with *-<name>-runner-token being updated at the time of update.

EC2 System Log shows nothing about fetching a new token though.


Update to 7.4.0 also didn't have any issues, so maybe this is only happening when not updating this project?

@jonpas jonpas reopened this Mar 26, 2024
@lpsm-nuageit
Copy link

is there any way of setting this up without having to register a runner? i already have my runner created in the visual interface

kayman-mk added a commit that referenced this issue Apr 24, 2024
## Description

GitLab announced then [Next GitLab Runner Token
Architecture](https://docs.gitlab.com/ee/architecture/blueprints/runner_tokens/index.html#proposal).
Runners have to be registered manually.

This PR adds a new import parameter
`runner_gitlab.preregistered_runner_token_ssm_parameter_name` holding
the name of a SSM parameter (type: `SecuredString`). This parameter
contains the GitLab Runner token obtained from GitLab. All other
registration methods will still work, but have been marked as deprecated
and will be removed with
[v8.0.0](https://github.com/cattle-ops/terraform-aws-gitlab-runner/milestone/4)
end of the year.

This also solves the problems with Runners removed from GitLab at
shutdown, resulting in new Runners not able to start.

Closes #1074 and #1109 

## Verification

- [x] deployed the module using the new registration version. Runner is
online.
- [x] deployed the module using the old authentication schema. Runner is
online.
@kayman-mk
Copy link
Collaborator

Yes, that is possible. We added a variable in the last release.

There is also a PR ongoing to allow zero downtime updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants