Skip to content

Commit

Permalink
testing: lints partial fixes
Browse files Browse the repository at this point in the history
This commit resolves the following lint rules:

- 'key-order[task]'
- 'name[missing]'
- 'yaml[trailing-spaces]'
- 'risky-shell-pipe'
- 'args[module]'

Also removes the branch constraint to run
the Ansible lint checks from any fork. This
is useful because in each contributor's fork
when pushing specific named branches the checks
will be executed, a future improvement could be
to run all the lints checks from a single environment
like `tox -e linters` instead of consuming the GH action.

Partially-solves: openshift-psap#10
  • Loading branch information
ccamacho committed Aug 25, 2023
1 parent 690108f commit ff9b57e
Show file tree
Hide file tree
Showing 32 changed files with 216 additions and 114 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ name: Run ansible-lint

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
pull_request:
branches: [main]
push:
branches: [main]
schedule:
- cron: '0 */8 * * *'
# Allows you to run this workflow manually from the Actions tab
Expand Down
7 changes: 0 additions & 7 deletions config/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ skip_list:
- 'command-instead-of-module'
- 'command-instead-of-shell'
- 'deprecated-local-action'
- 'key-order[task]'
- 'jinja[spacing]'
- 'no-free-form'
- 'chema[meta]'
- 'name[missing]'
- 'var-naming[no-reserved]'
- 'var-naming[no-role-prefix]'
- 'var-naming[pattern]'
Expand All @@ -29,15 +26,11 @@ skip_list:
- 'yaml[indentation]'
- 'yaml[key-duplicates]'
- 'yaml[line-length]'
- 'yaml[new-line-at-end-of-file]'
- 'yaml[octal-values]'
- 'yaml[trailing-spaces]'
- 'yaml[truthy]'
- 'name[template]'
- 'name[casing]'
- 'risky-file-permissions'
- 'risky-shell-pipe'
- 'ignore-errors'
- 'no-changed-when'
- 'fqcn'
- 'args[module]'
13 changes: 7 additions & 6 deletions roles/benchmarking/benchmarking_run_mlperf_ssd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
command: oc get nodes -l kubernetes.io/hostname={{ benchmarking_run_mlperf_ssd_node_hostname }} -oname

- name: Ensure that the coco dataset PVC exists
command:
command: |
oc get pvc/{{ benchmarking_run_mlperf_ssd_dataset_pvc_name }}
-n {{ benchmarking_run_mlperf_ssd_namespace }}
- name: Fetch the coco dataset PVC definition (debug)
shell:
shell: |
oc get pvc/{{ benchmarking_run_mlperf_ssd_pvc_name }}
-n {{ benchmarking_run_mlperf_ssd_namespace }}
-oyaml
> {{ artifact_extra_logs_dir }}/pvc_coco-dataset.yml
- name: Create the entrypoint ConfigMap file
shell:
shell: |
oc create cm {{ benchmarking_run_mlperf_ssd_entrypoint_cm_name }}
--from-file="{{ benchmarking_mlperf_ssd_entrypoint }}"
-n {{ benchmarking_run_mlperf_ssd_namespace }}
Expand All @@ -45,7 +45,8 @@
command:
oc create -f "{{ artifact_extra_logs_dir }}/001_pod_run-mlperf-ssd.yml"

- block:
- name: Make sure the benchmark completes
block:
- name: Wait for the benchmark completion
command:
oc get pod/{{ benchmarking_run_mlperf_ssd_name }}
Expand All @@ -63,7 +64,7 @@

always:
- name: Store the logs of benchmark execution (for post-processing)
shell:
shell: |
oc logs pod/{{ benchmarking_run_mlperf_ssd_name }} -n {{ benchmarking_run_mlperf_ssd_namespace }}
> "{{ artifact_extra_logs_dir }}/pod_run-mlperf-ssd.log"
failed_when: false
Expand All @@ -73,7 +74,7 @@
echo "{{ wait_benchmark_pod_cmd.stdout }}" > "{{ artifact_extra_logs_dir }}/pod_run-mlperf-ssd.status"

