Fix validation error on nil for optional slice field (runner.spec.env)
I had observed athe exact issue seen for the 4th option described in https://github.com/elastic/cloud-on-k8s/issues/1822, which resulted in actions-runner-controller is unable to create nor update runners. This fixes that. I've also updated README to introduce RunnerDeployment and manually tested it to work after the fix. --- `actions-runner-controller` has been failing while creating and updating runners: ``` 2020-03-05T11:05:16.610+0900 ERROR controllers.Runner Failed to update runner {"runner": "default/example-runner", "error": "Runner.actions.summerwind.dev \"example-runner\" is invalid: []: Invalid value: map[string]interface {}{\"apiVersion\":\"actions.summerwind.dev/v1alpha1\", \"kind\":\"Runner\", \"metadata\":map[string]interface {}{\"creationTimestamp\":\"2020-03-05T02:05:16Z\", \"finalizers\":[]interface {}{\"runner.actions.summerwind.dev\"}, \"generation\":2, \"name\":\"example-runner\", \"namespace\":\"default\", \"resourceVersion\":\"911496\", \"selfLink\":\"/apis/actions.summerwind.dev/v1alpha1/namespaces/default/runners/example-runner\", \"uid\":\"48b62d07-ff2c-42d6-878c-d3f951202209\"}, \"spec\":map[string]interface {}{\"env\":interface {}(nil), \"image\":\"\", \"repository\":\"mumoshu/actions-runner-controller-ci\"}}: validation failure list:\nspec.env in body must be of type array: \"null\""} github.com/go-logr/zapr.(*zapLogger).Error /Users/c-ykuoka/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128 github.com/summerwind/actions-runner-controller/controllers.(*RunnerReconciler).Reconcile /Users/c-ykuoka/p/actions-runner-controller/controllers/runner_controller.go:88 ``` This seems like the exact issue seen in the 4th option in https://github.com/elastic/cloud-on-k8s/issues/1822 I also observed the same issue is failing while the runnerset controller is trying to create/update runners: ``` Also while creating runner in the runnerset controller: 2020-03-05T11:15:01.223+0900 ERROR controller-runtime.controller Reconciler error {"controller": "runnerset", "request": "default/example-runnerset", "error": "Runner.actions.summerwind.dev \"example-runnersetgp56m\" is invalid: []: Invalid value: map[string]interface {}{\"apiVersion\":\"actions.summerwind.dev/v1alpha1\", \"kind\":\"Runner\", \"metadata\":map[string]interface {}{\"creationTimestamp\":\"2020-03-05T02:15:01Z\", \"generateName\":\"example-runnerset\", \"generation\":1, \"name\":\"example-runnersetgp56m\", \"namespace\":\"default\", \"ownerReferences\":[]interface {}{map[string]interface {}{\"apiVersion\":\"actions.summerwind.dev/v1alpha1\", \"blockOwnerDeletion\":true, \"controller\":true, \"kind\":\"RunnerSet\", \"name\":\"example-runnerset\", \"uid\":\"e26f7d01-3168-496d-931b-8e6f97b776ea\"}}, \"uid\":\"4ee490f5-9a8c-4f30-86f9-61dea799b972\"}, \"spec\":map[string]interface {}{\"env\":interface {}(nil), \"image\":\"\", \"repository\":\"mumoshu/actions-runner-controller-ci\"}}: validation failure list:\nspec.env in body must be of type array: \"null\""} github.com/go-logr/zapr.(*zapLogger).Error ``` and while the runnerdeployment controller is trying to create/update runners. I've fixed it so that the new `RunnerDeployment` example added to README just works.
This commit is contained in:
parent
4b6806fda3
commit
d12eca268d
45
README.md
45
README.md
|
|
@ -24,7 +24,14 @@ $ kubectl create secret generic controller-manager --from-literal=github_token=$
|
|||
|
||||
## Usage
|
||||
|
||||
To launch Self-hosted runner, you need to create a manifest file includes *Runner* resource as follows. This example launches a self-hosted runner with name *example-runner* for the *summerwind/actions-runner-controller* repository.
|
||||
There's generally two ways to use this controller:
|
||||
|
||||
- Manage runners one by one with `Runner`
|
||||
- Manage a set of runners with `RunnerDeployment`
|
||||
|
||||
### Runners
|
||||
|
||||
To launch a single Self-hosted runner, you need to create a manifest file includes *Runner* resource as follows. This example launches a self-hosted runner with name *example-runner* for the *summerwind/actions-runner-controller* repository.
|
||||
|
||||
```
|
||||
# runner.yaml
|
||||
|
|
@ -64,3 +71,39 @@ The runner you created has been registerd to your repository.
|
|||
<img width="756" alt="Actions tab in your repository settings" src="https://user-images.githubusercontent.com/230145/73618667-8cbf9700-466c-11ea-80b6-c67e6d3f70e7.png">
|
||||
|
||||
Now your can use your self-hosted runner. See the [official documentation](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-self-hosted-runners-in-a-workflow) on how to run a job with it.
|
||||
|
||||
### RunnerDeployments
|
||||
|
||||
There's also `RunnerSet` and `RunnerDeployment` that corresponds to `ReplicaSet` and `Deployment` but for `Runner`.
|
||||
|
||||
You usually need only `RunnerDeployment` rather than `RunnerSet` as the former is for managing the latter.
|
||||
|
||||
```yaml
|
||||
# runnerdeployment.yaml
|
||||
apiVersion: actions.summerwind.dev/v1alpha1
|
||||
kind: RunnerDeployment
|
||||
metadata:
|
||||
name: example-runnerdeploy
|
||||
spec:
|
||||
replicas: 2
|
||||
template:
|
||||
spec:
|
||||
repository: mumoshu/actions-runner-controller-ci
|
||||
```
|
||||
|
||||
Apply the manifest file to your cluster:
|
||||
|
||||
```
|
||||
$ kubectl apply -f runner.yaml
|
||||
runnerdeployment.actions.summerwind.dev/example-runnerdeploy created
|
||||
```
|
||||
|
||||
You can see that 2 runners has been created as specified by `replicas: 2`:
|
||||
|
||||
```
|
||||
$ kubectl get runners
|
||||
NAME REPOSITORY STATUS
|
||||
NAME REPOSITORY STATUS
|
||||
example-runnerdeploy2475h595fr mumoshu/actions-runner-controller-ci Running
|
||||
example-runnerdeploy2475ht2qbr mumoshu/actions-runner-controller-ci Running
|
||||
```
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type RunnerSpec struct {
|
|||
Image string `json:"image"`
|
||||
|
||||
// +optional
|
||||
Env []corev1.EnvVar `json:"env"`
|
||||
Env []corev1.EnvVar `json:"env,omitempty"`
|
||||
}
|
||||
|
||||
// RunnerStatus defines the observed state of Runner
|
||||
|
|
|
|||
Loading…
Reference in New Issue