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

Add gitlab-runner-scaler #6499

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

fira42073
Copy link
Contributor

@fira42073 fira42073 commented Jan 25, 2025

Provide a description of what has been changed

Checklist

Fixes #5616

@fira42073 fira42073 requested a review from a team as a code owner January 25, 2025 21:23
@fira42073 fira42073 force-pushed the gitlab-runner-scaler branch 2 times, most recently from 1abaa5f to 7af19df Compare January 25, 2025 21:25
@fira42073 fira42073 force-pushed the gitlab-runner-scaler branch from 7af19df to b58aaae Compare January 25, 2025 21:42
Signed-off-by: Fira Curie <[email protected]>
@fira42073 fira42073 force-pushed the gitlab-runner-scaler branch from b58aaae to b650bc3 Compare January 25, 2025 22:02
meta := &gitlabRunnerMetadata{
ProjectID: "12345",
TargetPipelineQueueLength: 5,
TriggerIndex: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something quite small but, could we use TriggerIndex: 1 ? 0 is the default value so just using 1 we can also check that the TriggerIndex is correctly reflected in the metric name

@@ -0,0 +1,503 @@
//go:build e2e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the e2e test, it waits a PAT so I guess that we need to create an e2e account to run it. Does it have any special requirement? Does it make sense to use gitlab.com instead of spin up a dummy gitlab instance in the cluster during the e2e test? https://docs.gitlab.com/charts/installation/deployment.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually already tried doing that, and it's a bit too complicated
#5616 (comment)

I think it's best to create a gitlab.com account, since it would only require phone verification to run pipelines, and that's it. Repos will be cleaned up automatically as well as part of e2e tests.

Comment on lines +90 to +111
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.DeploymentName}}
namespace: {{.TestNamespace}}
labels:
app: gitlab-runner
spec:
replicas: 0
selector:
matchLabels:
app: gitlab-runner
template:
metadata:
labels:
app: gitlab-runner
spec:
terminationGracePeriodSeconds: 90
containers:
- name: gitlab-runner
image: busybox
command: ["/bin/sh", "-c", "trap 'echo SIGTERM received; exit 0' SIGTERM; while true; do sleep 30; done"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense creating a real runner using their runner image to check that the job is dequeued? https://hub.docker.com/r/gitlab/gitlab-runner/tags

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sat down and tried doing that this evening, but then realized that we actually already kind of had this discussion here.

Gitlab already does have a mechanism of autoscaling (creating runner per job)
image
don't worry about the token in the image, it's been rotated already.

So I think doesn't make sense to manage that using keda. Again, please correct me if I'm wrong, maybe I simply don't quite understand the usecase here.

Comment on lines 170 to 173
testSONotActivated(t, kc)

testSOScaleOut(t, kc, projectID)
testSOScaleIn(t, kc, projectID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the same name as the majority of the tests:

Suggested change
testSONotActivated(t, kc)
testSOScaleOut(t, kc, projectID)
testSOScaleIn(t, kc, projectID)
testActivation(t, kc)
testScaleOut(t, kc, projectID)
testScaleIn(t, kc, projectID)


metric := GenerateMetricInMili(metricName, float64(queueLen))

return []external_metrics.ExternalMetricValue{metric}, queueLen >= s.metadata.TargetPipelineQueueLength, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TargetPipelineQueueLength shouldn't be used here. It is used for the target, for the activation we need to include another parameter ActivationTargetPipelineQueueLength with default value 0 and use it with >

return []external_metrics.ExternalMetricValue{metric}, queueLen > s.metadata.ActivationTargetPipelineQueueLength, nil

gitlabAPIURL: {{.GitlabAPIURL}}
projectID: "{{.ProjectID}}"
targetPipelineQueueLength: "{{.TargetPipelineQueueLength}}"
labels: "e2eSOtester"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The activation parameter is left here for the activation test

Comment on lines 205 to 206

func testSONotActivated(t *testing.T, kc *kubernetes.Clientset) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the activation test, we have to add an item in the queue and check that the activation value blocks the scaling until the item count in the queue is higher

@@ -295,6 +295,22 @@ func setConfigValueURLParams(params Params, valFromConfig string, field reflect.
return nil
}

// setConfigValueURL is a function that sets the value of the url.URL field
func setConfigValueURL(valFromConfig string, field reflect.Value) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT @wozniakjan ?

@fira42073 fira42073 force-pushed the gitlab-runner-scaler branch from 9f9ad27 to a2ccae7 Compare March 4, 2025 22:03
@fira42073 fira42073 force-pushed the gitlab-runner-scaler branch from 3fc095e to f92b18c Compare March 4, 2025 22:26
@fira42073 fira42073 requested review from JorTurFer and zroubalik March 4, 2025 22:26
@zroubalik
Copy link
Member

zroubalik commented Mar 26, 2025

/run-e2e gitlab
Update: You can check the progress here

@zroubalik zroubalik mentioned this pull request Mar 26, 2025
37 tasks
@fira42073
Copy link
Contributor Author

We need gitlab PAT for this to work, have you had a chance to add it?

@zroubalik
Copy link
Member

We need gitlab PAT for this to work, have you had a chance to add it?

I see, nope. We need to work on that, adding this #6499 (comment) for reference, thanks for letting us know!

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 this pull request may close these issues.

GitLab Runner Scaler
3 participants