Skip to content

Commit

Permalink
[OSASINFRA] Add an option to set the project name
Browse files Browse the repository at this point in the history
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
  • Loading branch information
itzikb-redhat authored and openshift-merge-bot[bot] committed Jun 26, 2024
1 parent c680631 commit 43072d1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
6 changes: 5 additions & 1 deletion roles/shiftstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 6 additions & 2 deletions roles/shiftstack/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
8 changes: 4 additions & 4 deletions roles/shiftstack/tasks/deploy_shiftstackclient_pod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions roles/shiftstack/tasks/pre_test_shiftstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 7 additions & 15 deletions roles/shiftstack/tasks/test_shiftstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}/

0 comments on commit 43072d1

Please sign in to comment.