From c7aa2bfe159f3c906330722a7ca448788d977a2d Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Thu, 5 Apr 2018 11:06:52 +0200 Subject: [PATCH 01/12] Using the MASTER image, to have the latest developement --- roles/provision-unifiedpush-apb/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/provision-unifiedpush-apb/defaults/main.yml b/roles/provision-unifiedpush-apb/defaults/main.yml index 730ae12..7e2a0cc 100644 --- a/roles/provision-unifiedpush-apb/defaults/main.yml +++ b/roles/provision-unifiedpush-apb/defaults/main.yml @@ -15,7 +15,7 @@ postgres_secret_name: ups-postgres # Sidecar Image values ups_sidecar_image: "docker.io/aerogear/ups-config-operator" -ups_sidecar_image_tag: "0.0.1" +ups_sidecar_image_tag: "master" # OAuth Proxy values proxy_image: "docker.io/openshift/oauth-proxy" From a943b0f1dc02c1dab814a902fb8116112d4abd84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Tue, 3 Apr 2018 14:55:03 +0200 Subject: [PATCH 02/12] feat: added jenkinsfile --- Jenkinsfile | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..d7b9671 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,56 @@ +#!groovy + +// https://github.com/feedhenry/fh-pipeline-library +@Library('fh-pipeline-library') _ + +def repositoryName = "unifiedpush-apb" +def projectName = "test-${repositoryName}-${currentBuild.number}-${currentBuild.startTimeInMillis}" + +stage('Trust') { + enforceTrustedApproval('aerogear') +} + +node ("ocp-slave") { + stage('Cleanup') { + deleteDir() + } + stage('Cloning the repo') { + checkout scm + } + + stage('Create OpenShift project') { + sh script: """ + oc new-project ${projectName} + """ + } + stage('Build APB') { + sh script: """ + oc new-build --name ${repositoryName} --binary + oc start-build ${repositoryName} --from-dir=. + sleep 10 + oc logs -f bc/${repositoryName} + """ + } + + stage('Add admin policy to serviceaccount "default"') + + stage('Test APB') { + sh script: """ + oc policy add-role-to-user admin --serviceaccount=default + oc run testing-pod \ + --image=docker-registry.default.svc:5000/${projectName}/${repositoryName} \ + --restart=Never \ + --env POD_NAME=testing-pod \ + --env POD_NAMESPACE=${projectName} \ + --command -- \ + entrypoint.sh test --extra-vars '{\"namespace\": \"${projectName}\"}' + sleep 10 + oc logs --pod-running-timeout=20s -f pod/testing-pod + """ + } + stage('Delete OpenShift project') { + sh script: """ + oc delete project ${projectName} + """ + } +} \ No newline at end of file From dcb6644cf5b3851e9bceca487643c4264be812b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Tue, 3 Apr 2018 14:56:02 +0200 Subject: [PATCH 03/12] feat: added test playbook with roles --- playbooks/test.yml | 30 +++++++++ playbooks/vars/test_defaults.yml | 3 + .../tasks/main.yml | 61 +++++++++++++++++++ .../tasks/main.yml | 12 ++++ 4 files changed, 106 insertions(+) create mode 100644 playbooks/test.yml create mode 100644 playbooks/vars/test_defaults.yml create mode 100644 roles/test-deprovision-unifiedpush-apb/tasks/main.yml create mode 100644 roles/test-provision-unifiedpush-apb/tasks/main.yml diff --git a/playbooks/test.yml b/playbooks/test.yml new file mode 100644 index 0000000..59b7186 --- /dev/null +++ b/playbooks/test.yml @@ -0,0 +1,30 @@ +--- +- name: Test unifiedpush-apb + hosts: localhost + gather_facts: false + connection: local + vars_files: + - /opt/ansible/vars/main.yml + + roles: + - role: ansible.kubernetes-modules + install_python_requirements: no + - role: ansibleplaybookbundle.asb-modules + post_tasks: + - name: Load default variables for testing + include_vars: test_defaults.yml + - name: create project for namespace + openshift_v1_project: + name: '{{ namespace }}' + - name: Run the provision role. + include_role: + name: provision-unifiedpush-apb + - name: Run the test role. + include_role: + name: test-provision-unifiedpush-apb + - name: Run the deprovision role. + include_role: + name: deprovision-unifiedpush-apb + - name: Run the deprovision test role. + include_role: + name: test-deprovision-unifiedpush-apb \ No newline at end of file diff --git a/playbooks/vars/test_defaults.yml b/playbooks/vars/test_defaults.yml new file mode 100644 index 0000000..fd1085f --- /dev/null +++ b/playbooks/vars/test_defaults.yml @@ -0,0 +1,3 @@ +MYSQL_USER: 'testuser' +MYSQL_DATABASE: 'unifiedpush' +MYSQL_VERSION: '55' \ No newline at end of file diff --git a/roles/test-deprovision-unifiedpush-apb/tasks/main.yml b/roles/test-deprovision-unifiedpush-apb/tasks/main.yml new file mode 100644 index 0000000..ef1b5fe --- /dev/null +++ b/roles/test-deprovision-unifiedpush-apb/tasks/main.yml @@ -0,0 +1,61 @@ +--- + +# Instead of testing that the deployment config is removed, we test that the pods +# are cleaned up afterwards +- name: Check that all pods have been removed + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig in (mysql,ups)" 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"No resources found." not in result.stdout' + until: '"No resources found." in result.stdout' + +- name: Check that the ups route has been removed + shell: oc get route --namespace={{ namespace }} {{ ups_route_name }} 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"not found" not in result.stdout' + until: '"not found" in result.stdout' + +- name: Check that all services have been removed + shell: oc get service --namespace={{ namespace }} {{ item }} 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"not found" not in result.stdout' + until: '"not found" in result.stdout' + with_items: + - '{{ mysql_service_name}}' + - '{{ ups_service_name}}' + - '{{ ups_proxy_service_name}}' + +- name: Check that all secrets have been removed + shell: oc get secret --namespace={{ namespace }} {{ ups_secret_name }} 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"not found" not in result.stdout' + until: '"not found" in result.stdout' + +- name: Check that all persistent volume claims have been removed + shell: oc get pvc --namespace={{ namespace }} {{ mysql_claim_name }} 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"not found" not in result.stdout' + until: '"not found" in result.stdout' + +- name: Check that the service account has been removed + shell: oc get serviceaccount --namespace={{ namespace }} {{ proxy_serviceaccount_name }} 2>&1 + register: result + retries: 50 + delay: 10 + failed_when: + - '"not found" not in result.stdout' + until: '"not found" in result.stdout' \ No newline at end of file diff --git a/roles/test-provision-unifiedpush-apb/tasks/main.yml b/roles/test-provision-unifiedpush-apb/tasks/main.yml new file mode 100644 index 0000000..b34bfc4 --- /dev/null +++ b/roles/test-provision-unifiedpush-apb/tasks/main.yml @@ -0,0 +1,12 @@ +- name: Check that the unifiedpush login webpage is accessible + uri: + url: "https://{{ ups_route.route.spec.host }}" + return_content: yes + validate_certs: no + register: webpage + retries: 10 + delay: 20 + failed_when: + - webpage.status == 403 + - '"Log in with OpenShift" not in webpage.content' + until: '"Log in with OpenShift" in webpage.content' \ No newline at end of file From 983311d345336f49abc3579b0064d96c652849ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Tue, 3 Apr 2018 14:57:15 +0200 Subject: [PATCH 04/12] fix: objects' names as variables --- roles/deprovision-unifiedpush-apb/tasks/main.yml | 15 ++++++++++----- .../tasks/provision-ups.yml | 9 +++------ .../templates/secret.yml.j2 | 2 +- vars/main.yml | 6 ++++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/roles/deprovision-unifiedpush-apb/tasks/main.yml b/roles/deprovision-unifiedpush-apb/tasks/main.yml index 7f499b2..690014c 100644 --- a/roles/deprovision-unifiedpush-apb/tasks/main.yml +++ b/roles/deprovision-unifiedpush-apb/tasks/main.yml @@ -1,5 +1,5 @@ - k8s_v1_persistent_volume_claim: - name: mysql + name: '{{ mysql_claim_name }}' namespace: '{{ namespace }}' state: absent @@ -9,7 +9,7 @@ state: absent - k8s_v1_service: - name: mysql + name: '{{ mysql_service_name }}' namespace: '{{ namespace }}' state: absent @@ -19,12 +19,17 @@ state: absent - k8s_v1_service: - name: unifiedpush + name: '{{ ups_service_name }}' namespace: '{{ namespace }}' - state: absent + state: absent + +- k8s_v1_service: + name: '{{ ups_proxy_service_name }}' + namespace: '{{ namespace }}' + state: absent - openshift_v1_route: - name: unifiedpush + name: '{{ ups_route_name }}' namespace: '{{ namespace }}' state: absent diff --git a/roles/provision-unifiedpush-apb/tasks/provision-ups.yml b/roles/provision-unifiedpush-apb/tasks/provision-ups.yml index 31b0f25..b7a4377 100644 --- a/roles/provision-unifiedpush-apb/tasks/provision-ups.yml +++ b/roles/provision-unifiedpush-apb/tasks/provision-ups.yml @@ -63,7 +63,7 @@ - name: create UPS service k8s_v1_service: - name: ups-service + name: '{{ ups_service_name }}' namespace: '{{ namespace }}' annotations: org.aerogear.metrics/plain_endpoint: "/rest/prometheus/metrics" @@ -82,7 +82,7 @@ - name: create UPS Proxy k8s_v1_service: - name: ups-proxy + name: '{{ ups_proxy_service_name }}' namespace: '{{ namespace }}' labels: app: ups @@ -97,7 +97,7 @@ - name: create ups route openshift_v1_route: - name: ups + name: '{{ ups_route_name }}' namespace: '{{ namespace }}' labels: app: ups @@ -105,9 +105,6 @@ to_name: ups-proxy spec_port_target_port: web spec_tls_termination: edge - -- name: "Retrieve route to ups-server" - shell: "oc get routes ups -n {{ namespace }} | grep -v NAME | awk '{print $2}'" register: ups_route # We need to wait for the deployment to be ready before we can exit the ansible job diff --git a/roles/provision-unifiedpush-apb/templates/secret.yml.j2 b/roles/provision-unifiedpush-apb/templates/secret.yml.j2 index 3335259..85cb6d2 100644 --- a/roles/provision-unifiedpush-apb/templates/secret.yml.j2 +++ b/roles/provision-unifiedpush-apb/templates/secret.yml.j2 @@ -10,5 +10,5 @@ metadata: stringData: type: {{ ups_secret_name }} name: {{ ups_secret_name }} - uri: http://{{ ups_route.stdout }} + uri: http://{{ ups_route.route.spec.host }} applicationId: "{{ namespace_push_app.json.pushApplicationID }}" \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index 20607eb..00ba4f8 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,3 +1,9 @@ # Global values used in all playbooks ups_secret_name: "unified-push-server" proxy_serviceaccount_name: "oauth-proxy" +mysql_claim_name: "mysql-claim" +mysql_service_name: "mysql" +ups_route_name: "ups" +ups_service_name: "ups-service" +ups_proxy_service_name: "ups-proxy" + From 6d93a5763681f4af22e5be489785e9124f4d02dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Tue, 3 Apr 2018 15:22:31 +0200 Subject: [PATCH 05/12] fix: exception handling in Jenkinsfile --- Jenkinsfile | 90 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d7b9671..fa5ce73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,40 +17,64 @@ node ("ocp-slave") { stage('Cloning the repo') { checkout scm } + + try { - stage('Create OpenShift project') { - sh script: """ - oc new-project ${projectName} - """ - } - stage('Build APB') { - sh script: """ - oc new-build --name ${repositoryName} --binary - oc start-build ${repositoryName} --from-dir=. - sleep 10 - oc logs -f bc/${repositoryName} - """ - } + stage('Create OpenShift project') { + sh script: "oc new-project ${projectName}" + } + stage('Build APB') { + try { + timeout(5) { + sh script: """ + oc new-build --name ${repositoryName} --binary + oc start-build ${repositoryName} --from-dir=. + sleep 10 + oc logs -f bc/${repositoryName} + """ + } + } catch (Exception e) { + error "Build timed out" + } - stage('Add admin policy to serviceaccount "default"') - - stage('Test APB') { - sh script: """ - oc policy add-role-to-user admin --serviceaccount=default - oc run testing-pod \ - --image=docker-registry.default.svc:5000/${projectName}/${repositoryName} \ - --restart=Never \ - --env POD_NAME=testing-pod \ - --env POD_NAMESPACE=${projectName} \ - --command -- \ - entrypoint.sh test --extra-vars '{\"namespace\": \"${projectName}\"}' - sleep 10 - oc logs --pod-running-timeout=20s -f pod/testing-pod - """ - } - stage('Delete OpenShift project') { - sh script: """ - oc delete project ${projectName} - """ + } + + stage('Add admin policy to serviceaccount "default"') { + sh script: "oc policy add-role-to-user admin --serviceaccount=default" + } + + stage('Test APB') { + try { + timeout(5) { + sh script: """ + oc run testing-pod \ + --image=docker-registry.default.svc:5000/${projectName}/${repositoryName} \ + --restart=Never \ + --env POD_NAME=testing-pod \ + --env POD_NAMESPACE=${projectName} \ + --command -- \ + entrypoint.sh test --extra-vars '{\"namespace\": \"${projectName}\"}' + sleep 10 + oc logs --pod-running-timeout=20s -f pod/testing-pod + """ + } + } catch (Exception e) { + error "Pod didn't finish in time." + } + } + stage('Delete OpenShift project') { + sh script: "oc delete project ${projectName}" + } + } catch (Exception e) { + try { + timeout(15) { + input message: 'The test failed. Click on "Approve" to delete the project. Otherwise it will be deleted after 15 minutes' + } + } catch (Exception e2) { + println("Waiting for a user input exceeded its time limit. Deleting the project now.") + } + + sh script: "oc delete project ${projectName}" + error "Error when running the test: ${e}" } } \ No newline at end of file From 0c14e4142dae890a5df7c71d1f8aa6fa3a8ae01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Tue, 3 Apr 2018 15:25:34 +0200 Subject: [PATCH 06/12] fix: increased timeout for test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa5ce73..163ebf6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,7 +45,7 @@ node ("ocp-slave") { stage('Test APB') { try { - timeout(5) { + timeout(15) { sh script: """ oc run testing-pod \ --image=docker-registry.default.svc:5000/${projectName}/${repositoryName} \ From 2fd84f1ec1dfebd66887b999d38a6c5e5b8e0310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Wed, 4 Apr 2018 12:36:15 +0200 Subject: [PATCH 07/12] fix: variable names changes for postgres --- .../tasks/main.yml | 19 +++++++++++++------ .../defaults/main.yml | 4 ---- .../tasks/provision-ups.yml | 4 ++-- .../tasks/main.yml | 6 +++--- vars/main.yml | 18 +++++++++++------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/roles/deprovision-unifiedpush-apb/tasks/main.yml b/roles/deprovision-unifiedpush-apb/tasks/main.yml index 690014c..43d2f92 100644 --- a/roles/deprovision-unifiedpush-apb/tasks/main.yml +++ b/roles/deprovision-unifiedpush-apb/tasks/main.yml @@ -1,20 +1,27 @@ +# PostgreSQL +- openshift_v1_deployment_config: + name: '{{ postgres_deploymentconfig_name }}' + namespace: '{{ namespace }}' + state: absent + - k8s_v1_persistent_volume_claim: - name: '{{ mysql_claim_name }}' + name: '{{ postgres_pvc_name }}' namespace: '{{ namespace }}' state: absent -- openshift_v1_deployment_config: - name: mysql +- k8s_v1_secret: + name: '{{ postgres_secret_name }}' namespace: '{{ namespace }}' state: absent - k8s_v1_service: - name: '{{ mysql_service_name }}' + name: '{{ postgres_service_name }}' namespace: '{{ namespace }}' - state: absent + state: absent +# UPS - openshift_v1_deployment_config: - name: ups + name: '{{ ups_deploymentconfig_name }}' namespace: '{{ namespace }}' state: absent diff --git a/roles/provision-unifiedpush-apb/defaults/main.yml b/roles/provision-unifiedpush-apb/defaults/main.yml index 7e2a0cc..805779b 100644 --- a/roles/provision-unifiedpush-apb/defaults/main.yml +++ b/roles/provision-unifiedpush-apb/defaults/main.yml @@ -1,17 +1,13 @@ # UPS Values -ups_secret_name: "unified-push-server" ups_image: " docker.io/matzew/unifiedpush-psql" ups_image_tag: "latest" ups_port: 8080 ups_proxy_port: 4180 -proxy_serviceaccount_name: "oauth-proxy" # Non global constants postgres_image: centos/postgresql-95-centos7 postgres_image_tag: '9.5' postgres_database_name: unifiedpush -postgres_service_name: postgres -postgres_secret_name: ups-postgres # Sidecar Image values ups_sidecar_image: "docker.io/aerogear/ups-config-operator" diff --git a/roles/provision-unifiedpush-apb/tasks/provision-ups.yml b/roles/provision-unifiedpush-apb/tasks/provision-ups.yml index b7a4377..ad38617 100644 --- a/roles/provision-unifiedpush-apb/tasks/provision-ups.yml +++ b/roles/provision-unifiedpush-apb/tasks/provision-ups.yml @@ -1,6 +1,6 @@ - name: UPS deployment openshift_v1_deployment_config: - name: ups + name: '{{ ups_deploymentconfig_name }}' namespace: "{{ namespace }}" labels: app: ups @@ -109,7 +109,7 @@ # We need to wait for the deployment to be ready before we can exit the ansible job - name: "Wait for all UPS containers to become ready" - shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=ups" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig={{ ups_deploymentconfig_name }}" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w register: ups_result until: ups_result.stdout.find("3") != -1 retries: 30 diff --git a/roles/test-deprovision-unifiedpush-apb/tasks/main.yml b/roles/test-deprovision-unifiedpush-apb/tasks/main.yml index ef1b5fe..1a53e54 100644 --- a/roles/test-deprovision-unifiedpush-apb/tasks/main.yml +++ b/roles/test-deprovision-unifiedpush-apb/tasks/main.yml @@ -3,7 +3,7 @@ # Instead of testing that the deployment config is removed, we test that the pods # are cleaned up afterwards - name: Check that all pods have been removed - shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig in (mysql,ups)" 2>&1 + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig in ({{ postgres_deploymentconfig_name }}, {{ ups_deploymentconfig_name }})" 2>&1 register: result retries: 50 delay: 10 @@ -29,7 +29,7 @@ - '"not found" not in result.stdout' until: '"not found" in result.stdout' with_items: - - '{{ mysql_service_name}}' + - '{{ postgres_service_name}}' - '{{ ups_service_name}}' - '{{ ups_proxy_service_name}}' @@ -43,7 +43,7 @@ until: '"not found" in result.stdout' - name: Check that all persistent volume claims have been removed - shell: oc get pvc --namespace={{ namespace }} {{ mysql_claim_name }} 2>&1 + shell: oc get pvc --namespace={{ namespace }} {{ postgres_pvc_name }} 2>&1 register: result retries: 50 delay: 10 diff --git a/vars/main.yml b/vars/main.yml index 00ba4f8..f6c6885 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,9 +1,13 @@ # Global values used in all playbooks -ups_secret_name: "unified-push-server" -proxy_serviceaccount_name: "oauth-proxy" -mysql_claim_name: "mysql-claim" -mysql_service_name: "mysql" -ups_route_name: "ups" -ups_service_name: "ups-service" -ups_proxy_service_name: "ups-proxy" +proxy_serviceaccount_name: "sa-oauth-proxy" + +postgres_deploymentconfig_name: "postgres" +postgres_pvc_name: "postgres-pvc" +postgres_secret_name: "postgres-secret" +postgres_service_name: "postgres-service" +ups_deploymentconfig_name: "ups" +ups_proxy_service_name: "ups-proxy" +ups_route_name: "ups-route" +ups_secret_name: "ups-secret" +ups_service_name: "ups-service" \ No newline at end of file From c3def0a87b51001c3f2c05b15dec6da11bd66175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Wed, 4 Apr 2018 12:50:36 +0200 Subject: [PATCH 08/12] fix: additional fix of variables --- playbooks/vars/test_defaults.yml | 3 --- roles/provision-unifiedpush-apb/tasks/main.yml | 2 +- .../tasks/provision-database.yml | 12 ++++++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/playbooks/vars/test_defaults.yml b/playbooks/vars/test_defaults.yml index fd1085f..e69de29 100644 --- a/playbooks/vars/test_defaults.yml +++ b/playbooks/vars/test_defaults.yml @@ -1,3 +0,0 @@ -MYSQL_USER: 'testuser' -MYSQL_DATABASE: 'unifiedpush' -MYSQL_VERSION: '55' \ No newline at end of file diff --git a/roles/provision-unifiedpush-apb/tasks/main.yml b/roles/provision-unifiedpush-apb/tasks/main.yml index f985c3f..aa00a67 100644 --- a/roles/provision-unifiedpush-apb/tasks/main.yml +++ b/roles/provision-unifiedpush-apb/tasks/main.yml @@ -4,7 +4,7 @@ register: service_instance_name - name: Label the service instance with the service name - shell: oc label serviceinstance '{{ service_instance_name.stdout }}' serviceName=unifiedpush --namespace={{ namespace }} + shell: oc label serviceinstance '{{ service_instance_name.stdout }}' serviceName={{ ups_service_name }} --namespace={{ namespace }} when: _apb_service_instance_id is defined - name: "Create OAuth Proxy Serviceaccount yaml" diff --git a/roles/provision-unifiedpush-apb/tasks/provision-database.yml b/roles/provision-unifiedpush-apb/tasks/provision-database.yml index 4f0d095..7428d6e 100644 --- a/roles/provision-unifiedpush-apb/tasks/provision-database.yml +++ b/roles/provision-unifiedpush-apb/tasks/provision-database.yml @@ -31,7 +31,7 @@ session_affinity: None - k8s_v1_persistent_volume_claim: - name: '{{ postgres_service_name }}' + name: '{{ postgres_pvc_name }}' namespace: '{{ namespace }}' access_modes: - ReadWriteOnce @@ -39,7 +39,7 @@ storage: "1Gi" - openshift_v1_deployment_config: - name: '{{ postgres_service_name }}' + name: '{{ postgres_deploymentconfig_name }}' namespace: '{{ namespace }}' replicas: 1 labels: @@ -89,18 +89,18 @@ limits: memory: '512Mi' volume_mounts: - - name: '{{ postgres_service_name }}-data' + - name: '{{ postgres_pvc_name }}-data' mount_path: "/var/lib/pgsql/data" termination_message_path: "/dev/termination-log" volumes: - - name: '{{ postgres_service_name }}-data' + - name: '{{ postgres_pvc_name }}-data' persistent_volume_claim: - claim_name: '{{ postgres_service_name }}' + claim_name: '{{ postgres_pvc_name }}' # Check the containers in the Postgres pod and make sure they are all ready - name: "Wait for all Postgres containers to become ready" - shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=postgres" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w + shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig={{ postgres_deploymentconfig_name }}" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w register: postgresql_result until: postgresql_result.stdout.find("1") != -1 retries: 30 From 8062e1c1d5fd7718a6ac5782503d34583f8b6d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Wed, 4 Apr 2018 14:50:38 +0200 Subject: [PATCH 09/12] feat: test for existing push app --- roles/test-provision-unifiedpush-apb/tasks/main.yml | 11 ++++++++++- vars/main.yml | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/roles/test-provision-unifiedpush-apb/tasks/main.yml b/roles/test-provision-unifiedpush-apb/tasks/main.yml index b34bfc4..098fe3d 100644 --- a/roles/test-provision-unifiedpush-apb/tasks/main.yml +++ b/roles/test-provision-unifiedpush-apb/tasks/main.yml @@ -9,4 +9,13 @@ failed_when: - webpage.status == 403 - '"Log in with OpenShift" not in webpage.content' - until: '"Log in with OpenShift" in webpage.content' \ No newline at end of file + until: '"Log in with OpenShift" in webpage.content' + +- name: "Check that new application was created for the namespace {{ namespace }}" + uri: + method: GET + url: "http://{{ unifiedpush_service.service.spec.cluster_ip }}/rest/applications" + return_content: yes + validate_certs: no + register: applications + failed_when: applications.json[0].name != "{{ namespace }}" \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index f6c6885..0651e39 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -4,10 +4,10 @@ proxy_serviceaccount_name: "sa-oauth-proxy" postgres_deploymentconfig_name: "postgres" postgres_pvc_name: "postgres-pvc" postgres_secret_name: "postgres-secret" -postgres_service_name: "postgres-service" +postgres_service_name: "postgres" ups_deploymentconfig_name: "ups" ups_proxy_service_name: "ups-proxy" ups_route_name: "ups-route" ups_secret_name: "ups-secret" -ups_service_name: "ups-service" \ No newline at end of file +ups_service_name: "ups" \ No newline at end of file From 50947bf80a505021f228dfe3068b19f476b6469b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Thu, 5 Apr 2018 12:53:17 +0200 Subject: [PATCH 10/12] fix: ups route name, check status of testing pod --- Jenkinsfile | 4 +++- vars/main.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 163ebf6..22c48df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,6 +56,8 @@ node ("ocp-slave") { entrypoint.sh test --extra-vars '{\"namespace\": \"${projectName}\"}' sleep 10 oc logs --pod-running-timeout=20s -f pod/testing-pod + # Check if the status of testing-pod is error + if [ \$(oc get pods | grep testing-pod | awk '{print \$3}') == "Error" ] ; then exit 1 ; fi """ } } catch (Exception e) { @@ -77,4 +79,4 @@ node ("ocp-slave") { sh script: "oc delete project ${projectName}" error "Error when running the test: ${e}" } -} \ No newline at end of file +} diff --git a/vars/main.yml b/vars/main.yml index 0651e39..cb0509a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -8,6 +8,6 @@ postgres_service_name: "postgres" ups_deploymentconfig_name: "ups" ups_proxy_service_name: "ups-proxy" -ups_route_name: "ups-route" +ups_route_name: "ups" ups_secret_name: "ups-secret" -ups_service_name: "ups" \ No newline at end of file +ups_service_name: "ups" From 055fe9e91b80a1545c5e4913acea023d9802086d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0turc?= Date: Thu, 5 Apr 2018 13:36:45 +0200 Subject: [PATCH 11/12] fix: final --- vars/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vars/main.yml b/vars/main.yml index cb0509a..a391722 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,5 +1,5 @@ # Global values used in all playbooks -proxy_serviceaccount_name: "sa-oauth-proxy" +proxy_serviceaccount_name: "oauth-proxy" postgres_deploymentconfig_name: "postgres" postgres_pvc_name: "postgres-pvc" @@ -9,5 +9,5 @@ postgres_service_name: "postgres" ups_deploymentconfig_name: "ups" ups_proxy_service_name: "ups-proxy" ups_route_name: "ups" -ups_secret_name: "ups-secret" +ups_secret_name: "unified-push-server" ups_service_name: "ups" From 2e8ca239b18c4779b44d5151ec5e495e7b54ebd5 Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Thu, 5 Apr 2018 20:35:47 +0200 Subject: [PATCH 12/12] Updating app name --- roles/provision-unifiedpush-apb/tasks/provision-database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/provision-unifiedpush-apb/tasks/provision-database.yml b/roles/provision-unifiedpush-apb/tasks/provision-database.yml index 7428d6e..1972189 100644 --- a/roles/provision-unifiedpush-apb/tasks/provision-database.yml +++ b/roles/provision-unifiedpush-apb/tasks/provision-database.yml @@ -43,10 +43,10 @@ namespace: '{{ namespace }}' replicas: 1 labels: - app: ups + app: '{{ ups_deploymentconfig_name }}' service: '{{ postgres_service_name }}' spec_template_metadata_labels: - app: ups + app: '{{ ups_deploymentconfig_name }}' name: '{{ postgres_service_name }}' containers: - name: postgresql