- name: Store the description of benchmark execution (debug)
shell:
shell: |
oc describe pod/{{ benchmarking_run_mlperf_ssd_name }} -n {{ benchmarking_run_mlperf_ssd_namespace }}
> "{{ artifact_extra_logs_dir }}/pod_run-mlperf-ssd.descr"
failed_when: false
Expand Down
14 changes: 5 additions & 9 deletions roles/cluster/cluster_capture_environment/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
- name: Store OpenShift version identifier
shell:
shell: |
set -o pipefail;
oc version -o json
| jq --raw-output '.openshiftVersion'
> {{ artifact_extra_logs_dir }}/ocp.version
- name: Store OpenShift YAML version
shell:
shell: |
oc version -oyaml
> {{ artifact_extra_logs_dir }}/ocp_version.yml
- name: Store OpenShift YAML clusterversion
shell:
shell: |
oc get clusterversion/version -oyaml
> {{ artifact_extra_logs_dir }}/ocp_clusterversion.yml
# ---

- name: Store the OpenShift nodes
shell:
shell: |
oc get nodes -owide
> {{ artifact_extra_logs_dir }}/nodes.status;
oc get nodes -oyaml
> {{ artifact_extra_logs_dir }}/nodes.yaml;
- name: Store the OpenShift machines
shell:
shell: |
oc get machines -n openshift-machine-api -owide
> {{ artifact_extra_logs_dir }}/machines.status;
oc get machines -n openshift-machine-api -oyaml
Expand All @@ -37,8 +37,6 @@
command:
git describe HEAD --long --always
register: git_version
args:
warn: false # don't warn about using git here

- name: Store ci-artifact version from Git
copy:
Expand All @@ -50,8 +48,6 @@
command:
git show --no-patch
register: git_show
args:
warn: false # don't warn about using git here

- name: Store ci-artifact last git commit
copy:
Expand Down
7 changes: 6 additions & 1 deletion roles/cluster/cluster_deploy_ldap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,12 @@
# Workaround until `ocm` supports the --insecure flag

- name: Get the cluster ID
shell:
shell: |
set -o pipefail
ocm describe cluster "{{ cluster_deploy_ldap_cluster_name }}" --json | jq .id -r
register: cluster_id_cmd
args:
executable: /bin/bash

- name: Create the IDP resource manually
shell: |
Expand All @@ -157,6 +160,8 @@
url="https://api.openshift.com/api/clusters_mgmt/v1/clusters/{{ cluster_id_cmd.stdout }}/identity_providers";
cat "{{ cluster_deploy_ldap_ocm_idp }}" | envsubst > /tmp/idp.json
ocm post "$url" --body /tmp/idp.json
args:
executable: /bin/bash

- name: Get the API URL
command: oc whoami --show-server
Expand Down
42 changes: 21 additions & 21 deletions roles/cluster/cluster_deploy_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
-n {{ cluster_deploy_operator_catalog_namespace }}

- name: Capture the state of the CatalogSource (debug)
shell:
shell: |
oc get -oyaml CatalogSource/{{ cluster_deploy_operator_catalog }}
-n {{ cluster_deploy_operator_catalog_namespace }}
-oyaml
Expand All @@ -61,22 +61,22 @@
delay: 30

- name: Save the operator PackageManifest YAML (debug)
shell:
shell: |
oc get packagemanifests/{{ cluster_deploy_operator_manifest_name }}
-n {{ cluster_deploy_operator_catalog_namespace }}
-oyaml
> {{ artifact_extra_logs_dir }}/operator_packagemanifest.yml
- name: Store the operator PackageManifest JSON
shell:
shell: |
oc get packagemanifests/{{ cluster_deploy_operator_manifest_name }}
-n {{ cluster_deploy_operator_catalog_namespace }}
-ojson
> {{ artifact_extra_logs_dir }}/operator_packagemanifest.json
rescue:
- name: Capture the Catalog Operator logs (debug)
shell:
shell: |
oc logs deployment.apps/catalog-operator
-n openshift-operator-lifecycle-manager
> {{ artifact_extra_logs_dir }}/catalog_operator.log
Expand All @@ -86,7 +86,7 @@
debug: msg="The logs of Catalog Operator have been saved in {{ artifact_extra_logs_dir }}/catalog_operator.log"

