[Controller] Add adapter hash suffix to Migrations job name
Summary
Adds the CustomResourceAdapter's hash as a suffix to the Migrations Job name (the first 3 characters of the hash).
I couldn't use a random hash because that value would be different every time the controller did a reconcile loop, and would have resulted in a brand new Migrations job deployed upon every loop.
Instead, we use the Adapter hash because that value will change every time the CR values change, which is ultimately what we want anyway.
Note that this is expected to be a temporary workaround. The more complete fix is being discussed in gitlab-org/charts/gitlab#734 (closed).
Closes #216 (closed)
Testing
First, deploy the controller and a CR. Example CR:
apiVersion: apps.gitlab.com/v1beta1
kind: GitLab
metadata:
name: gitlab
spec:
chart:
version: "5.1.1"
values:
certmanager:
install: false
global:
hosts:
domain: yourdomain.com
configureCertmanager: false
Wait for all pods to be up and running.
Next, update the CR with a new value. Example:
apiVersion: apps.gitlab.com/v1beta1
kind: GitLab
metadata:
name: gitlab
spec:
chart:
version: "5.1.1"
values:
certmanager:
install: false
global:
hosts:
domain: yourdomain.com
hostSuffix: foo # added this configuration
configureCertmanager: false
Apply the CR and observe that a second Migrations job is created, with a different suffix. (In the past, this second job would not have been created because it would have had the same name as the previous one.)
$ kubectl get jobs -n gitlab-system -lapp=migrations
NAME COMPLETIONS DURATION AGE
gitlab-migrations-1-836 1/1 67s 11m
gitlab-migrations-1-a75 1/1 84s 8m7s