Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ospdo adoption ovn adoption #691

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/roles/ovn_adoption/defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@ ovn_nic_mapping_patch: |
ovnController:
nicMappings:
baremetal: baremetal

dpa_dir: "../.."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these variables here?

dpa_tests_dir: "{{ dpa_dir }}/tests"

# ospdo env:
# Whether source env is OSPD Director Operator
# i.e. https://github.com/openstack-k8s-operators/osp-director-operator
ospdo_src: false
# rhoso namespace
rhoso_namespace: "openstack"
# director operator namespace
org_namespace: "openstack"
# adoption repo default location
8 changes: 4 additions & 4 deletions tests/roles/ovn_adoption/handlers/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ansible.builtin.shell: |
{{ shell_header }}
{{ oc_header }}
oc delete pod ovn-copy-data
oc delete certificate ovn-data-cert
oc delete secret ovn-data-cert
{% if storage_reclaim_policy.lower() == "delete" %}oc delete pvc ovn-data{% endif %}
oc delete pod -n {{ org_namespace }} ovn-copy-data
oc delete certificate -n {{ org_namespace }} ovn-data-cert
oc delete secret -n {{ org_namespace }} ovn-data-cert
{% if storage_reclaim_policy.lower() == "delete" %}oc delete pvc -n {{ org_namespace }} ovn-data{% endif %}
25 changes: 16 additions & 9 deletions tests/roles/ovn_adoption/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
retries: 10
delay: 2

- name: execute alternative tasks when source env is ODPdO
ansible.builtin.include_tasks: ovn_ospdo_src_vars.yaml
when: ospdo_src| bool

- name: set OVN copy shell vars
no_log: "{{ use_no_log }}"
ansible.builtin.set_fact:
Expand All @@ -50,6 +54,7 @@
CONTROLLER1_SSH="{{ controller1_ssh }}"
CONTROLLER2_SSH="{{ controller2_ssh }}"
CONTROLLER3_SSH="{{ controller3_ssh }}"
when: not ospdo_src| bool

- name: start an adoption helper pod
ansible.builtin.shell: |-
Expand All @@ -63,7 +68,7 @@
kind: Certificate
metadata:
name: ovn-data-cert
namespace: openstack
namespace: {{ org_namespace }}
spec:
commonName: ovn-data-cert
secretName: ovn-data-cert
Expand All @@ -73,6 +78,7 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: {{ org_namespace }}
name: ovn-data
labels:
app: adoption
Expand All @@ -90,10 +96,11 @@
name: ovn-copy-data
annotations:
openshift.io/scc: anyuid
k8s.v1.cni.cncf.io/networks: internalapi
k8s.v1.cni.cncf.io/networks: {{ copy_pods_custom_networks | default('internalapi') }}
labels:
app: adoption
spec:
{{ copy_pods_custom_spec|default('') }}
containers:
- image: $OVSDB_IMAGE
command: [ "sh", "-c", "sleep infinity"]
Expand Down Expand Up @@ -126,7 +133,7 @@
ansible.builtin.shell: |
{{ shell_header }}
{{ oc_header }}
oc wait --for condition=Ready pod/ovn-copy-data --timeout=30s
oc wait --for condition=Ready -n {{ org_namespace }} pod/ovn-copy-data --timeout=30s
register: ovn_data_pod_result
until: ovn_data_pod_result is success
retries: 2
Expand Down Expand Up @@ -168,8 +175,8 @@
{{ oc_header }}
{{ ovn_copy_shell_vars }}

oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db"
oc exec ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6641 > /backup/ovs-nb.db"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client backup tcp:$SOURCE_OVSDB_IP:6642 > /backup/ovs-sb.db"
when: enable_tlse|bool is false

- name: dump OVN databases using ssl connection
Expand All @@ -190,8 +197,8 @@
{{ oc_header }}
{{ ovn_copy_shell_vars }}

oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema"
oc exec ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_NB_IP:6641 > /backup/ovs-nb.ovsschema && ovsdb-tool convert /backup/ovs-nb.db /backup/ovs-nb.ovsschema"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client get-schema tcp:$PODIFIED_OVSDB_SB_IP:6642 > /backup/ovs-sb.ovsschema && ovsdb-tool convert /backup/ovs-sb.db /backup/ovs-sb.ovsschema"
when: enable_tlse|bool is false

- name: upgrade OVN databases to the latest schema from podified ovsdb-servers (tls)
Expand Down Expand Up @@ -223,8 +230,8 @@
{{ oc_header }}
{{ ovn_copy_shell_vars }}

oc exec ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
oc exec ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_NB_IP:6641 < /backup/ovs-nb.db"
oc exec -n {{ org_namespace }} ovn-copy-data -- bash -c "ovsdb-client restore --ca-cert=/etc/pki/tls/misc/ca.crt --private-key=/etc/pki/tls/misc/tls.key --certificate=/etc/pki/tls/misc/tls.crt ssl:$PODIFIED_OVSDB_SB_IP:6642 < /backup/ovs-sb.db"
when: enable_tlse|bool

- name: deploy podified OVN northd service to keep databases in sync
Expand Down
46 changes: 46 additions & 0 deletions tests/roles/ovn_adoption/tasks/ovn_ospdo_src_vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- name: get ospdo source_ovndb_ip
ansible.builtin.shell: |
oc -n {{ org_namespace }} get cm tripleo-exports-default -o yaml | awk '/ovn_dbs_node_ips:/{getline; print $3}'|tr -d '\\n'
register: source_ovndb_ip_str

- name: register controller node
no_log: "{{ use_no_log }}"
ansible.builtin.shell: |
oc get vmi -n{{ org_namespace }} -o jsonpath='{.items[0].metadata.labels.kubevirt\.io/nodeName}'
register: controller_node

- name: get OSPdO storage storageClass
ansible.builtin.shell: |
oc get -n {{ org_namespace }} pvc openstackclient-hosts -o jsonpath='{.spec.storageClassName}'
register: ospdo_storage_class

- name: set OVN copy shell vars
no_log: "{{ use_no_log }}"
ansible.builtin.set_fact:
ovn_copy_shell_vars: |
STORAGE_CLASS={{ ospdo_storage_class.stdout }}
PODIFIED_OVSDB_NB_IP={{ podified_ovn_nb_ip_result.stdout }}
PODIFIED_OVSDB_SB_IP={{ podified_ovn_sb_ip_result.stdout }}
OVSDB_IMAGE={{ ovn_image }}

SOURCE_OVSDB_IP={{ source_ovndb_ip_str.stdout }}

CONTROLLER1_SSH="{{ controller1_ssh }}"
CONTROLLER2_SSH="echo ospdo src env, skipping on controller-1 "
CONTROLLER3_SSH="echo ospdo src env ,skipping on controller-2 "

- name: create ovn-data-cert secret
ansible.builtin.shell: |
oc apply -f - <<EOF
---
apiVersion: v1
kind: Secret
metadata:
name: ovn-data-cert
namespace: {{ org_namespace }}
type: Opaque
EOF

- name: set default NS to {{ rhoso_namespace }}
ansible.builtin.shell: |
oc project {{ rhoso_namespace }}
Loading