- name: Mark the failure as flake
shell:
shell: |
echo "Failed because the {{ cluster_deploy_operator_manifest_name }} PackageManifest is not available"
> "{{ artifact_extra_logs_dir }}/FLAKE"
Expand Down Expand Up @@ -231,7 +231,8 @@
- name: Instantiate the Subscription
command: oc apply -f "{{ artifact_extra_logs_dir }}/src/002_sub.yml"

- block:
- name: Make sure the InstallPlan is deployed
block:
- name: Find the operator InstallPlan
command:
oc get InstallPlan
Expand Down Expand Up @@ -276,32 +277,31 @@
fail: msg="ClusterServiceVersion install not successful ({{ operator_csv_phase.stdout }})"
when: operator_csv_phase.stdout != "Succeeded"

rescue:
- name: Capture the Catalog Operator logs (debug)
shell: |
oc logs deployment.apps/catalog-operator
-n openshift-operator-lifecycle-manager
> {{ artifact_extra_logs_dir }}/catalog_operator.log
failed_when: false
- name: Indicate where the Catalog-operator logs have been saved
debug: msg="The logs of Catalog Operator have been saved in {{ artifact_extra_logs_dir }}/catalog_operator.log"
- name: Failed because the operator could not be installed from the CatalogSource
fail: msg="Failed because the operator could not be installed from the CatalogSource"

always:
- name: Store the YAML of the operator CSV that was installed (debug)
shell:
shell: |
oc get ClusterServiceVersion/{{ operator_csv_name }}
-oyaml
-n "{{ cluster_deploy_operator_namespace }}"
> {{ artifact_extra_logs_dir }}/operator_csv.yml
- name: Store the YAML of the subscription
shell:
shell: |
oc get -f "{{ artifact_extra_logs_dir }}/src/002_sub.yml"
-oyaml
-n "{{ cluster_deploy_operator_namespace }}"
> {{ artifact_extra_logs_dir }}/operator_sub.yml
rescue:
- name: Capture the Catalog Operator logs (debug)
shell:
oc logs deployment.apps/catalog-operator
-n openshift-operator-lifecycle-manager
> {{ artifact_extra_logs_dir }}/catalog_operator.log
failed_when: false

- name: Indicate where the Catalog-operator logs have been saved
debug: msg="The logs of Catalog Operator have been saved in {{ artifact_extra_logs_dir }}/catalog_operator.log"

- name: Failed because the operator could not be installed from the CatalogSource
fail: msg="Failed because the operator could not be installed from the CatalogSource"
- name: Deploy the operator CustomResource from its ClusterServiceVersion
include_tasks: deploy_cr.yml
Expand Down
5 changes: 4 additions & 1 deletion roles/cluster/cluster_ensure_machineset/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
- name: "Check if the cluster already has a {{ machineset_instance_type }} machineset"
shell:
shell: |
set -o pipefail
oc get machineset -n openshift-machine-api
{% if machineset_name | length > 0 %}
-ojson | jq '.items[] | select(.spec.template.spec.providerSpec.value.instanceType=="{{ machineset_instance_type }}" and .metadata.name=="{{ machineset_name }}") | .metadata.name' -r
{% else %}
-o=jsonpath='{.items[?(@.spec.template.spec.providerSpec.value.instanceType=="{{ machineset_instance_type }}")].metadata.name}'
{% endif %}
register: cluster_has_machineset
args:
executable: /bin/bash

- name: Delete the machineset if it is set but has the wrong instance type
when: not cluster_has_machineset.stdout and machineset_name | length > 0
Expand Down
7 changes: 5 additions & 2 deletions roles/cluster/cluster_fill_workernodes/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
- name: Get the list of the worker nodes
shell:
shell: |
set -o pipefail
oc get nodes
-l{{ cluster_fill_workernodes_label_selector }}
-oname
| cut -d/ -f2
register:
worker_node_names_cmd
failed_when: not worker_node_names_cmd.stdout
args:
executable: /bin/bash

- name: Create the src artifacts directory
file:
Expand All @@ -21,7 +24,7 @@
include_tasks: fill_node.yaml

- name: Store the definition of the nodes
shell:
shell: |
oc get nodes
-lnode-role.kubernetes.io/worker
-oyaml
Expand Down
19 changes: 12 additions & 7 deletions roles/cluster/cluster_set_scale/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
register: oc_get_machinesets
failed_when: not oc_get_machinesets.stdout

- when: current_replicas_sum != scale
name: Change all {{ machineset_instance_type }} machinesets replicas to have sum {{ scale }}
- name: Change all {{ machineset_instance_type }} machinesets replicas to have sum {{ scale }}
when: current_replicas_sum != scale
block:
- name: Do not downscale any machinesets other than the first one, unless the user used force
block:
Expand Down Expand Up @@ -80,7 +80,8 @@
oc patch machineset -n openshift-machine-api {{ first_machineset }}
--patch '{"spec": {"replicas": {{ scale }} }}' --type merge
- block:
- name: Make sure the machinesets are ready
block:
- name: Wait for all machinesets with type {{ machineset_instance_type }} to be ready
# This is done by verifying that at the availableReplicas

Expand All @@ -91,7 +92,8 @@
# See https://docs.openshift.com/container-platform/4.7/rest_api/machine_apis/machineset-machine-openshift-io-v1beta1.html
# for more information.
# 3. Perform some extra formatting for nicer logging
shell: >-
shell: |
set -o pipefail
oc get machinesets -n openshift-machine-api \
{% if machineset_name | length > 0 %}
"{{ machineset_name }}" -ojson \
Expand All @@ -110,6 +112,12 @@
until: not non_ready_replicas.stdout_lines
retries: 120
delay: 30
args:
executable: /bin/bash

rescue:
- name: Fail because the cluster machineset creation failed
fail: msg="Failing because cluster machineset creation failed"

always:
# info about the 'machines'
Expand Down Expand Up @@ -150,7 +158,4 @@
failed_when: false
loop: "{{ oc_get_machinesets.stdout_lines }}"

rescue:

- name: Fail because the cluster machineset creation failed
fail: msg="Failing because cluster machineset creation failed"
8 changes: 7 additions & 1 deletion roles/codeflare/codeflare_cleanup_appwrappers/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
- name: List all the AppWrappers in the namespace
shell: |
set -o pipefail
oc get appwrappers -n {{ codeflare_cleanup_appwrappers_namespace }} -ojson | jq '.items[] | .metadata.name + " ==> "+ .status.state' -r > "{{ artifact_extra_logs_dir }}/appwrappers.status"
oc get appwrappers -n {{ codeflare_cleanup_appwrappers_namespace }} -oyaml > "{{ artifact_extra_logs_dir }}/appwrappers.yaml"
args:
executable: /bin/bash

- name: Count the AppWrappers in the namespace
shell:
shell: |
set -o pipefail
oc get appwrappers -n {{ codeflare_cleanup_appwrappers_namespace }} -oname | wc -l
args:
executable: /bin/bash

- name: Create a configmap for the beginning of the test timestamp
shell:
Expand Down
5 changes: 4 additions & 1 deletion roles/codeflare/codeflare_generate_mcad_load/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
mode: '0755'

- name: Create the namespace if it does not exist
shell:
shell: |
set -o pipefail
oc create ns "{{ codeflare_generate_mcad_load_namespace }}" -oyaml --dry-run=client | tee "{{ artifact_extra_logs_dir }}/src/namespace.yaml" | oc apply -f-
args:
executable: /bin/bash

- name: Create a configmap for the beginning of the test timestamp
shell:
Expand Down
Loading

0 comments on commit ff9b57e

Please sign in to comment.