diff --git a/ci/playbooks/enable-lightspeed-metrics.yml b/ci/playbooks/enable-lightspeed-metrics.yml new file mode 100644 index 0000000..76622ed --- /dev/null +++ b/ci/playbooks/enable-lightspeed-metrics.yml @@ -0,0 +1,66 @@ +--- +- name: Enable OpenStack Lightspeed metrics collection + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" + connection: local + gather_facts: false + vars: + telemetry_namespace: "{{ cifmw_openstack_namespace | default(cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack')) }}" + lightspeed_namespace: "{{ cifmw_openstack_lightspeed_namespace | default('openstack-lightspeed') }}" + lightspeed_metrics_target: "lightspeed-app-server.{{ lightspeed_namespace }}.svc:8443" + environment: + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" + tasks: + # Configure the owning control plane after Lightspeed is ready. + # Lightspeed Service creation does not trigger MetricStorage reconciliation. + # See docs/development.md#telemetry-metrics-discovery. + - name: Enable metric storage in the OpenStack control plane + kubernetes.core.k8s: + state: present + merge_type: merge + definition: + apiVersion: core.openstack.org/v1beta1 + kind: OpenStackControlPlane + metadata: + name: controlplane + namespace: "{{ telemetry_namespace }}" + spec: + telemetry: + enabled: true + template: + metricStorage: + enabled: true + openStackLightspeedNamespace: "{{ lightspeed_namespace }}" + monitoringStack: + alertingEnabled: false + storage: + # CI only needs metrics for the lifetime of this job. + strategy: ephemeral + + - name: Wait for metric storage to be ready + kubernetes.core.k8s_info: + api_version: telemetry.openstack.org/v1beta1 + kind: MetricStorage + name: metric-storage + namespace: "{{ telemetry_namespace }}" + wait: true + wait_condition: + type: Ready + status: "True" + wait_timeout: 600 + register: metric_storage + failed_when: metric_storage is failed or metric_storage.resources | default([]) | length == 0 + + - name: Wait for telemetry to discover the Lightspeed metrics service + kubernetes.core.k8s_info: + api_version: monitoring.rhobs/v1alpha1 + kind: ScrapeConfig + name: telemetry-openstack-lightspeed + namespace: "{{ telemetry_namespace }}" + register: lightspeed_scrape_config + until: + - lightspeed_scrape_config.resources | default([]) | length == 1 + - >- + lightspeed_metrics_target in (lightspeed_scrape_config.resources[0].spec.staticConfigs + | map(attribute='targets') | flatten) + retries: 30 + delay: 10 diff --git a/ci/playbooks/install-openstack-lightspeed.yml b/ci/playbooks/install-openstack-lightspeed.yml index f8fc70a..0274811 100644 --- a/ci/playbooks/install-openstack-lightspeed.yml +++ b/ci/playbooks/install-openstack-lightspeed.yml @@ -483,7 +483,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: "lightspeed-access-{{ cifmw_test_operator_namespace | default('openstack') }}" + name: "lightspeed-tests-access-{{ cifmw_test_operator_namespace | default('openstack') }}" roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/ci/vars-lightspeed.yml b/ci/vars-lightspeed.yml index e856970..e8e714b 100644 --- a/ci/vars-lightspeed.yml +++ b/ci/vars-lightspeed.yml @@ -5,3 +5,6 @@ pre_tests_01_deploy_lightspeed_operator: pre_tests_02_deploy_openstack_assistant: source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/lightspeed-operator'].src_dir }}/ci/playbooks/deploy-openstack-assistant.yml" type: playbook +pre_tests_03_enable_lightspeed_metrics: + source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/openstack-k8s-operators/lightspeed-operator'].src_dir }}/ci/playbooks/enable-lightspeed-metrics.yml" + type: playbook diff --git a/docs/development.md b/docs/development.md index 08fad12..c597be3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -23,6 +23,29 @@ cd ../.. `PULL_SECRET` is the same pull secret described in the [installation guide](install_guide.md#access-to-registry-images). +## Telemetry metrics discovery + +For new deployments collecting metrics through telemetry-operator, wait for +`OpenStackLightspeed` to become `Ready` before enabling `MetricStorage` through +the `OpenStackControlPlane`. The CRC CI job uses this order so that the +`lightspeed-app-server` service exists when telemetry first discovers scrape +targets. + +Telemetry currently discovers Lightspeed during `MetricStorage` reconciliation, +using `spec.openStackLightspeedNamespace` to locate its metrics service. The +service watch does not handle Lightspeed service events or map them to +`MetricStorage` resources in another namespace. If `MetricStorage` has already +reconciled before Lightspeed is installed, creating the service alone does not +trigger discovery. Another reconciliation, caused by an update to `MetricStorage` +or another watched resource, can discover it later. Until then, the +`telemetry-openstack-lightspeed` scrape configuration may be absent even when +`MetricStorage` reports `Ready`. + +A future improvement in telemetry-operator would be to watch Lightspeed metrics +service events and reconcile the `MetricStorage` resources whose +`spec.openStackLightspeedNamespace` matches the service's namespace. This would +allow discovery regardless of installation order. + ## Releasing to the community catalog The **Propose community operator release** GitHub Actions workflow uses diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 6766879..d03201b 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -20,6 +20,8 @@ - name: ci/playbooks/cleanup_lightspeed_secret.yml cleanup: true vars: + # MetricStorage is managed by telemetry-operator and requires COO. + cifmw_deploy_obs: true cifmw_extras: - '@scenarios/centos-9/multinode-ci.yml' - '@scenarios/centos-9/hci_ceph_backends.yml' @@ -37,8 +39,9 @@ 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: "" + # debug only, switch back to openstack-k8s-operators/lightspeed-tests + cifmw_test_operator_ansibletest_ansible_git_repo: https://github.com/jancervenka/lightspeed-tests + cifmw_test_operator_ansibletest_ansible_git_branch: telemetry-e2e-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 @@ -88,7 +91,9 @@ 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" + pytest_args: "-v --tb=short --color=no -m 'not llm_dependent' -k 'integration or e2e'" + 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 cifmw_test_operator_ansibletest_extra_mounts: - name: lightspeed @@ -102,10 +107,19 @@ - serviceAccountToken: path: token expirationSeconds: 3600 + - name: prometheus-ca + secret: + secretName: combined-ca-bundle + items: + - key: tls-ca-bundle.pem + path: ca.crt mounts: - name: lightspeed-client-token mountPath: /var/run/secrets/kubernetes.io/serviceaccount readOnly: true + - name: prometheus-ca + mountPath: /var/run/secrets/prometheus + readOnly: true # Fake LLM only; real-provider credentials are a follow-up. cifmw_openstack_lightspeed_mock_enabled: true