Chart naming validation on AutoscalingRunnerSet install (#2347)
Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Co-authored-by: Bassem Dghaidi <Link-@github.com>
This commit is contained in:
parent
e8d8c6f357
commit
be47190d4c
|
|
@ -1,6 +1,12 @@
|
|||
apiVersion: actions.github.com/v1alpha1
|
||||
kind: AutoscalingRunnerSet
|
||||
metadata:
|
||||
{{- if or (not .Release.Name) (gt (len .Release.Name) 45) }}
|
||||
{{ fail "Name must have up to 45 characters" }}
|
||||
{{- end }}
|
||||
{{- if gt (len .Release.Namespace) 63 }}
|
||||
{{ fail "Namespace must have up to 63 characters" }}
|
||||
{{- end }}
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
|
|
@ -82,7 +88,7 @@ spec:
|
|||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
containers:
|
||||
containers:
|
||||
{{- if eq .Values.containerMode.type "dind" }}
|
||||
- name: runner
|
||||
{{- include "gha-runner-scale-set.dind-runner-container" . | nindent 8 }}
|
||||
|
|
@ -97,7 +103,7 @@ spec:
|
|||
{{ .Values.template.spec.containers | toYaml | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.template.spec.volumes (eq .Values.containerMode.type "dind") (eq .Values.containerMode.type "kubernetes") }}
|
||||
volumes:
|
||||
volumes:
|
||||
{{- if eq .Values.containerMode.type "dind" }}
|
||||
{{- include "gha-runner-scale-set.dind-volume" . | nindent 6 }}
|
||||
{{- include "gha-runner-scale-set.dind-work-volume" . | nindent 6 }}
|
||||
|
|
@ -105,4 +111,4 @@ spec:
|
|||
{{- include "gha-runner-scale-set.kubernetes-mode-work-volume" . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- include "gha-runner-scale-set.non-work-volumes" . | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
|
|
|||
|
|
@ -780,3 +780,45 @@ func TestTemplateRenderedWithProxy(t *testing.T) {
|
|||
assert.Contains(t, ars.Spec.Proxy.NoProxy, "example.com")
|
||||
assert.Contains(t, ars.Spec.Proxy.NoProxy, "example.org")
|
||||
}
|
||||
|
||||
func TestTemplateNamingConstraints(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Path to the helm chart we will test
|
||||
helmChartPath, err := filepath.Abs("../../gha-runner-scale-set")
|
||||
require.NoError(t, err)
|
||||
|
||||
setValues := map[string]string{
|
||||
"githubConfigUrl": "https://github.com/actions",
|
||||
"githubConfigSecret": "",
|
||||
}
|
||||
|
||||
tt := map[string]struct {
|
||||
releaseName string
|
||||
namespaceName string
|
||||
expectedError string
|
||||
}{
|
||||
"Name too long": {
|
||||
releaseName: strings.Repeat("a", 46),
|
||||
namespaceName: "test-" + strings.ToLower(random.UniqueId()),
|
||||
expectedError: "Name must have up to 45 characters",
|
||||
},
|
||||
"Namespace too long": {
|
||||
releaseName: "test-" + strings.ToLower(random.UniqueId()),
|
||||
namespaceName: strings.Repeat("a", 64),
|
||||
expectedError: "Namespace must have up to 63 characters",
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range tt {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
options := &helm.Options{
|
||||
SetValues: setValues,
|
||||
KubectlOptions: k8s.NewKubectlOptions("", "", tc.namespaceName),
|
||||
}
|
||||
_, err = helm.RenderTemplateE(t, options, helmChartPath, tc.releaseName, []string{"templates/autoscalingrunnerset.yaml"})
|
||||
require.Error(t, err)
|
||||
assert.ErrorContains(t, err, tc.expectedError)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ https://user-images.githubusercontent.com/568794/212668313-8946ddc5-60c1-461f-a7
|
|||
|
||||
```bash
|
||||
# Using a Personal Access Token (PAT)
|
||||
INSTALLATION_NAME="arc-runner-set"
|
||||
INSTALLATION_NAME="arc-runner-set"
|
||||
NAMESPACE="arc-runners"
|
||||
GITHUB_CONFIG_URL="https://github.com/<your_enterprise/org/repo>"
|
||||
GITHUB_PAT="<PAT>"
|
||||
|
|
@ -64,9 +64,9 @@ https://user-images.githubusercontent.com/568794/212668313-8946ddc5-60c1-461f-a7
|
|||
|
||||
```bash
|
||||
# Using a GitHub App
|
||||
INSTALLATION_NAME="arc-runner-set"
|
||||
INSTALLATION_NAME="arc-runner-set"
|
||||
NAMESPACE="arc-runners"
|
||||
GITHUB_CONFIG_URL="https://github.com/<your_enterprise/org/repo>"
|
||||
GITHUB_CONFIG_URL="https://github.com/<your_enterprise/org/repo>"
|
||||
GITHUB_APP_ID="<GITHUB_APP_ID>"
|
||||
GITHUB_APP_INSTALLATION_ID="<GITHUB_APP_INSTALLATION_ID>"
|
||||
GITHUB_APP_PRIVATE_KEY="<GITHUB_APP_PRIVATE_KEY>"
|
||||
|
|
@ -86,8 +86,8 @@ https://user-images.githubusercontent.com/568794/212668313-8946ddc5-60c1-461f-a7
|
|||
$ helm list -n "${NAMESPACE}"
|
||||
|
||||
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
|
||||
arc arc-systems 1 2023-01-18 10:03:36.610534934 +0000 UTC deployed gha-runner-scale-set-controller-0.2.0 preview
|
||||
arc-runner-set arc-systems 1 2023-01-18 10:20:14.795285645 +0000 UTC deployed gha-runner-scale-set-0.2.0 0.2.0
|
||||
arc arc-systems 1 2023-01-18 10:03:36.610534934 +0000 UTC deployed gha-runner-scale-set-controller-0.2.0 preview
|
||||
arc-runner-set arc-systems 1 2023-01-18 10:20:14.795285645 +0000 UTC deployed gha-runner-scale-set-0.2.0 0.2.0
|
||||
```
|
||||
|
||||
```bash
|
||||
|
|
@ -118,10 +118,10 @@ https://user-images.githubusercontent.com/568794/212668313-8946ddc5-60c1-461f-a7
|
|||
```bash
|
||||
$ kubectl get pods -A
|
||||
|
||||
NAMESPACE NAME READY STATUS RESTARTS AGE
|
||||
NAMESPACE NAME READY STATUS RESTARTS AGE
|
||||
arc-systems arc-gha-runner-scale-set-controller-8c74b6f95-gr7zr 1/1 Running 0 27m
|
||||
arc-systems arc-runner-set-6cd58d58-listener 1/1 Running 0 7m52s
|
||||
arc-runners arc-runner-set-rmrgw-runner-p9p5n 1/1 Running 0 21s
|
||||
arc-systems arc-runner-set-6cd58d58-listener 1/1 Running 0 7m52s
|
||||
arc-runners arc-runner-set-rmrgw-runner-p9p5n 1/1 Running 0 21s
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
|
@ -138,6 +138,20 @@ $ kubectl logs -n "${NAMESPACE}" -l app.kubernetes.io/name=gha-runner-scale-set-
|
|||
kubectl logs -n "${NAMESPACE}" -l runner-scale-set-listener=arc-systems-arc-runner-set
|
||||
```
|
||||
|
||||
### Naming error: `Name must have up to characters`
|
||||
|
||||
We are using some of the resources generated names as labels for other resources. Resource names have a max length of `263 characters` while labels are limited to `63 characters`. Given this constraint, we have to limit the resource names to `63 characters`.
|
||||
|
||||
Since part of the resource name is defined by you, we have to impose a limit on the amount of characters you can use for the installation and namespace names.
|
||||
|
||||
If you see these errors, you have to use shorter installation or namespace names.
|
||||
|
||||
```bash
|
||||
Error: INSTALLATION FAILED: execution error at (gha-runner-scale-set/templates/autoscalingrunnerset.yaml:5:5): Name must have up to 45 characters
|
||||
|
||||
Error: INSTALLATION FAILED: execution error at (gha-runner-scale-set/templates/autoscalingrunnerset.yaml:8:5): Namespace must have up to 63 characters
|
||||
```
|
||||
|
||||
### If you installed the autoscaling runner set, but the listener pod is not created
|
||||
|
||||
Verify that the secret you provided is correct and that the `githubConfigUrl` you provided is accurate.
|
||||
|
|
|
|||
Loading…
Reference in New Issue