diff --git a/ci/playbooks/inject-ssh-key.yml b/ci/playbooks/inject-ssh-key.yml new file mode 100644 index 0000000..8956257 --- /dev/null +++ b/ci/playbooks/inject-ssh-key.yml @@ -0,0 +1,40 @@ +--- +# Copyright Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# Add lpiwowar's public SSH keys (fetched from GitHub) to every node of the +# job so that a Zuul autohold request can keep a failed node alive and it can +# be debugged over SSH, as demonstrated in [1]. +# +# NOTE: this playbook must remain LAST in the job's pre-run list. +# create_lightspeed_secret.yml replaces authorized_keys with the job's +# automation keys only and would drop any key added before it. +# +# [1] https://github.com/openstack-k8s-operators/lightspeed-operator/pull/69 +- name: Inject lpiwowar public SSH keys for autohold debugging + hosts: all + gather_facts: false + tasks: + - name: Fetch lpiwowar public SSH keys from GitHub + ansible.builtin.uri: + url: https://github.com/lpiwowar.keys + return_content: true + register: lpiwowar_pubkeys + + - name: Add lpiwowar public SSH keys to authorized_keys + ansible.posix.authorized_key: + user: "{{ ansible_user }}" + key: "{{ lpiwowar_pubkeys.content }}" + state: present diff --git a/ci/playbooks/install-openstack-lightspeed.yml b/ci/playbooks/install-openstack-lightspeed.yml index 0274811..9d9d167 100644 --- a/ci/playbooks/install-openstack-lightspeed.yml +++ b/ci/playbooks/install-openstack-lightspeed.yml @@ -494,6 +494,42 @@ name: "{{ openstack_lightspeed_ansibletest_service_account }}" namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" + - name: Authorize the test Pod to exec into the openstack-assistant Pod + when: openstack_assistant_enabled | default(false) | bool + kubernetes.core.k8s: + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: ClusterRole + metadata: + name: lightspeed-tests-assistant-exec + rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list"] + - apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create", "get"] + + - name: Bind the exec permissions to the test-operator ServiceAccount + when: openstack_assistant_enabled | default(false) | bool + kubernetes.core.k8s: + state: present + definition: + apiVersion: rbac.authorization.k8s.io/v1 + kind: RoleBinding + metadata: + name: lightspeed-tests-assistant-exec + namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: lightspeed-tests-assistant-exec + subjects: + - kind: ServiceAccount + name: "{{ openstack_lightspeed_ansibletest_service_account }}" + namespace: "{{ cifmw_test_operator_namespace | default('openstack') }}" + - name: Create test-operator dummy config ConfigMap kubernetes.core.k8s: state: present diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 83b7e72..056c368 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -14,7 +14,12 @@ - name: openai_credentials secret: lightspeed-openai-token # Creates the token Secret in-cluster before the run (see playbook header). - pre-run: ci/playbooks/create_lightspeed_secret.yml + # The SSH key injection must stay last: create_lightspeed_secret.yml + # replaces authorized_keys with the automation keys only and would drop + # any key added before it. + pre-run: + - ci/playbooks/create_lightspeed_secret.yml + - ci/playbooks/inject-ssh-key.yml # cleanup: true so Zuul still attempts the delete when the job is canceled. post-run: - name: ci/playbooks/cleanup_lightspeed_secret.yml @@ -39,8 +44,10 @@ cifmw_test_operator_ansibletest_name: ansibletest cifmw_test_operator_ansibletest_image: quay.io/podified-antelope-centos9/openstack-ansible-tests cifmw_test_operator_ansibletest_image_tag: current-podified - cifmw_test_operator_ansibletest_ansible_git_repo: https://github.com/openstack-k8s-operators/lightspeed-tests - cifmw_test_operator_ansibletest_ansible_git_branch: "" + # TODO(lpiwowar): switch back to openstack-k8s-operators/lightspeed-tests + # (default branch) once feature/openstack-assistant-test merges upstream. + cifmw_test_operator_ansibletest_ansible_git_repo: https://github.com/lpiwowar/lightspeed-tests + cifmw_test_operator_ansibletest_ansible_git_branch: feature/openstack-assistant-test cifmw_test_operator_ansibletest_ansible_playbook_path: playbooks/run_lightspeed_tests.yaml cifmw_test_operator_ansibletest_ansible_inventory: | localhost ansible_connection=local ansible_python_interpreter=python3 @@ -90,7 +97,7 @@ lightspeed_url: "https://lightspeed-app-server.{{ cifmw_openstack_lightspeed_namespace | default('openstack-lightspeed') }}.svc.cluster.local:8443" lightspeed_timeout: 120 lightspeed_model: "provider-default-model/default-model" - pytest_args: "-v --tb=short --color=no -m 'not llm_dependent' -k 'integration or e2e'" + pytest_args: "-v --tb=short --color=no -m 'not llm_dependent' -k 'integration or e2e' --runxfail" prometheus_url: "https://metric-storage-prometheus.{{ cifmw_openstack_namespace | default('openstack') }}.svc:9090" prometheus_ca_cert_path: /var/run/secrets/prometheus/ca.crt junit_xml_path: /var/lib/AnsibleTests/external_files/lightspeed-tests/junit.xml @@ -106,6 +113,11 @@ - serviceAccountToken: path: token expirationSeconds: 3600 + - configMap: + name: kube-root-ca.crt + items: + - key: ca.crt + path: ca.crt - name: prometheus-ca secret: secretName: combined-ca-bundle