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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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