From 03d1e424af3026f4adb87bc41488e86d4377d741 Mon Sep 17 00:00:00 2001 From: Omer Date: Mon, 15 Jul 2024 14:59:36 +0000 Subject: [PATCH 1/2] Rename backendType varialbe from None So far backendType was mistakenly added as "None", amd wasn't changed during runtime. This patch renames it to backendType. --- ...designate.openstack.org_designateapis.yaml | 10 +-- ....openstack.org_designatebackendbind9s.yaml | 10 +-- ...gnate.openstack.org_designatecentrals.yaml | 10 +-- ...signate.openstack.org_designatemdnses.yaml | 10 +-- ...nate.openstack.org_designateproducers.yaml | 10 +-- .../designate.openstack.org_designates.yaml | 70 +++++++++---------- ...ignate.openstack.org_designateworkers.yaml | 10 +-- api/v1beta1/common_types.go | 2 +- api/v1beta1/designate_types.go | 2 +- ...designate.openstack.org_designateapis.yaml | 10 +-- ....openstack.org_designatebackendbind9s.yaml | 10 +-- ...gnate.openstack.org_designatecentrals.yaml | 10 +-- ...signate.openstack.org_designatemdnses.yaml | 10 +-- ...nate.openstack.org_designateproducers.yaml | 10 +-- .../designate.openstack.org_designates.yaml | 70 +++++++++---------- ...ignate.openstack.org_designateworkers.yaml | 10 +-- 16 files changed, 132 insertions(+), 132 deletions(-) diff --git a/api/bases/designate.openstack.org_designateapis.yaml b/api/bases/designate.openstack.org_designateapis.yaml index 4b47556c..03471b94 100644 --- a/api/bases/designate.openstack.org_designateapis.yaml +++ b/api/bases/designate.openstack.org_designateapis.yaml @@ -48,17 +48,17 @@ spec: spec: description: DesignateAPISpec defines the desired state of DesignateAPI properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/bases/designate.openstack.org_designatebackendbind9s.yaml b/api/bases/designate.openstack.org_designatebackendbind9s.yaml index d2ab4979..06f22a72 100644 --- a/api/bases/designate.openstack.org_designatebackendbind9s.yaml +++ b/api/bases/designate.openstack.org_designatebackendbind9s.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateBackendbind9Spec defines the desired state of DesignateBackendbind9 properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/bases/designate.openstack.org_designatecentrals.yaml b/api/bases/designate.openstack.org_designatecentrals.yaml index 6e7e71d0..66fae3a8 100644 --- a/api/bases/designate.openstack.org_designatecentrals.yaml +++ b/api/bases/designate.openstack.org_designatecentrals.yaml @@ -49,17 +49,17 @@ spec: description: DesignateCentralSpec defines the input parameters for the Designate Central service properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/bases/designate.openstack.org_designatemdnses.yaml b/api/bases/designate.openstack.org_designatemdnses.yaml index 5150402b..c5b39f0a 100644 --- a/api/bases/designate.openstack.org_designatemdnses.yaml +++ b/api/bases/designate.openstack.org_designatemdnses.yaml @@ -49,17 +49,17 @@ spec: description: DesignateMdnsSpec defines the input parameters for the Designate Mdns service properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/bases/designate.openstack.org_designateproducers.yaml b/api/bases/designate.openstack.org_designateproducers.yaml index db177559..fab6f0da 100644 --- a/api/bases/designate.openstack.org_designateproducers.yaml +++ b/api/bases/designate.openstack.org_designateproducers.yaml @@ -48,17 +48,17 @@ spec: spec: description: DesignateProducerSpec the desired state of DesignateProducer properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/bases/designate.openstack.org_designates.yaml b/api/bases/designate.openstack.org_designates.yaml index 549a6128..2e73508d 100644 --- a/api/bases/designate.openstack.org_designates.yaml +++ b/api/bases/designate.openstack.org_designates.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateAPISpec defines the desired state of DesignateAPI properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the @@ -91,17 +91,17 @@ spec: description: DesignateAPI - Spec definition for the API service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -431,17 +431,17 @@ spec: description: DesignateBackendbind9 - Spec definition for the Backendbind9 service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -589,17 +589,17 @@ spec: description: DesignateCentral - Spec definition for the Central service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -747,17 +747,17 @@ spec: description: DesignateMdns - Spec definition for the Mdns service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -905,17 +905,17 @@ spec: description: DesignateProducer - Spec definition for the Producer service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -1172,17 +1172,17 @@ spec: description: DesignateWorker - Spec definition for the Worker service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from diff --git a/api/bases/designate.openstack.org_designateworkers.yaml b/api/bases/designate.openstack.org_designateworkers.yaml index 9cc02078..e0cc97e6 100644 --- a/api/bases/designate.openstack.org_designateworkers.yaml +++ b/api/bases/designate.openstack.org_designateworkers.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateWorkerSpec the desired state of DesignateWorker properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index 4ef8a994..72e67cc0 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -64,7 +64,7 @@ type DesignateTemplate struct { // +kubebuilder:validation:Optional // BackendType - Defines the backend service/configuration we are using, i.e. bind9, PowerDNS, BYO, etc.. // Helps maintain a single init container/init.sh to do container setup - BackendType string `json:"None"` + BackendType string `json:"backendType"` // +kubebuilder:validation:Optional // BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & diff --git a/api/v1beta1/designate_types.go b/api/v1beta1/designate_types.go index b288e7b4..832c8589 100644 --- a/api/v1beta1/designate_types.go +++ b/api/v1beta1/designate_types.go @@ -140,7 +140,7 @@ type DesignateSpecBase struct { // +kubebuilder:validation:Optional // BackendType - Defines the backend service/configuration we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. // Helps maintain a single init container/init.sh to do container setup - BackendType string `json:"None"` + BackendType string `json:"backendType"` // +kubebuilder:validation:Optional // BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & diff --git a/config/crd/bases/designate.openstack.org_designateapis.yaml b/config/crd/bases/designate.openstack.org_designateapis.yaml index 4b47556c..03471b94 100644 --- a/config/crd/bases/designate.openstack.org_designateapis.yaml +++ b/config/crd/bases/designate.openstack.org_designateapis.yaml @@ -48,17 +48,17 @@ spec: spec: description: DesignateAPISpec defines the desired state of DesignateAPI properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/config/crd/bases/designate.openstack.org_designatebackendbind9s.yaml b/config/crd/bases/designate.openstack.org_designatebackendbind9s.yaml index d2ab4979..06f22a72 100644 --- a/config/crd/bases/designate.openstack.org_designatebackendbind9s.yaml +++ b/config/crd/bases/designate.openstack.org_designatebackendbind9s.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateBackendbind9Spec defines the desired state of DesignateBackendbind9 properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/config/crd/bases/designate.openstack.org_designatecentrals.yaml b/config/crd/bases/designate.openstack.org_designatecentrals.yaml index 6e7e71d0..66fae3a8 100644 --- a/config/crd/bases/designate.openstack.org_designatecentrals.yaml +++ b/config/crd/bases/designate.openstack.org_designatecentrals.yaml @@ -49,17 +49,17 @@ spec: description: DesignateCentralSpec defines the input parameters for the Designate Central service properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/config/crd/bases/designate.openstack.org_designatemdnses.yaml b/config/crd/bases/designate.openstack.org_designatemdnses.yaml index 5150402b..c5b39f0a 100644 --- a/config/crd/bases/designate.openstack.org_designatemdnses.yaml +++ b/config/crd/bases/designate.openstack.org_designatemdnses.yaml @@ -49,17 +49,17 @@ spec: description: DesignateMdnsSpec defines the input parameters for the Designate Mdns service properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/config/crd/bases/designate.openstack.org_designateproducers.yaml b/config/crd/bases/designate.openstack.org_designateproducers.yaml index db177559..fab6f0da 100644 --- a/config/crd/bases/designate.openstack.org_designateproducers.yaml +++ b/config/crd/bases/designate.openstack.org_designateproducers.yaml @@ -48,17 +48,17 @@ spec: spec: description: DesignateProducerSpec the desired state of DesignateProducer properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the diff --git a/config/crd/bases/designate.openstack.org_designates.yaml b/config/crd/bases/designate.openstack.org_designates.yaml index 549a6128..2e73508d 100644 --- a/config/crd/bases/designate.openstack.org_designates.yaml +++ b/config/crd/bases/designate.openstack.org_designates.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateAPISpec defines the desired state of DesignateAPI properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the @@ -91,17 +91,17 @@ spec: description: DesignateAPI - Spec definition for the API service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -431,17 +431,17 @@ spec: description: DesignateBackendbind9 - Spec definition for the Backendbind9 service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -589,17 +589,17 @@ spec: description: DesignateCentral - Spec definition for the Central service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -747,17 +747,17 @@ spec: description: DesignateMdns - Spec definition for the Mdns service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -905,17 +905,17 @@ spec: description: DesignateProducer - Spec definition for the Producer service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from @@ -1172,17 +1172,17 @@ spec: description: DesignateWorker - Spec definition for the Worker service of this Designate deployment properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain - a single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain + a single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from diff --git a/config/crd/bases/designate.openstack.org_designateworkers.yaml b/config/crd/bases/designate.openstack.org_designateworkers.yaml index 9cc02078..e0cc97e6 100644 --- a/config/crd/bases/designate.openstack.org_designateworkers.yaml +++ b/config/crd/bases/designate.openstack.org_designateworkers.yaml @@ -44,17 +44,17 @@ spec: spec: description: DesignateWorkerSpec the desired state of DesignateWorker properties: - None: - description: BackendType - Defines the backend service/configuration - we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a - single init container/init.sh to do container setup - type: string backendMdnsServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the DNS server. Acceptable values are: "UDP", "TCP" Please Note: this MUST match what is in the /etc/designate.conf [''service:mdns'']' type: string + backendType: + description: BackendType - Defines the backend service/configuration + we are using, i.e. bind9, PowerDNS, BYO, etc.. Helps maintain a + single init container/init.sh to do container setup + type: string backendWorkerServerProtocol: description: 'BackendTypeProtocol - Defines the backend protocol to be used between the designate-worker & designate_mdns to/from the From 08563d189f6230cc4473a295447bc570921eac76 Mon Sep 17 00:00:00 2001 From: Omer Date: Wed, 17 Jul 2024 08:21:15 +0000 Subject: [PATCH 2/2] Use MariaDB account and secret in Designate controllers So far, MariaDB account and secret were added to specs and types, and were used in designate_controller.go, but weren't used in the rest of the controllers. This patch uses MariaDB in the rest of the controllers. --- .../designate.openstack.org_designates.yaml | 3 +- api/v1beta1/designate_types.go | 9 +- .../designate.openstack.org_designates.yaml | 3 +- .../samples/designate_v1beta1_designate.yaml | 50 +++ ...esignate_v1beta1_designate_with_bind9.yaml | 13 - .../designate_v1beta1_designateapi.yaml | 6 - ...signate_v1beta1_designatebackendbind9.yaml | 6 - .../designate_v1beta1_designatecentral.yaml | 6 - .../designate_v1beta1_designatemdns.yaml | 6 - .../designate_v1beta1_designateproducer.yaml | 6 - .../designate_v1beta1_designateunbound.yaml | 6 - .../designate_v1beta1_designateworker.yaml | 6 - config/samples/kustomization.yaml | 7 - controllers/designate_controller.go | 359 ++++++++++-------- controllers/designateapi_controller.go | 50 ++- .../designatebackendbind9_controller.go | 50 ++- controllers/designatecentral_controller.go | 50 ++- controllers/designatemdns_controller.go | 50 ++- controllers/designateproducer_controller.go | 50 ++- controllers/designateunbound_controller.go | 10 + controllers/designateworker_controller.go | 50 ++- pkg/designate/const.go | 7 + pkg/designateapi/deployment.go | 6 - pkg/designatebackendbind9/deployment.go | 50 --- pkg/designatecentral/deployment.go | 6 - pkg/designatemdns/deployment.go | 6 - pkg/designateproducer/deployment.go | 6 - pkg/designateworker/deployment.go | 6 - 28 files changed, 529 insertions(+), 354 deletions(-) delete mode 100644 config/samples/designate_v1beta1_designate_with_bind9.yaml delete mode 100644 config/samples/designate_v1beta1_designateapi.yaml delete mode 100644 config/samples/designate_v1beta1_designatebackendbind9.yaml delete mode 100644 config/samples/designate_v1beta1_designatecentral.yaml delete mode 100644 config/samples/designate_v1beta1_designatemdns.yaml delete mode 100644 config/samples/designate_v1beta1_designateproducer.yaml delete mode 100644 config/samples/designate_v1beta1_designateunbound.yaml delete mode 100644 config/samples/designate_v1beta1_designateworker.yaml diff --git a/api/bases/designate.openstack.org_designates.yaml b/api/bases/designate.openstack.org_designates.yaml index 2e73508d..6344b9bc 100644 --- a/api/bases/designate.openstack.org_designates.yaml +++ b/api/bases/designate.openstack.org_designates.yaml @@ -1413,6 +1413,7 @@ spec: to register in designate type: string required: + - databaseInstance - designateAPI - designateBackendbind9 - designateCentral @@ -1474,7 +1475,7 @@ spec: type: object type: array databaseHostname: - description: Designate Database Hostname + description: DatabaseHostname - Designate Database Hostname type: string designateAPIReadyCount: description: ReadyCount of Designate API instance diff --git a/api/v1beta1/designate_types.go b/api/v1beta1/designate_types.go index 832c8589..85758650 100644 --- a/api/v1beta1/designate_types.go +++ b/api/v1beta1/designate_types.go @@ -107,10 +107,6 @@ type DesignateSpecBase struct { // ServiceUser - optional username used for this service to register in designate ServiceUser string `json:"serviceUser"` - // +kubebuilder:validation:Optional - // DatabaseHostname - Designate Database Hostname - // DatabaseHostname string `json:"databaseHostname,omitempty"` - // +kubebuilder:validation:Required // MariaDB instance name // Right now required by the maridb-operator to get the credentials from the instance to create the DB @@ -135,7 +131,7 @@ type DesignateSpecBase struct { // +kubebuilder:validation:Optional // +kubebuilder:default={service: DesignatePassword} // PasswordSelectors - Selectors to identify the DB and AdminUser password from the Secret - PasswordSelectors PasswordSelector `json:"passwordSelectors,omitempty"` + PasswordSelectors PasswordSelector `json:"passwordSelectors"` // +kubebuilder:validation:Optional // BackendType - Defines the backend service/configuration we are using, i.e. bind9, unhbound, PowerDNS, BYO, etc.. @@ -193,7 +189,8 @@ type DesignateStatus struct { // Conditions Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"` - // Designate Database Hostname + // +kubebuilder:validation:Optional + // DatabaseHostname - Designate Database Hostname DatabaseHostname string `json:"databaseHostname,omitempty"` // TransportURLSecret - Secret containing RabbitMQ transportURL diff --git a/config/crd/bases/designate.openstack.org_designates.yaml b/config/crd/bases/designate.openstack.org_designates.yaml index 2e73508d..6344b9bc 100644 --- a/config/crd/bases/designate.openstack.org_designates.yaml +++ b/config/crd/bases/designate.openstack.org_designates.yaml @@ -1413,6 +1413,7 @@ spec: to register in designate type: string required: + - databaseInstance - designateAPI - designateBackendbind9 - designateCentral @@ -1474,7 +1475,7 @@ spec: type: object type: array databaseHostname: - description: Designate Database Hostname + description: DatabaseHostname - Designate Database Hostname type: string designateAPIReadyCount: description: ReadyCount of Designate API instance diff --git a/config/samples/designate_v1beta1_designate.yaml b/config/samples/designate_v1beta1_designate.yaml index 876b936e..86023e9b 100644 --- a/config/samples/designate_v1beta1_designate.yaml +++ b/config/samples/designate_v1beta1_designate.yaml @@ -11,3 +11,53 @@ spec: databaseInstance: openstack databaseAccount: designate rabbitMqClusterName: rabbitmq + designateAPI: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateBackendbind9: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateCentral: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateMdns: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateProducer: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateWorker: + secret: osp-secret + serviceUser: designate + customServiceConfig: | + [DEFAULT] + debug = true + databaseAccount: designate + rabbitMqClusterName: rabbitmq + designateUnbound: + replicas: 1 diff --git a/config/samples/designate_v1beta1_designate_with_bind9.yaml b/config/samples/designate_v1beta1_designate_with_bind9.yaml deleted file mode 100644 index 876b936e..00000000 --- a/config/samples/designate_v1beta1_designate_with_bind9.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: Designate -metadata: - name: designate -spec: - secret: osp-secret - serviceUser: designate - customServiceConfig: | - [DEFAULT] - debug = true - databaseInstance: openstack - databaseAccount: designate - rabbitMqClusterName: rabbitmq diff --git a/config/samples/designate_v1beta1_designateapi.yaml b/config/samples/designate_v1beta1_designateapi.yaml deleted file mode 100644 index 9e657c08..00000000 --- a/config/samples/designate_v1beta1_designateapi.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateAPI -metadata: - name: designateapi -spec: - # TODO(user): Add fields here diff --git a/config/samples/designate_v1beta1_designatebackendbind9.yaml b/config/samples/designate_v1beta1_designatebackendbind9.yaml deleted file mode 100644 index dec718d4..00000000 --- a/config/samples/designate_v1beta1_designatebackendbind9.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateBackendbind9 -metadata: - name: designatebackendbind9 -spec: - # TODO(user): Add fields here diff --git a/config/samples/designate_v1beta1_designatecentral.yaml b/config/samples/designate_v1beta1_designatecentral.yaml deleted file mode 100644 index 3ff0abbb..00000000 --- a/config/samples/designate_v1beta1_designatecentral.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateCentral -metadata: - name: designatecentral -spec: - # TODO(user): Add fields here diff --git a/config/samples/designate_v1beta1_designatemdns.yaml b/config/samples/designate_v1beta1_designatemdns.yaml deleted file mode 100644 index 65769d3b..00000000 --- a/config/samples/designate_v1beta1_designatemdns.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateMdns -metadata: - name: designate-mdns -spec: - # TODO(user): Add fields here diff --git a/config/samples/designate_v1beta1_designateproducer.yaml b/config/samples/designate_v1beta1_designateproducer.yaml deleted file mode 100644 index 5c1037ff..00000000 --- a/config/samples/designate_v1beta1_designateproducer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateProducer -metadata: - name: designate-producer -spec: - # TODO(user): Add fields here diff --git a/config/samples/designate_v1beta1_designateunbound.yaml b/config/samples/designate_v1beta1_designateunbound.yaml deleted file mode 100644 index 6139e47f..00000000 --- a/config/samples/designate_v1beta1_designateunbound.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateUnbound -metadata: - name: designate-unbound -spec: - replicas: 1 diff --git a/config/samples/designate_v1beta1_designateworker.yaml b/config/samples/designate_v1beta1_designateworker.yaml deleted file mode 100644 index 5ec1b45c..00000000 --- a/config/samples/designate_v1beta1_designateworker.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: designate.openstack.org/v1beta1 -kind: DesignateWorker -metadata: - name: designate-worker -spec: - # TODO(user): Add fields here diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 5b89c501..9774a280 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,11 +1,4 @@ ## Append samples you want in your CSV to this file as resources ## resources: - designate_v1beta1_designate.yaml -- designate_v1beta1_designateapi.yaml -- designate_v1beta1_designatecentral.yaml -- designate_v1beta1_designateproducer.yaml -- designate_v1beta1_designateworker.yaml -- designate_v1beta1_designatemdns.yaml -- designate_v1beta1_designatebackendbind9.yaml -- designate_v1beta1_designateunbound.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/controllers/designate_controller.go b/controllers/designate_controller.go index e0894c96..e7fb54a8 100644 --- a/controllers/designate_controller.go +++ b/controllers/designate_controller.go @@ -45,7 +45,7 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/labels" nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" - "github.com/openstack-k8s-operators/lib-common/modules/common/secret" + oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" @@ -302,13 +302,13 @@ func (r *DesignateReconciler) reconcileDelete(ctx context.Context, instance *des Log.Info(fmt.Sprintf("Reconciling Service '%s' delete", instance.Name)) // remove db finalizer first - db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, helper, instance.Name, instance.Spec.DatabaseAccount, instance.Namespace) + designateDb, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, helper, designate.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace) if err != nil && !k8s_errors.IsNotFound(err) { return ctrl.Result{}, err } if !k8s_errors.IsNotFound(err) { - if err := db.DeleteFinalizer(ctx, helper); err != nil { + if err := designateDb.DeleteFinalizer(ctx, helper); err != nil { return ctrl.Result{}, err } } @@ -334,59 +334,96 @@ func (r *DesignateReconciler) reconcileInit( Log.Info(fmt.Sprintf("Reconciling Service '%s' init", instance.Name)) + // ConfigMap + configMapVars := make(map[string]env.Setter) + // - // create service DB instance + // check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map // - db := mariadbv1.NewDatabaseForAccount( - instance.Spec.DatabaseInstance, // mariadb/galera service to target - instance.Name, // name used in CREATE DATABASE in mariadb - instance.Name, // CR name for MariaDBDatabase - instance.Spec.DatabaseAccount, // CR name for MariaDBAccount - instance.Namespace, // namespace - ) - - // create or patch the DB - ctrlResult, err := db.CreateOrPatchAll(ctx, helper) + ospSecret, hash, err := oko_secret.GetSecret(ctx, helper, instance.Spec.Secret, instance.Namespace) if err != nil { + if k8s_errors.IsNotFound(err) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.InputReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.InputReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Second * 10}, fmt.Errorf("OpenStack secret %s not found", instance.Spec.Secret) + } instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, + condition.InputReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.DBReadyErrorMessage, + condition.InputReadyErrorMessage, err.Error())) return ctrl.Result{}, err } - if (ctrlResult != ctrl.Result{}) { + + configMapVars[ospSecret.Name] = env.SetValue(hash) + + transportURLSecret, hash, err := oko_secret.GetSecret(ctx, helper, instance.Status.TransportURLSecret, instance.Namespace) + if err != nil { + if k8s_errors.IsNotFound(err) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.InputReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.InputReadyWaitingMessage)) + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("TransportURL secret %s not found", instance.Status.TransportURLSecret) + } instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil + condition.InputReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.InputReadyErrorMessage, + err.Error())) + return ctrl.Result{}, err } - // wait for the DB to be setup - ctrlResult, err = db.WaitForDBCreated(ctx, helper) + configMapVars[transportURLSecret.Name] = env.SetValue(hash) + + designateDb, result, err := r.ensureDB(ctx, helper, instance) + if err != nil { + return ctrl.Result{}, err + } else if (result != ctrl.Result{}) { + return result, nil + } + + // + // create Configmap required for designate input + // - %-scripts configmap holding scripts to e.g. bootstrap the service + // - %-config configmap holding minimal designate config required to get the service up, user can add additional files to be added to the service + // - parameters which has passwords gets added from the OpenStack secret via the init container + // + Log.Info("pre generateConfigMap ....") + + err = r.generateServiceConfigMaps(ctx, helper, instance, &configMapVars, designateDb) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, + condition.ServiceConfigReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.DBReadyErrorMessage, + condition.ServiceConfigReadyErrorMessage, err.Error())) - return ctrlResult, err + return ctrl.Result{}, err } - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil + Log.Info("post generateConfigMap ....") + + // + // create hash over all the different input resources to identify if any those changed + // and a restart/recreate is required. + // + _, hashChanged, err := r.createHashOfInputHashes(ctx, instance, configMapVars) + if err != nil { + return ctrl.Result{}, err + } else if hashChanged { + // Hash changed and instance status should be updated (which will be done by main defer func), + // so we need to return and reconcile again + Log.Info("input hashes have changed, restarting reconcile") + return ctrl.Result{}, nil } - // update Status.DatabaseHostname, used to config the service - instance.Status.DatabaseHostname = db.GetDatabaseHostname() - instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage) - // create service DB - end + // Create ConfigMaps and Secrets - end + + instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage) // // run Designate db sync @@ -394,6 +431,7 @@ func (r *DesignateReconciler) reconcileInit( dbSyncHash := instance.Status.Hash[designatev1beta1.DbSyncHash] jobDef := designate.DbSyncJob(instance, serviceLabels, serviceAnnotations) + Log.Info("Initializing db sync job") dbSyncjob := job.NewJob( jobDef, designatev1beta1.DbSyncHash, @@ -401,7 +439,7 @@ func (r *DesignateReconciler) reconcileInit( time.Duration(5)*time.Second, dbSyncHash, ) - ctrlResult, err = dbSyncjob.DoJob( + ctrlResult, err := dbSyncjob.DoJob( ctx, helper, ) @@ -428,15 +466,104 @@ func (r *DesignateReconciler) reconcileInit( } instance.Status.Conditions.MarkTrue(condition.DBSyncReadyCondition, condition.DBSyncReadyMessage) - // when job passed, mark NetworkAttachmentsReadyCondition ready - instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage) - // run Designate db sync - end Log.Info(fmt.Sprintf("Reconciled Service '%s' init successfully", instance.Name)) return ctrl.Result{}, nil } +// ensureDB - set up the main database, and then drives the ability to generate the config +func (r *DesignateReconciler) ensureDB( + ctx context.Context, + helper *helper.Helper, + instance *designatev1beta1.Designate, +) (*mariadbv1.Database, ctrl.Result, error) { + + // ensure MariaDBAccount exists. This account record may be created by + // openstack-operator or the cloud operator up front without a specific + // MariaDBDatabase configured yet. Otherwise, a MariaDBAccount CR is + // created here with a generated username as well as a secret with + // generated password. The MariaDBAccount is created without being + // yet associated with any MariaDBDatabase. + + _, _, err := mariadbv1.EnsureMariaDBAccount( + ctx, helper, instance.Spec.DatabaseAccount, + instance.Namespace, false, designate.DatabaseUsernamePrefix, + ) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return nil, ctrl.Result{}, err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + // + // create service DB instance + // + designateDb := mariadbv1.NewDatabaseForAccount( + instance.Spec.DatabaseInstance, // mariadb/galera service to target + designate.DatabaseName, // name used in CREATE DATABASE in mariadb + designate.DatabaseCRName, // CR name for MariaDBDatabase + instance.Spec.DatabaseAccount, // CR name for MariaDBAccount + instance.Namespace, // namespace + ) + + // create or patch the DB + ctrlResult, err := designateDb.CreateOrPatchAll(ctx, helper) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return designateDb, ctrl.Result{}, err + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return designateDb, ctrlResult, nil + } + // wait for the DB to be setup + ctrlResult, err = designateDb.WaitForDBCreated(ctx, helper) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return designateDb, ctrlResult, nil + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return designateDb, ctrlResult, nil + } + + // update Status.DatabaseHostname, used to config the service + instance.Status.DatabaseHostname = designateDb.GetDatabaseHostname() + instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage) + + return designateDb, ctrl.Result{}, nil + // create service DB - end +} + func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *designatev1beta1.Designate, helper *helper.Helper) (ctrl.Result, error) { Log := r.GetLogger(ctx) @@ -463,18 +590,11 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des return rbacResult, nil } - serviceLabels := map[string]string{ - common.AppSelector: designate.ServiceName, - } - - // ConfigMap - configMapVars := make(map[string]env.Setter) - // // create RabbitMQ transportURL CR and get the actual URL from the associated secret that is created // - transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance, serviceLabels) + transportURL, op, err := r.transportURLCreateOrUpdate(ctx, instance) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( designatev1beta1.DesignateRabbitMqTransportURLReadyCondition, @@ -494,10 +614,10 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des if instance.Status.TransportURLSecret == "" { Log.Info(fmt.Sprintf("Waiting for TransportURL %s secret to be created", transportURL.Name)) instance.Status.Conditions.Set(condition.FalseCondition( - designatev1beta1.DesignateRabbitMqTransportURLReadyCondition, + condition.InputReadyCondition, condition.RequestedReason, condition.SeverityInfo, - designatev1beta1.DesignateRabbitMqTransportURLReadyRunningMessage)) + condition.InputReadyWaitingMessage)) return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } @@ -505,110 +625,16 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des // end transportURL - // - // check for required OpenStack secret holding passwords for service/admin user and add hash to the vars map - // - ospSecret, hash, err := secret.GetSecret(ctx, helper, instance.Spec.Secret, instance.Namespace) - if err != nil { - if k8s_errors.IsNotFound(err) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.InputReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.InputReadyWaitingMessage)) - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, fmt.Errorf("OpenStack secret %s not found", instance.Spec.Secret) - } - instance.Status.Conditions.Set(condition.FalseCondition( - condition.InputReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.InputReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - // Add a prefix to the var name to avoid accidental collision with other non-secret vars. - configMapVars["secret-"+ospSecret.Name] = env.SetValue(hash) - instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) - // run check OpenStack secret - end - - // ensure MariaDBAccount exists. This account record may be created by - // openstack-operator or the cloud operator up front without a specific - // MariaDBDatabase configured yet. Otherwise, a MariaDBAccount CR is - // created here with a generated username as well as a secret with - // generated password. The MariaDBAccount is created without being - // yet associated with any MariaDBDatabase. - _, _, err = mariadbv1.EnsureMariaDBAccount( - ctx, helper, instance.Spec.DatabaseAccount, - instance.Namespace, false, "designate", - ) - - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - mariadbv1.MariaDBAccountReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - mariadbv1.MariaDBAccountNotReadyMessage, - err.Error())) - - return ctrl.Result{}, err - } - instance.Status.Conditions.MarkTrue( - mariadbv1.MariaDBAccountReadyCondition, - mariadbv1.MariaDBAccountReadyMessage, - ) - - // - // Create ConfigMaps and Secrets required as input for the Service and calculate an overall hash of hashes - // // - // create Configmap required for designate input - // - %-scripts configmap holding scripts to e.g. bootstrap the service - // - %-config configmap holding minimal designate config required to get the service up, user can add additional files to be added to the service - // - parameters which has passwords gets added from the OpenStack secret via the init container + // TODO check when/if Init, Update, or Upgrade should/could be skipped // - Log.Info("pre generateConfigMap ....") - err = r.generateServiceConfigMaps(ctx, helper, instance, &configMapVars, serviceLabels) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.ServiceConfigReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.ServiceConfigReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - Log.Info("post generateConfigMap ....") - - // - // create hash over all the different input resources to identify if any those changed - // and a restart/recreate is required. - // - _, hashChanged, err := r.createHashOfInputHashes(ctx, instance, configMapVars) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.ServiceConfigReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.ServiceConfigReadyErrorMessage, - err.Error())) - Log.Info(fmt.Sprintf("createHashOfInputHashes failed: %v", err)) - return ctrl.Result{}, err - } else if hashChanged { - // Hash changed and instance status should be updated (which will be done by main defer func), - // so we need to return and reconcile again - Log.Info("input hashes have changed, restarting reconcile") - return ctrl.Result{}, nil + serviceLabels := map[string]string{ + common.AppSelector: designate.ServiceName, } - // Create ConfigMaps and Secrets - end - instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage) - - // - // TODO check when/if Init, Update, or Upgrade should/could be skipped - // // Note: Dkehn - this will remain in the code base until determination of DNS server connections are determined. // networks to attach to for _, netAtt := range instance.Spec.DesignateAPI.NetworkAttachments { @@ -646,6 +672,7 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des } else if (ctrlResult != ctrl.Result{}) { return ctrlResult, nil } + instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage) // Handle service update ctrlResult, err = r.reconcileUpdate(ctx, instance) @@ -956,7 +983,8 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des } Log.Info("Deployment Unbound task reconciled") - err = mariadbv1.DeleteUnusedMariaDBAccountFinalizers(ctx, helper, instance.Name, instance.Spec.DatabaseAccount, instance.Namespace) + // remove finalizers from unused MariaDBAccount records + err = mariadbv1.DeleteUnusedMariaDBAccountFinalizers(ctx, helper, designate.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace) if err != nil { return ctrl.Result{}, err } @@ -1002,7 +1030,7 @@ func (r *DesignateReconciler) generateServiceConfigMaps( h *helper.Helper, instance *designatev1beta1.Designate, envVars *map[string]env.Setter, - serviceLabels map[string]string, + designateDb *mariadbv1.Database, ) error { // // create Configmap/Secret required for designate input @@ -1011,7 +1039,7 @@ func (r *DesignateReconciler) generateServiceConfigMaps( // - parameters which has passwords gets added from the ospSecret via the init container // - cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(designate.ServiceName), serviceLabels) + cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(designate.ServiceName), map[string]string{}) // customData hold any customization for the service. // custom.conf is going to /etc//.conf.d @@ -1023,6 +1051,9 @@ func (r *DesignateReconciler) generateServiceConfigMaps( customData[key] = data } + databaseAccount := designateDb.GetAccount() + dbSecret := designateDb.GetSecret() + keystoneAPI, err := keystonev1.GetKeystoneAPI(ctx, h, instance.Namespace, map[string]string{}) if err != nil { return err @@ -1036,20 +1067,15 @@ func (r *DesignateReconciler) generateServiceConfigMaps( return err } - databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret(ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) - if err != nil { - return err - } - templateParameters := make(map[string]interface{}) templateParameters["ServiceUser"] = instance.Spec.ServiceUser templateParameters["KeystoneInternalURL"] = keystoneInternalURL templateParameters["KeystonePublicURL"] = keystonePublicURL - templateParameters["DatabaseConnection"] = fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s", + templateParameters["DatabaseConnection"] = fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", databaseAccount.Spec.UserName, string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), instance.Status.DatabaseHostname, - instance.Name, + designate.DatabaseName, ) cms := []util.Template{ @@ -1074,7 +1100,12 @@ func (r *DesignateReconciler) generateServiceConfigMaps( }, } - return secret.EnsureSecrets(ctx, h, instance, cms, envVars) + err = oko_secret.EnsureSecrets(ctx, h, instance, cms, envVars) + if err != nil { + return err + } + + return nil } // createHashOfInputHashes - creates a hash of hashes which gets added to the resources which requires a restart @@ -1106,13 +1137,11 @@ func (r *DesignateReconciler) createHashOfInputHashes( func (r *DesignateReconciler) transportURLCreateOrUpdate( ctx context.Context, instance *designatev1beta1.Designate, - serviceLabels map[string]string, ) (*rabbitmqv1.TransportURL, controllerutil.OperationResult, error) { transportURL := &rabbitmqv1.TransportURL{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%s-designate-transport", instance.Name), Namespace: instance.Namespace, - Labels: serviceLabels, }, } @@ -1142,7 +1171,6 @@ func (r *DesignateReconciler) apiDeploymentCreateOrUpdate(ctx context.Context, i deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.ServiceAccount = instance.RbacResourceName() deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret if len(deployment.Spec.NodeSelector) == 0 { @@ -1176,7 +1204,6 @@ func (r *DesignateReconciler) centralDeploymentCreateOrUpdate(ctx context.Contex deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret deployment.Spec.ServiceAccount = instance.RbacResourceName() if len(deployment.Spec.NodeSelector) == 0 { @@ -1210,7 +1237,6 @@ func (r *DesignateReconciler) workerDeploymentCreateOrUpdate(ctx context.Context deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret deployment.Spec.ServiceAccount = instance.RbacResourceName() if len(deployment.Spec.NodeSelector) == 0 { @@ -1244,7 +1270,6 @@ func (r *DesignateReconciler) mdnsDeploymentCreateOrUpdate(ctx context.Context, deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret deployment.Spec.ServiceAccount = instance.RbacResourceName() if len(deployment.Spec.NodeSelector) == 0 { @@ -1278,7 +1303,6 @@ func (r *DesignateReconciler) producerDeploymentCreateOrUpdate(ctx context.Conte deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret deployment.Spec.ServiceAccount = instance.RbacResourceName() if len(deployment.Spec.NodeSelector) == 0 { @@ -1312,7 +1336,6 @@ func (r *DesignateReconciler) backendbind9DeploymentCreateOrUpdate(ctx context.C deployment.Spec.DatabaseHostname = instance.Status.DatabaseHostname deployment.Spec.DatabaseAccount = instance.Spec.DatabaseAccount deployment.Spec.Secret = instance.Spec.Secret - deployment.Spec.PasswordSelectors = instance.Spec.PasswordSelectors deployment.Spec.TransportURLSecret = instance.Status.TransportURLSecret deployment.Spec.ServiceAccount = instance.RbacResourceName() if len(deployment.Spec.NodeSelector) == 0 { diff --git a/controllers/designateapi_controller.go b/controllers/designateapi_controller.go index f68c26b4..ce6684a2 100644 --- a/controllers/designateapi_controller.go +++ b/controllers/designateapi_controller.go @@ -51,6 +51,7 @@ import ( "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/service" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -862,15 +863,52 @@ func (r *DesignateAPIReconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/controllers/designatebackendbind9_controller.go b/controllers/designatebackendbind9_controller.go index 5734b8b3..ab8884ea 100644 --- a/controllers/designatebackendbind9_controller.go +++ b/controllers/designatebackendbind9_controller.go @@ -45,6 +45,7 @@ import ( nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -662,15 +663,52 @@ func (r *DesignateBackendbind9Reconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/controllers/designatecentral_controller.go b/controllers/designatecentral_controller.go index d0807085..08c39e53 100644 --- a/controllers/designatecentral_controller.go +++ b/controllers/designatecentral_controller.go @@ -47,6 +47,7 @@ import ( nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -626,15 +627,52 @@ func (r *DesignateCentralReconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/controllers/designatemdns_controller.go b/controllers/designatemdns_controller.go index eeb77649..09a0e2e6 100644 --- a/controllers/designatemdns_controller.go +++ b/controllers/designatemdns_controller.go @@ -46,6 +46,7 @@ import ( nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -624,15 +625,52 @@ func (r *DesignateMdnsReconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/controllers/designateproducer_controller.go b/controllers/designateproducer_controller.go index 6be79119..7016db99 100644 --- a/controllers/designateproducer_controller.go +++ b/controllers/designateproducer_controller.go @@ -47,6 +47,7 @@ import ( nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -626,15 +627,52 @@ func (r *DesignateProducerReconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/controllers/designateunbound_controller.go b/controllers/designateunbound_controller.go index 6d3c7afd..0d16e28e 100644 --- a/controllers/designateunbound_controller.go +++ b/controllers/designateunbound_controller.go @@ -418,6 +418,16 @@ func (r *UnboundReconciler) generateServiceConfigMaps( templateParameters["ExternalNetCidr"] = "0.0.0.0/0" cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, + // ConfigMap { Name: fmt.Sprintf("%s-config-data", instance.Name), Namespace: instance.Namespace, diff --git a/controllers/designateworker_controller.go b/controllers/designateworker_controller.go index 196047f1..5a570783 100644 --- a/controllers/designateworker_controller.go +++ b/controllers/designateworker_controller.go @@ -46,6 +46,7 @@ import ( nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/util" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -619,15 +620,52 @@ func (r *DesignateWorkerReconciler) generateServiceConfigMaps( customData[common.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig + databaseAccount, dbSecret, err := mariadbv1.GetAccountAndSecret( + ctx, h, instance.Spec.DatabaseAccount, instance.Namespace) + + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + mariadbv1.MariaDBAccountReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + mariadbv1.MariaDBAccountNotReadyMessage, + err.Error())) + + return err + } + + instance.Status.Conditions.MarkTrue( + mariadbv1.MariaDBAccountReadyCondition, + mariadbv1.MariaDBAccountReadyMessage) + + templateParameters := map[string]interface{}{ + "DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s?read_default_file=/etc/my.cnf", + databaseAccount.Spec.UserName, + string(dbSecret.Data[mariadbv1.DatabasePasswordSelector]), + instance.Spec.DatabaseHostname, + designate.DatabaseName, + ), + } + cms := []util.Template{ + // ScriptsConfigMap + { + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + AdditionalTemplate: map[string]string{"common.sh": "/common/common.sh"}, + Labels: cmLabels, + }, // Custom ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - Labels: cmLabels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + Labels: cmLabels, }, } diff --git a/pkg/designate/const.go b/pkg/designate/const.go index bf6398f1..1c471293 100644 --- a/pkg/designate/const.go +++ b/pkg/designate/const.go @@ -23,6 +23,13 @@ const ( // DatabaseName - DatabaseName = "designate" + // DatabaseCRName - Name of the MariaDBDatabase CR + DatabaseCRName = "designate" + + // DatabaseUsernamePrefix - used by EnsureMariaDBAccount when a new username + // is to be generated, e.g. "designate_e5a4", "designate_78bc", etc + DatabaseUsernamePrefix = "designate" + // DesignatePublicPort - DesignatePublicPort int32 = 9001 // DesignateInternalPort - diff --git a/pkg/designateapi/deployment.go b/pkg/designateapi/deployment.go index a93bf468..f4a5e6a9 100644 --- a/pkg/designateapi/deployment.go +++ b/pkg/designateapi/deployment.go @@ -137,11 +137,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment } diff --git a/pkg/designatebackendbind9/deployment.go b/pkg/designatebackendbind9/deployment.go index 110c2a41..f64f900e 100644 --- a/pkg/designatebackendbind9/deployment.go +++ b/pkg/designatebackendbind9/deployment.go @@ -171,55 +171,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment } - -// envVars := map[string]env.Setter{} -// envVars["KOLLA_CONFIG_FILE"] = env.SetValue(KollaConfig) -// envVars["KOLLA_CONFIG_STRATEGY"] = env.SetValue("COPY_ALWAYS") -// envVars["CONFIG_HASH"] = env.SetValue(configHash) - -// deployment := &appsv1.Deployment{ -// ObjectMeta: metav1.ObjectMeta{ -// Name: instance.Name, -// Namespace: instance.Namespace, -// }, -// Spec: appsv1.DeploymentSpec{ -// Replicas: instance.Spec.Replicas, -// Selector: &metav1.LabelSelector{ -// MatchLabels: matchls, -// }, -// Template: corev1.PodTemplateSpec{ -// ObjectMeta: metav1.ObjectMeta{ -// Labels: ls, -// }, -// Spec: corev1.PodSpec{ -// ServiceAccountName: instance.RbacResourceName(), -// Containers: []corev1.Container{{ -// Image: instance.Spec.ContainerImage, -// Name: "designatebackendbind9", -// Command: command, -// Args: args, -// Ports: []corev1.ContainerPort{{ -// ContainerPort: 6379, -// Name: "designatebackendbind9", -// }}, -// Env: env.MergeEnvs([]corev1.EnvVar{}, envVars), -// VolumeMounts: designate.GetServiceVolumeMounts("designate-backendbind9"), -// Resources: instance.Spec.Resources, -// ReadinessProbe: readinessProbe, -// LivenessProbe: livenessProbe, -// }}, -// }, -// }, -// }, -// } - -// return deployment -// } diff --git a/pkg/designatecentral/deployment.go b/pkg/designatecentral/deployment.go index abfa5c3e..8da88fdd 100644 --- a/pkg/designatecentral/deployment.go +++ b/pkg/designatecentral/deployment.go @@ -140,11 +140,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment } diff --git a/pkg/designatemdns/deployment.go b/pkg/designatemdns/deployment.go index ed90eed9..f8abd4dd 100644 --- a/pkg/designatemdns/deployment.go +++ b/pkg/designatemdns/deployment.go @@ -137,11 +137,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment } diff --git a/pkg/designateproducer/deployment.go b/pkg/designateproducer/deployment.go index 4e067469..17aee57b 100644 --- a/pkg/designateproducer/deployment.go +++ b/pkg/designateproducer/deployment.go @@ -136,11 +136,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment } diff --git a/pkg/designateworker/deployment.go b/pkg/designateworker/deployment.go index b5d96d5f..478e93b8 100644 --- a/pkg/designateworker/deployment.go +++ b/pkg/designateworker/deployment.go @@ -136,11 +136,5 @@ func Deployment( } deployment.Spec.Template.Spec.InitContainers = designate.InitContainer(initContainerDetails) - // TODO: Clean up this hack - // Add custom config for the API Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - deployment.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(deployment.Spec.Template.Spec.InitContainers[0].Env, envVars) - return deployment }