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

[Proposal] Support changing labels of Actions runner without re-registration #24540

Closed
wolfogre opened this issue May 5, 2023 · 1 comment · Fixed by #24806
Closed

[Proposal] Support changing labels of Actions runner without re-registration #24540

wolfogre opened this issue May 5, 2023 · 1 comment · Fixed by #24806
Assignees
Labels
topic/gitea-actions related to the actions of Gitea type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@wolfogre
Copy link
Member

wolfogre commented May 5, 2023

Background

Act runner will ask for labels when you register it to a Gitea instance. For example, one of the default labels is ubuntu-latest:docker://node:16-bullseye . It could be split into two parts.:

  • ubuntu-latest: This means it can run jobs with runs-on: ubuntu-latest
  • docker://node:16-bullseye: This means that the jobs will run in Docker containers with the specified image.

The runner will report ubuntu-latest to the Gitea instance, so the instance will know what kind of jobs can be assigned to this runner. However, the instance doesn't know the second part of the label because Gitea doesn't care how a runner runs jobs.

For some reason, it was designed to allow modifying labels on the Gitea side, in a special way:

  • Gitea cannot modify the labels reported by runners, which are called "Agent Labels".
  • Gitea can append more labels to runners, which are called "Custom Labels".

Untitled

So it will be convenient for users when they have a job with runs-on: centos, but there are no runners with the label. They can add centos as a custom label to let the runner pick up the jobs.

Unfortunately, when the runner receives the job, it doesn't understand how to run it. To avoid failure, the act runner will use the default image to run jobs with unrecognized labels. This may surprise users.

IMO, the point is that we shouldn't let Gitea define runners. It should be the runners who decide what kind of jobs they can run, not the Gitea instance. However, we also need to provide an elegant way to modify labels on the runner side, instead of re-registration.

Solution

Forbid modifying runner labels on the Gitea side

  1. Combine “agent labels” and “custom labels” to “labels”. Drop “custom labels” and use “agent labels” only.
  2. Users cannot modify the labels on settings pages of Gitea.

Provide a new RPC method for runners to declare their labels

  1. A new method like Declare(or a better name).
  2. Act runner will call Declare to pass its current labels to Gitea once it has started.
  3. Gitea will update the labels of the runner in database.

Support specifying labels in the config file of the runner

  1. Users can specify labels in the config file; it's optional. An empty value means "none" instead of "empty”.
  2. When registering a runner:
    1. Ignore the step/flag for labels if a config file with labels has been specified.
    2. Otherwise, ask for labels.
  3. When running a runner:
    1. Overwrite the labels to state file (.runner) if a config file with labels has been specified, and declare with new labels to Gitea.
    2. Otherwise, use the labels stored in the state file.

Benefits

  1. Provide convenience. Users can add/remove/change the labels of a runner by simply updating the config file and restarting the runner.
  2. Reduce confusion. The only way to the labels of a runner is modifying the config file.
  3. Clear boundaries. Users cannot modify the labels if they cannot touch the runner, even if they are the admin of the Gitea instance.
@wolfogre wolfogre added type/proposal The new feature has not been accepted yet but needs to be discussed first. type/feature Completely new functionality. Can only be merged if feature freeze is not active. topic/gitea-actions related to the actions of Gitea and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels May 5, 2023
@sillyguodong

This comment was marked as resolved.

@sillyguodong sillyguodong self-assigned this May 16, 2023
lunny pushed a commit that referenced this issue Jun 13, 2023
…4806)

close #24540

related:
- Protocol: https://gitea.com/gitea/actions-proto-def/pulls/9
- Runner side: https://gitea.com/gitea/act_runner/pulls/201

changes:
- Add column of `labels` to table `action_runner`, and combine the value
of `agent_labels` and `custom_labels` column to `labels` column.
- Store `labels` when registering `act_runner`.
- Update `labels` when `act_runner` starting and calling `Declare`.
- Users cannot modify the `custom labels` in edit page any more.

other changes:
- Store `version` when registering `act_runner`.
- If runner is latest version, parse version from `Declare`. But older
version runner still parse version from request header.
NexZhu pushed a commit to daotl/gitea_act_runner that referenced this issue Jun 20, 2023
Implement proposal: go-gitea/gitea#24540

Related:
- Protocol: https://gitea.com/gitea/actions-proto-def/pulls/9
- Gitea side: go-gitea/gitea#24806

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/201
Reviewed-by: Jason Song <i@wolfogre.com>
Co-authored-by: sillyguodong <gedong_1994@163.com>
Co-committed-by: sillyguodong <gedong_1994@163.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic/gitea-actions related to the actions of Gitea type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants