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]'
- 'jinja[spacing]'
- 'name[missing]'
- 'yaml[new-line-at-end-of-file]'
- '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 931a4f6 commit 06a3af8
Show file tree
Hide file tree
Showing 37 changed files with 120 additions and 86 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]'
Original file line number Diff line number Diff line change
Expand Up @@ -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 Down
4 changes: 0 additions & 4 deletions roles/cluster/cluster_capture_environment/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion roles/cluster/cluster_create_osd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
ocm edit machinepool
{{ cluster_create_osd_machinepool_name }}
--cluster={{ cluster_create_osd_cluster_name }}
--replicas={{ [2, cluster_create_osd_compute_nodes|int] |max }}
--replicas={{ [2, cluster_create_osd_compute_nodes | int] | max }}

- name: Wait for the desired worker node count
shell: |
Expand Down
8 changes: 4 additions & 4 deletions roles/cluster/cluster_deploy_aws_efs/tasks/aws-efs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@

- name: Populate the tags dict
set_fact:
tags: "{{ tags | default({}) | combine ({ item.key : item.value }) }}"
tags: "{{ tags | default({}) | combine({item.key: item.value}) }}"
with_items:
- { 'key': 'Name' , 'value': '{{ cluster_name_cmd.stdout }}'}
- { 'key': '{{ cluster_name_tag_cmd.stdout }}' , 'value': 'owned'}
- { 'key': 'Purpose', 'value': ''}
- {'key': 'Name' , 'value': '{{ cluster_name_cmd.stdout }}'}
- {'key': '{{ cluster_name_tag_cmd.stdout }}' , 'value': 'owned'}
- {'key': 'Purpose', 'value': ''}

- name: Get the SecurityGroup content
amazon.aws.ec2_group_info:
Expand Down
1 change: 1 addition & 0 deletions roles/cluster/cluster_deploy_ldap/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@

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

Expand Down
31 changes: 17 additions & 14 deletions roles/cluster/cluster_deploy_operator/tasks/main.yml
Original file line number Diff line number Diff line change
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,34 @@
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:
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:
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
1 change: 1 addition & 0 deletions roles/cluster/cluster_ensure_machineset/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: "Check if the cluster already has a {{ machineset_instance_type }} machineset"
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
Expand Down
1 change: 1 addition & 0 deletions roles/cluster/cluster_fill_workernodes/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- name: Get the list of the worker nodes
shell:
set -o pipefail;
oc get nodes
-l{{ cluster_fill_workernodes_label_selector }}
-oname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
echo "- deleting the project $test_project_name ..."
oc delete ns "$test_project_name" >/dev/null
echo "--> project annotation value: $project_annotation_value"
echo "==> expected value: "'{{ cluster_set_project_annotation_value or "null"}}'
[[ "$project_annotation_value" == '{{ cluster_set_project_annotation_value or "null"}}' ]]
echo "==> expected value: "'{{ cluster_set_project_annotation_value or "null" }}'
[[ "$project_annotation_value" == '{{ cluster_set_project_annotation_value or "null" }}' ]]
retries: 120
delay: 5
register: wait_project_template_active
Expand Down
15 changes: 9 additions & 6 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 @@ -92,6 +93,7 @@
# for more information.
# 3. Perform some extra formatting for nicer logging
shell: >-
set -o pipefail;
oc get machinesets -n openshift-machine-api \
{% if machineset_name | length > 0 %}
"{{ machineset_name }}" -ojson \
Expand All @@ -111,6 +113,10 @@
retries: 120
delay: 30

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

always:
# info about the 'machines'
- name: Capture the description of the machines
Expand Down Expand Up @@ -150,7 +156,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"
2 changes: 2 additions & 0 deletions roles/codeflare/codeflare_cleanup_appwrappers/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
- 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"
- name: Count the AppWrappers in the namespace
shell:
set -o pipefail;
oc get appwrappers -n {{ codeflare_cleanup_appwrappers_namespace }} -oname | wc -l

- name: Create a configmap for the beginning of the test timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

- name: Create the namespace if it does not exist
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-

- name: Create a configmap for the beginning of the test timestamp
Expand Down
10 changes: 5 additions & 5 deletions roles/entitlement/entitlement_deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@
- name: "Deploy RHSM from file '{{ entitlement_rhsm }}'"
shell:
set -o pipefail;
cat "{{ entitlement_mc_rhsm }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_RHSM_FILE @"{{ entitlement_rhsm }}"
cat "{{ entitlement_mc_rhsm }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_RHSM_FILE @"{{ entitlement_rhsm }}"
| python3 "{{ entitlement_py_apply }}" MACHINE_CONFIG_ROLE "{{ machine_config_role }}"
| oc apply -f-

- name: "Deploy the pem and key-pem from file '{{ entitlement_pem }}'"
shell:
set -o pipefail;
cat "{{ entitlement_mc_pem }}"
cat "{{ entitlement_mc_pem }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_PEM_FILE @"{{ entitlement_pem }}"
| python3 "{{ entitlement_py_apply }}" MACHINE_CONFIG_ROLE "{{ machine_config_role }}"
| oc apply -f-

