-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Add gitlab-runner-scaler #6499
Conversation
1abaa5f
to
7af19df
Compare
7af19df
to
b58aaae
Compare
Signed-off-by: Fira Curie <[email protected]>
b58aaae
to
b650bc3
Compare
meta := &gitlabRunnerMetadata{ | ||
ProjectID: "12345", | ||
TargetPipelineQueueLength: 5, | ||
TriggerIndex: 0, |
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.
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 |
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.
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
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 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.
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"] |
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.
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
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 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)
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.
testSONotActivated(t, kc) | ||
|
||
testSOScaleOut(t, kc, projectID) | ||
testSOScaleIn(t, kc, projectID) |
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.
Let's use the same name as the majority of the tests:
testSONotActivated(t, kc) | |
testSOScaleOut(t, kc, projectID) | |
testSOScaleIn(t, kc, projectID) | |
testActivation(t, kc) | |
testScaleOut(t, kc, projectID) | |
testScaleIn(t, kc, projectID) |
pkg/scalers/gitlab_runner_scaler.go
Outdated
|
||
metric := GenerateMetricInMili(metricName, float64(queueLen)) | ||
|
||
return []external_metrics.ExternalMetricValue{metric}, queueLen >= s.metadata.TargetPipelineQueueLength, nil |
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.
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" |
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.
The activation parameter is left here for the activation test
|
||
func testSONotActivated(t *testing.T, kc *kubernetes.Clientset) { |
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.
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 { |
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.
WDYT @wozniakjan ?
Signed-off-by: Fira Curie <[email protected]>
9f9ad27
to
a2ccae7
Compare
Signed-off-by: Fira Curie <[email protected]>
3fc095e
to
f92b18c
Compare
/run-e2e gitlab |
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! |
Provide a description of what has been changed
Checklist
Fixes #5616