-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the standalone mode and dev mode
This change replaces the legacy dev mode with the new standalone mode, since they both provides the same feature: fast development mode. The CRD will only be validated using OLM, as it is expected in production. Change-Id: Ia8b416b3ed762f488e6368e3416b2e9e4f8e23a4
- Loading branch information
1 parent
44f041c
commit 118622e
Showing
14 changed files
with
175 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 47 additions & 34 deletions
81
roles/health-check/check-sf-resource-ready/tasks/main.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,51 @@ | ||
--- | ||
- name: Wait for the custom resources to be reconciledBy {{ reconciledBy }} | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}' | ||
register: sf_ready | ||
until: | ||
- sf_ready.stdout != "" | ||
- '"reconciledBy" in (sf_ready.stdout | from_json)' | ||
- (sf_ready.stdout | from_json).reconciledBy == reconciledBy | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
when: | ||
- reconciledBy is defined | ||
- reconciledBy != "" | ||
- name: "Ensure CR Ready (olm)" | ||
when: mode == 'olm' | ||
block: | ||
- name: Wait for the custom resources to be reconciledBy {{ reconciledBy }} | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}' | ||
register: sf_ready | ||
until: | ||
- sf_ready.stdout != "" | ||
- '"reconciledBy" in (sf_ready.stdout | from_json)' | ||
- (sf_ready.stdout | from_json).reconciledBy == reconciledBy | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
when: | ||
- reconciledBy is defined | ||
- reconciledBy != "" | ||
|
||
# This task is there by safety. From my understanding the generation field is updated | ||
# by k8s right after any object change | ||
# https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
- name: Ensure 1 sec delay to let time for k8s to update the metadata.generation field | ||
command: sleep 1 | ||
# This task is there by safety. From my understanding the generation field is updated | ||
# by k8s right after any object change | ||
# https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata | ||
- name: Ensure 1 sec delay to let time for k8s to update the metadata.generation field | ||
command: sleep 1 | ||
|
||
- name: Get current resource generation | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.metadata.generation}' | ||
register: cr_generation | ||
until: cr_generation.stdout != "" | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
- name: Get current resource generation | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.metadata.generation}' | ||
register: cr_generation | ||
until: cr_generation.stdout != "" | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
|
||
- name: Wait for the custom resources to be ready | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}' | ||
register: sf_ready | ||
until: | ||
- sf_ready.stdout != "" | ||
- '"ready" in (sf_ready.stdout | from_json)' | ||
- '"observedGeneration" in (sf_ready.stdout | from_json)' | ||
- (sf_ready.stdout | from_json).observedGeneration == (cr_generation.stdout | int) | ||
- (sf_ready.stdout | from_json).ready == true | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
- name: Wait for the custom resources to be ready | ||
ansible.builtin.command: kubectl get sf my-sf -o=jsonpath='{.status}' | ||
register: sf_ready | ||
until: | ||
- sf_ready.stdout != "" | ||
- '"ready" in (sf_ready.stdout | from_json)' | ||
- '"observedGeneration" in (sf_ready.stdout | from_json)' | ||
- (sf_ready.stdout | from_json).observedGeneration == (cr_generation.stdout | int) | ||
- (sf_ready.stdout | from_json).ready == true | ||
retries: "{{ retries }}" | ||
delay: "{{ delay }}" | ||
|
||
- name: "Ensure CR Ready (standalone)" | ||
when: mode == 'standalone' | ||
block: | ||
- name: run the operator in standalone mode | ||
ansible.builtin.include_role: | ||
name: run-operator-standalone | ||
vars: | ||
cr_path: /tmp/current_cr.yaml | ||
glue: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
glue: true | ||
cr_path: config/samples/sf_v1_softwarefactory.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
--- | ||
- name: Ensure ~/zuul-output/logs | ||
ansible.builtin.file: | ||
path: ~/zuul-output/logs | ||
state: directory | ||
when: | ||
- glue | ||
|
||
# Empty the sf-operator.log output before the run | ||
- name: Ensure ~/zuul-output/logs | ||
ansible.builtin.file: | ||
path: ~/zuul-output/logs/sf-operator.log | ||
state: absent | ||
when: | ||
- glue | ||
|
||
- name: Run the operator in standalone mode | ||
ansible.builtin.shell: | | ||
go run ./main.go standalone --cr config/samples/sf_v1_softwarefactory.yaml --namespace sf | ||
set -o pipefail | ||
go run ./main.go standalone --cr {{ cr_path }} --namespace sf 2>&1 | tee -a ~/zuul-output/logs/sf-operator.log | ||
args: | ||
chdir: "{{ zuul.project.src_dir }}" | ||
|
||
- name: Copy current spec | ||
ansible.builtin.shell: "cp {{ cr_path }} /tmp/current_cr.yaml" | ||
args: | ||
chdir: "{{ zuul.project.src_dir }}" | ||
when: | ||
- glue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
--- | ||
- ansible.builtin.include_role: | ||
name: setup-variables | ||
|
||
- name: Iterate on preparation roles | ||
ansible.builtin.include_role: | ||
name: "utils/{{ role }}" | ||
name: "{{ role.name }}" | ||
when: role.when | default(true) | ||
loop: | ||
- manage-hosts | ||
- get-gerrit-admin-user-api-key | ||
- config-repo-get-or-reset | ||
- name: setup-variables | ||
- name: run-operator-standalone | ||
when: "{{ mode == 'standalone' }}" | ||
- name: utils/manage-hosts | ||
- name: utils/get-gerrit-admin-user-api-key | ||
- name: utils/config-repo-get-or-reset | ||
loop_control: | ||
loop_var: role | ||
|
||
- name: Iterate on tests | ||
ansible.builtin.include_role: | ||
name: "health-check/{{ role }}" | ||
name: "health-check/{{ role.name }}" | ||
when: role.when | default(true) | ||
loop: | ||
- check-service-uri | ||
- zuul-connections | ||
- scale-resources | ||
- zuul-authenticators | ||
- config-update-zuul | ||
- config-update-nodepool-launcher | ||
- config-update-nodepool-builder | ||
- pod-spawning | ||
- test-volumestats-sidecar | ||
- expand-volume | ||
- validate-purgelogs | ||
- test-custom-route-certs | ||
- test-cert-manager-letsencrypt | ||
- zuul-client-api | ||
- zuul-components | ||
- test-monitoring | ||
- name: check-service-uri | ||
- name: scale-resources | ||
- name: zuul-connections | ||
- name: zuul-authenticators | ||
- name: config-update-zuul | ||
- name: config-update-nodepool-launcher | ||
- name: config-update-nodepool-builder | ||
- name: pod-spawning | ||
- name: test-volumestats-sidecar | ||
- name: expand-volume | ||
- name: validate-purgelogs | ||
- name: test-custom-route-certs | ||
- name: test-cert-manager-letsencrypt | ||
when: "{{ mode == 'olm' }}" | ||
- name: zuul-client-api | ||
- name: zuul-components | ||
- name: test-monitoring | ||
loop_control: | ||
loop_var: role | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,41 @@ | ||
--- | ||
- name: "Update SoftwareFactory resource {{ cr_name }}" | ||
kubernetes.core.k8s: | ||
kubeconfig: "{{ kubeconfig }}" | ||
definition: | ||
kind: "{{ cr_kind }}" | ||
namespace: "{{ cr_namespace }}" | ||
metadata: | ||
name: "{{ cr_name }}" | ||
namespace: sf | ||
spec: "{{ cr_spec }}" | ||
|
||
- ansible.builtin.include_role: | ||
name: "health-check/check-sf-resource-ready" | ||
when: check_sf_resource_ready | default(true) | ||
- name: "Update CRD" | ||
when: mode == 'olm' | ||
block: | ||
- name: "Update SoftwareFactory resource {{ cr_name }}" | ||
kubernetes.core.k8s: | ||
kubeconfig: "{{ kubeconfig }}" | ||
definition: | ||
kind: "{{ cr_kind }}" | ||
namespace: "{{ cr_namespace }}" | ||
metadata: | ||
name: "{{ cr_name }}" | ||
namespace: sf | ||
spec: "{{ cr_spec }}" | ||
|
||
- ansible.builtin.include_role: | ||
name: "health-check/check-sf-resource-ready" | ||
when: check_sf_resource_ready | default(true) | ||
|
||
- name: "Update standalone" | ||
when: mode == 'standalone' | ||
block: | ||
- name: read current crd | ||
slurp: | ||
src: "/tmp/current_cr.yaml" | ||
register: base_cr | ||
|
||
- name: merge the new cr | ||
copy: | ||
content: "{{ base_cr['content'] | b64decode | from_yaml | combine(new_cr, recursive=true) }}" | ||
dest: "/tmp/current_cr.yaml" | ||
vars: | ||
new_cr: | ||
spec: "{{ cr_spec }}" | ||
|
||
- name: run the operator in standalone mode | ||
ansible.builtin.include_role: | ||
name: run-operator-standalone | ||
vars: | ||
cr_path: /tmp/current_cr.yaml | ||
glue: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.