- name: "Deploy the repo CA from file '{{ entitlement_mc_rhsm_ca }}' if requested"
when: entitlement_repo_ca | default('', true) | trim != ''
block:
- name: Compute the md5sum of the CA file (debug)
command: md5sum '{{ entitlement_repo_ca }}'

- name: "Deploy the repo CA from file '{{ entitlement_mc_rhsm_ca }}'"
shell:
set -o pipefail;
cat "{{ entitlement_mc_rhsm_ca }}"
cat "{{ entitlement_mc_rhsm_ca }}"
| python3 "{{ entitlement_py_apply }}" BASE64_ENCODED_RHSM_CA_FILE @"{{ entitlement_repo_ca }}"
| python3 "{{ entitlement_py_apply }}" MACHINE_CONFIG_ROLE "{{ machine_config_role }}"
| oc apply -f-
when: entitlement_repo_ca | default('', true) | trim != ''
3 changes: 2 additions & 1 deletion roles/entitlement/entitlement_test_in_cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
- name: Delete the entitlement tester Pod if it exists
command: oc delete --ignore-not-found=true -f "{{ entitlement_tester_pod }}"

- block:
- name: Make sure the entitlement Pod is created
block:
- name: Create the entitlement tester Pod
command: oc create -f "{{ entitlement_tester_pod }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
entitlement_retries: "{{ entitlement_nb_wait_retries }}"
when: entitlement_test_and_wait == 'yes'

- block:
- name: Make sure the entitlement Pod is deployed
block:
- name: Wait for the entitlement Pod to succeed
shell: |
set -o errexit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
retries: 15
delay: 30

- block:
- name: Make sure the GPU Operator ClusterPolicy is ready
block:
- name: Wait for the GPU Operator ClusterPolicy CRD to appear
command: oc get crd clusterpolicies.nvidia.com
register: has_clusterpolicy_crd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
- name: Instantiate the OperatorHub subscription
command: oc create -f "{{ artifact_extra_logs_dir }}/gpu_operator_sub.yml"

- block:
- name: Install the GPU Operator
block:
- name: Find the GPU Operator OperatorHub InstallPlan
command:
oc get InstallPlan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
- name: Get the gpu-operator subscription package name
block:
- name: Count gpu operator subscription candidates
shell: oc get subscription --all-namespaces -ojson | jq '[.items[] | select(.spec.name | test("gpu-operator"))] | length'
shell:
set -o pipefail;
oc get subscription --all-namespaces -ojson | jq '[.items[] | select(.spec.name | test("gpu-operator"))] | length'
register: gpu_subscriptions
failed_when: gpu_subscriptions.stdout != '1'
- name: Read the package name from the first gpu-operator subscription
shell: oc get subscription -A -ojson | jq '[.items[] | select(.spec.name | test("gpu-operator"))][0].spec.name'
shell:
set -o pipefail;
oc get subscription -A -ojson | jq '[.items[] | select(.spec.name | test("gpu-operator"))][0].spec.name'
register: gpu_operator_subscription_package_name
- name: Ensure that there is a CSV for the GPU Operator
command:
Expand Down
7 changes: 5 additions & 2 deletions roles/gpu_operator/gpu_operator_run_gpu_burn/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@
- name: Ensure that no GPU was faulty
loop: "{{ gpu_burn_gpu_nodes.stdout_lines }}"
shell:
set -o pipefail;
oc logs pod/gpu-burn-{{ item }} -n {{ gpu_operator_run_gpu_burn_namespace }} | grep FAULTY
register: gpu_burn_test_faulty
failed_when: gpu_burn_test_faulty.rc == 0

always:
- name: Save the logs of the GPU burn Pods
shell: oc logs pod/gpu-burn-{{ item }} -n {{ gpu_operator_run_gpu_burn_namespace }} | grep -o "[^$(printf '\r')]*$"
shell:
set -o pipefail;
oc logs pod/gpu-burn-{{ item }} -n {{ gpu_operator_run_gpu_burn_namespace }} | grep -o "[^$(printf '\r')]*$"
with_items: "{{ gpu_burn_gpu_nodes.stdout_lines }}"
failed_when: false

Expand All @@ -124,4 +127,4 @@
- name: Delete the src ConfigMap
command: oc --ignore-not-found=true delete configmap gpu-burn-src -n {{ gpu_operator_run_gpu_burn_namespace }}
failed_when: false
when: not gpu_operator_run_gpu_burn_keep_resources
when: not gpu_operator_run_gpu_burn_keep_resources
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
retries: 15
delay: 60

- block:
- name: Wait for the nodes labeling
block:
- name: Wait for the gpu-feature-discovery Pod to label the nodes
command: oc get nodes -l nvidia.com/gpu.count -oname
register: has_gpu_feature_discovery_labels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- block:
- name: Create the GPU operator requirements
block:
- name: Check if the GPU Operator namespace has the openshift.io/cluster-monitoring label
shell:
set -o pipefail;
Expand Down
Loading

0 comments on commit 06a3af8

Please sign in to comment.