From 43072d16e25c0ad62993e027ed20eb5b0b5024ea Mon Sep 17 00:00:00 2001 From: Itzik Brown Date: Thu, 13 Jun 2024 10:44:53 +0300 Subject: [PATCH] [OSASINFRA] Add an option to set the project name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use a project name for the shiftstackclient as well as the OCP on top of OSP cluster name Also: - Delete the shiftstackclient pod before creating it to make sure we are not reusing an old one - Modify the installation artifacts as it was changed in shiftstack-qa ref: https://review.gerrithub.io/c/shiftstack/shiftstack-qa/+/1196079 The structure: artifacts/ ├── must-gather-verification ├── installation │ └── shiftstack # `user_cloud_installation_dir` │ ├── install-config.yaml │ ├── openstack # `osp_config_dir` │ │ ├── clouds.yaml │ │ └── shiftstackrc │ └── ostest # `ocp_installation_dir` - Sync only artifacts dir as intallation is included in the artifacts dir --- roles/shiftstack/README.md | 6 ++++- roles/shiftstack/defaults/main.yml | 8 +++++-- .../tasks/deploy_shiftstackclient_pod.yml | 8 +++---- .../shiftstack/tasks/pre_test_shiftstack.yml | 7 ++++++ roles/shiftstack/tasks/test_shiftstack.yml | 22 ++++++------------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/roles/shiftstack/README.md b/roles/shiftstack/README.md index 03b26337f0..c01aa2b6f9 100644 --- a/roles/shiftstack/README.md +++ b/roles/shiftstack/README.md @@ -5,9 +5,13 @@ Role for triggering Openshift on Openstack QA automation (installation and tests * `cifmw_shiftstack_artifacts_dir`: (*string*) Directory name for the role artifacts. Defaults to `"{{ cifmw_shiftstack_basedir }}/artifacts"`. * `cifmw_shiftstack_basedir`: (*string*) Base directory for the role artifacts and logs. Defaults to `{{ cifmw_basedir }}/tests/shiftstack` (which defaults to `~/ci-framework-data/tests/shiftstack`. * `cifmw_shiftstack_client_pod_name`: (*string*) Pod name for the pod running the Openshift installer and tests. Defaults to `shiftstackclient`. +* `cifmw_shiftstack_client_pod_manifest`: (*string*) The file name for the shiftstackclient pod manifest. Defaults to `"{{ cifmw_shiftstack_client_pod_name }}_pod.yml"`. * `cifmw_shiftstack_client_pod_namespace`: (*string*) The namespace where the `cifmw_shiftstack_client_pod_name` will be deployed. Defaults to `openstack`. * `cifmw_shiftstack_client_pod_image`: (*string*) The image for the container running in the `cifmw_shiftstack_client_pod_name` pod. Defaults to `quay.io/shiftstack-qe/shiftstack-client:latest`. -* `cifmw_shiftstack_installation_dir`: (*string*) Directory to place installation files. Defaults to `"{{ cifmw_shiftstack_basedir }}/installation"`. +* `cifmw_shiftstack_client_pvc_manifest`: (*string*) The file name for the shiftstackclient pvc manifest. Defaults to `"{{ cifmw_shiftstack_client_pod_name }}_pvc.yml"`. +* `cifmw_shiftstack_cluster_name`: (*string*) The Openshift cluster name. Defaults to `ostest`. +* `cifmw_shiftstack_installation_dir`: (*string*) Directory to place installation files. Defaults to `"{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}/installation"`. +* `cifmw_shiftstack_project_name`: (*string*) The Openstack project name. Defaults to `shiftstack`. * `cifmw_shiftstack_qa_gerrithub_change`: (*string*) The gerrithub change to fetch from the `cifmw_shiftstack_qa_repo` repository (i.e. 'refs/changes/29/1188429/50)'. Defaults to ''. * `cifmw_shiftstack_qa_repo`: (*string*) The repository containing the Openshift on Openstack QA automation. Defaults to `https://review.gerrithub.io/shiftstack/shiftstack-qa`. * `cifmw_shiftstack_run_playbook`: (*string*) The playbook to be run from the `cifmw_shiftstack_qa_repo` repository. Defaults to `ocp_testing.yaml`. diff --git a/roles/shiftstack/defaults/main.yml b/roles/shiftstack/defaults/main.yml index 004acc8086..02f88809f0 100644 --- a/roles/shiftstack/defaults/main.yml +++ b/roles/shiftstack/defaults/main.yml @@ -20,12 +20,16 @@ cifmw_shiftstack_artifacts_dir: "{{ cifmw_shiftstack_basedir }}/artifacts" cifmw_shiftstack_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/shiftstack" cifmw_shiftstack_client_pod_image: "quay.io/shiftstack-qe/shiftstack-client:latest" -cifmw_shiftstack_client_pod_name: "shiftstackclient" +cifmw_shiftstack_client_pod_manifest: "{{ cifmw_shiftstack_client_pod_name }}_pod.yml" +cifmw_shiftstack_client_pod_name: "shiftstackclient-{{ cifmw_shiftstack_project_name }}" cifmw_shiftstack_client_pod_namespace: "openstack" +cifmw_shiftstack_client_pvc_manifest: "{{ cifmw_shiftstack_client_pod_name }}_pvc.yml" +cifmw_shiftstack_cluster_name: "ostest" cifmw_shiftstack_installation_dir: "{{ cifmw_shiftstack_basedir }}/installation" +cifmw_shiftstack_project_name: "shiftstack" cifmw_shiftstack_qa_gerrithub_change: "" cifmw_shiftstack_qa_repo: "https://review.gerrithub.io/shiftstack/shiftstack-qa" cifmw_shiftstack_run_playbook: "ocp_testing.yaml" cifmw_shiftstack_sc: "local-storage" cifmw_shiftstack_shiftstackclient_artifacts_dir: "/home/cloud-admin/artifacts" -cifmw_shiftstack_shiftstackclient_installation_dir: "/home/cloud-admin/installation" +cifmw_shiftstack_shiftstackclient_installation_dir: "{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}/installation" diff --git a/roles/shiftstack/tasks/deploy_shiftstackclient_pod.yml b/roles/shiftstack/tasks/deploy_shiftstackclient_pod.yml index 1cc6b7217d..51801d207e 100644 --- a/roles/shiftstack/tasks/deploy_shiftstackclient_pod.yml +++ b/roles/shiftstack/tasks/deploy_shiftstackclient_pod.yml @@ -17,25 +17,25 @@ - name: Render the pvc manifest ansible.builtin.template: src: templates/shiftstackclient_pvc.yml.j2 - dest: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_name + '_pvc.yml') | path_join }}" + dest: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pvc_manifest) | path_join }}" - name: Apply the manifest for the PVC creation kubernetes.core.k8s: state: present kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - src: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_name + '_pvc.yml') | path_join }}" + src: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pvc_manifest) | path_join }}" - name: Render the pod manifest from a template ansible.builtin.template: src: "templates/shiftstackclient_pod.yml.j2" - dest: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_name + '_pod.yml') | path_join }}" + dest: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_manifest) | path_join }}" mode: "0644" - name: Apply the manifest for the pod creation kubernetes.core.k8s: state: present kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - src: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_name + '_pod.yml') | path_join }}" + src: "{{ (cifmw_shiftstack_basedir, cifmw_shiftstack_client_pod_manifest) | path_join }}" wait: true wait_condition: type: Ready diff --git a/roles/shiftstack/tasks/pre_test_shiftstack.yml b/roles/shiftstack/tasks/pre_test_shiftstack.yml index edb5c12387..4c0a3cd9a4 100644 --- a/roles/shiftstack/tasks/pre_test_shiftstack.yml +++ b/roles/shiftstack/tasks/pre_test_shiftstack.yml @@ -13,6 +13,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +- name: Remove the shiftstackclient pod if exists + kubernetes.core.k8s: + state: absent + api_version: v1 + kind: Pod + namespace: "{{ cifmw_shiftstack_client_pod_namespace }}" + name: "{{ cifmw_shiftstack_client_pod_name }}" - name: Remove the shiftstack role artifacts/logs directory (if exists) ansible.builtin.file: diff --git a/roles/shiftstack/tasks/test_shiftstack.yml b/roles/shiftstack/tasks/test_shiftstack.yml index 36610f2fc0..f69348921d 100644 --- a/roles/shiftstack/tasks/test_shiftstack.yml +++ b/roles/shiftstack/tasks/test_shiftstack.yml @@ -72,7 +72,7 @@ pod: "{{ cifmw_shiftstack_client_pod_name }}" command: >- cd shiftstack-qa && - ansible-navigator run playbooks/{{ cifmw_shiftstack_run_playbook }} -e @jobs_definitions/{{ cifmw_run_test_shiftstack_testconfig }} + ansible-navigator run playbooks/{{ cifmw_shiftstack_run_playbook }} -e @jobs_definitions/{{ cifmw_run_test_shiftstack_testconfig }} -e ocp_cluster_name={{ cifmw_shiftstack_cluster_name }} -e user_cloud={{ cifmw_shiftstack_project_name }} ansible.builtin.include_tasks: exec_command_in_pod.yml rescue: @@ -81,28 +81,20 @@ msg: "OCP install/test block failed, see logs for more information." always: - - name: Retrieve artifacts and installation files from the pod - vars: - directory_list: - - controller_dir: "{{ cifmw_shiftstack_artifacts_dir }}" - pod_dir: "{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}" - - controller_dir: "{{ cifmw_shiftstack_installation_dir }}" - pod_dir: "{{ cifmw_shiftstack_shiftstackclient_installation_dir }}" + - name: Retrieve artifacts from the pod block: - - name: Create the directories for the artifacts and installation files + - name: Create the directory for the artifacts ansible.builtin.file: - path: "{{ item.controller_dir }}" + path: "{{ cifmw_shiftstack_artifacts_dir }}" state: directory mode: "0755" - loop: "{{ directory_list }}" - - name: Copy the artifacts and installation files from the pod '{{ cifmw_shiftstack_client_pod_name }}' + - name: Copy the artifacts from the pod '{{ cifmw_shiftstack_client_pod_name }}' environment: PATH: "{{ cifmw_path }}" KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" ansible.builtin.command: cmd: > oc rsync -n {{ cifmw_shiftstack_client_pod_namespace }} - {{ cifmw_shiftstack_client_pod_name }}:{{ item.pod_dir }}/ - {{ item.controller_dir }}/ - loop: "{{ directory_list }}" + {{ cifmw_shiftstack_client_pod_name }}:{{ cifmw_shiftstack_shiftstackclient_artifacts_dir }}/ + {{ cifmw_shiftstack_artifacts_dir }}/