diff --git a/api/bases/cinder.openstack.org_cinderapis.yaml b/api/bases/cinder.openstack.org_cinderapis.yaml index ea21657e..7b0538c0 100644 --- a/api/bases/cinder.openstack.org_cinderapis.yaml +++ b/api/bases/cinder.openstack.org_cinderapis.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/api/bases/cinder.openstack.org_cinderbackups.yaml b/api/bases/cinder.openstack.org_cinderbackups.yaml index e02d5569..2c26d1bc 100644 --- a/api/bases/cinder.openstack.org_cinderbackups.yaml +++ b/api/bases/cinder.openstack.org_cinderbackups.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/api/bases/cinder.openstack.org_cinders.yaml b/api/bases/cinder.openstack.org_cinders.yaml index 1a17327b..867f87a9 100644 --- a/api/bases/cinder.openstack.org_cinders.yaml +++ b/api/bases/cinder.openstack.org_cinders.yaml @@ -48,9 +48,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -143,9 +140,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -212,9 +206,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -282,9 +273,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -350,9 +338,6 @@ spec: type: string debug: properties: - dbInitContainer: - default: false - type: boolean dbSync: default: false type: boolean diff --git a/api/bases/cinder.openstack.org_cinderschedulers.yaml b/api/bases/cinder.openstack.org_cinderschedulers.yaml index acc02bdc..c6bc087e 100644 --- a/api/bases/cinder.openstack.org_cinderschedulers.yaml +++ b/api/bases/cinder.openstack.org_cinderschedulers.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/api/bases/cinder.openstack.org_cindervolumes.yaml b/api/bases/cinder.openstack.org_cindervolumes.yaml index 860f2ef0..61c21c49 100644 --- a/api/bases/cinder.openstack.org_cindervolumes.yaml +++ b/api/bases/cinder.openstack.org_cindervolumes.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index e037457d..05111706 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -105,10 +105,6 @@ type PasswordSelector struct { // CinderDebug indicates whether certain stages of Cinder deployment should // pause in debug mode type CinderDebug struct { - // +kubebuilder:validation:Optional - // +kubebuilder:default=false - // dbInitContainer enable debug (waits until /tmp/stop-init-container disappears) - DBInitContainer bool `json:"dbInitContainer"` // +kubebuilder:validation:Optional // +kubebuilder:default=false // dbSync enable debug @@ -118,10 +114,6 @@ type CinderDebug struct { // CinderServiceDebug indicates whether certain stages of Cinder service // deployment should pause in debug mode type CinderServiceDebug struct { - // +kubebuilder:validation:Optional - // +kubebuilder:default=false - // initContainer enable debug (waits until /tmp/stop-init-container disappears) - InitContainer bool `json:"initContainer"` // +kubebuilder:validation:Optional // +kubebuilder:default=false // service enable debug diff --git a/config/crd/bases/cinder.openstack.org_cinderapis.yaml b/config/crd/bases/cinder.openstack.org_cinderapis.yaml index ea21657e..7b0538c0 100644 --- a/config/crd/bases/cinder.openstack.org_cinderapis.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderapis.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/config/crd/bases/cinder.openstack.org_cinderbackups.yaml b/config/crd/bases/cinder.openstack.org_cinderbackups.yaml index e02d5569..2c26d1bc 100644 --- a/config/crd/bases/cinder.openstack.org_cinderbackups.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderbackups.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/config/crd/bases/cinder.openstack.org_cinders.yaml b/config/crd/bases/cinder.openstack.org_cinders.yaml index 1a17327b..867f87a9 100644 --- a/config/crd/bases/cinder.openstack.org_cinders.yaml +++ b/config/crd/bases/cinder.openstack.org_cinders.yaml @@ -48,9 +48,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -143,9 +140,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -212,9 +206,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -282,9 +273,6 @@ spec: type: array debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean @@ -350,9 +338,6 @@ spec: type: string debug: properties: - dbInitContainer: - default: false - type: boolean dbSync: default: false type: boolean diff --git a/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml b/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml index acc02bdc..c6bc087e 100644 --- a/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderschedulers.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/config/crd/bases/cinder.openstack.org_cindervolumes.yaml b/config/crd/bases/cinder.openstack.org_cindervolumes.yaml index 860f2ef0..61c21c49 100644 --- a/config/crd/bases/cinder.openstack.org_cindervolumes.yaml +++ b/config/crd/bases/cinder.openstack.org_cindervolumes.yaml @@ -55,9 +55,6 @@ spec: type: string debug: properties: - initContainer: - default: false - type: boolean service: default: false type: boolean diff --git a/controllers/cinder_controller.go b/controllers/cinder_controller.go index 2eff78be..de8c9c2c 100644 --- a/controllers/cinder_controller.go +++ b/controllers/cinder_controller.go @@ -825,12 +825,11 @@ func (r *CinderReconciler) generateServiceConfigMaps( 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, + Name: fmt.Sprintf("%s-scripts", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeScripts, + InstanceType: instance.Kind, + Labels: cmLabels, }, // ConfigMap { diff --git a/pkg/cinder/dbsync.go b/pkg/cinder/dbsync.go index 675de061..77cfd712 100644 --- a/pkg/cinder/dbsync.go +++ b/pkg/cinder/dbsync.go @@ -99,18 +99,5 @@ func DbSyncJob(instance *cinderv1beta1.Cinder, labels map[string]string, annotat }, } - initContainerDetails := APIDetails{ - ContainerImage: instance.Spec.CinderAPI.ContainerImage, - DatabaseHost: instance.Status.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: DatabaseName, - OSPSecret: instance.Spec.Secret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: GetInitVolumeMounts(dbSyncExtraMounts, DbsyncPropagation), - Debug: instance.Spec.Debug.DBInitContainer, - } - job.Spec.Template.Spec.InitContainers = InitContainer(initContainerDetails) - return job } diff --git a/pkg/cinder/initcontainer.go b/pkg/cinder/initcontainer.go deleted file mode 100644 index 3ca17d2b..00000000 --- a/pkg/cinder/initcontainer.go +++ /dev/null @@ -1,128 +0,0 @@ -/* - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cinder - -import ( - "github.com/openstack-k8s-operators/lib-common/modules/common/env" - - corev1 "k8s.io/api/core/v1" -) - -// APIDetails information -type APIDetails struct { - ContainerImage string - DatabaseHost string - DatabaseUser string - DatabaseName string - OSPSecret string - TransportURLSecret string - DBPasswordSelector string - UserPasswordSelector string - VolumeMounts []corev1.VolumeMount - Privileged bool - Debug bool -} - -const ( - // InitContainerCommand - - InitContainerCommand = "/usr/local/bin/container-scripts/init.sh" -) - -// InitContainer - init container for Cinder pods -func InitContainer(init APIDetails) []corev1.Container { - runAsUser := int64(0) - trueVar := true - - securityContext := &corev1.SecurityContext{ - RunAsUser: &runAsUser, - } - - if init.Privileged { - securityContext.Privileged = &trueVar - } - - args := []string{"-c"} - - if init.Debug { - args = append( - args, - "touch /tmp/stop-init-container && while [ -f /tmp/stop-init-container ]; do sleep 5; done", - ) - } else { - args = append(args, InitContainerCommand) - } - - envVars := map[string]env.Setter{} - envVars["DatabaseHost"] = env.SetValue(init.DatabaseHost) - envVars["DatabaseUser"] = env.SetValue(init.DatabaseUser) - envVars["DatabaseName"] = env.SetValue(init.DatabaseName) - - envs := []corev1.EnvVar{ - { - Name: "DatabasePassword", - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: init.OSPSecret, - }, - Key: init.DBPasswordSelector, - }, - }, - }, - { - Name: "CinderPassword", - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: init.OSPSecret, - }, - Key: init.UserPasswordSelector, - }, - }, - }, - } - - if init.TransportURLSecret != "" { - envTransport := corev1.EnvVar{ - Name: "TransportURL", - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: init.TransportURLSecret, - }, - Key: "transport_url", - }, - }, - } - envs = append(envs, envTransport) - } - - envs = env.MergeEnvs(envs, envVars) - - return []corev1.Container{ - { - Name: "init", - Image: init.ContainerImage, - SecurityContext: securityContext, - Command: []string{ - "/bin/bash", - }, - Args: args, - Env: envs, - VolumeMounts: init.VolumeMounts, - }, - } -} diff --git a/pkg/cinder/volumes.go b/pkg/cinder/volumes.go index ea830040..d1c4cda9 100644 --- a/pkg/cinder/volumes.go +++ b/pkg/cinder/volumes.go @@ -131,30 +131,7 @@ func GetVolumes(name string, storageSvc bool, extraVol []cinderv1beta1.CinderExt return res } -// GetInitVolumeMounts - Nova Control Plane init task VolumeMounts -func GetInitVolumeMounts(extraVol []cinderv1beta1.CinderExtraVolMounts, svc []storage.PropagationType) []corev1.VolumeMount { - vm := []corev1.VolumeMount{ - { - Name: "scripts", - MountPath: "/usr/local/bin/container-scripts", - ReadOnly: true, - }, - { - Name: "config-data", - MountPath: "/var/lib/config-data/default", - ReadOnly: true, - }, - } - - for _, exv := range extraVol { - for _, vol := range exv.Propagate(svc) { - vm = append(vm, vol.Mounts...) - } - } - return vm -} - -// GetVolumeMounts - Nova Control Plane VolumeMounts +// GetVolumeMounts - Cinder Control Plane VolumeMounts func GetVolumeMounts(storageSvc bool, extraVol []cinderv1beta1.CinderExtraVolMounts, svc []storage.PropagationType) []corev1.VolumeMount { res := []corev1.VolumeMount{ { diff --git a/pkg/cinderapi/deployment.go b/pkg/cinderapi/deployment.go index 80f1e7ea..8028f63c 100644 --- a/pkg/cinderapi/deployment.go +++ b/pkg/cinderapi/deployment.go @@ -142,25 +142,5 @@ func Deployment( deployment.Spec.Template.Spec.NodeSelector = instance.Spec.NodeSelector } - initContainerDetails := cinder.APIDetails{ - ContainerImage: instance.Spec.ContainerImage, - DatabaseHost: instance.Spec.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: cinder.DatabaseName, - OSPSecret: instance.Spec.Secret, - TransportURLSecret: instance.Spec.TransportURLSecret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: GetInitVolumeMounts(instance.Spec.CustomServiceConfigSecrets, instance.Spec.ExtraMounts), - Debug: instance.Spec.Debug.InitContainer, - } - deployment.Spec.Template.Spec.InitContainers = cinder.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/cinderapi/volumes.go b/pkg/cinderapi/volumes.go index 577a2b22..f9b68938 100644 --- a/pkg/cinderapi/volumes.go +++ b/pkg/cinderapi/volumes.go @@ -25,20 +25,6 @@ func GetVolumes(parentName string, name string, secretNames []string, extraVol [ return append(cinder.GetVolumes(parentName, false, extraVol, cinder.CinderAPIPropagation), volumes...) } -// GetInitVolumeMounts - Cinder API init task VolumeMounts -func GetInitVolumeMounts(secretNames []string, extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { - - initVolumeMounts := []corev1.VolumeMount{ - { - Name: "config-data-custom", - MountPath: "/var/lib/config-data/custom", - ReadOnly: true, - }, - } - - return append(cinder.GetInitVolumeMounts(extraVol, cinder.CinderAPIPropagation), initVolumeMounts...) -} - // GetVolumeMounts - Cinder API VolumeMounts func GetVolumeMounts(extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{ diff --git a/pkg/cinderbackup/statefulset.go b/pkg/cinderbackup/statefulset.go index d2d8e80c..fa310732 100644 --- a/pkg/cinderbackup/statefulset.go +++ b/pkg/cinderbackup/statefulset.go @@ -182,26 +182,5 @@ func StatefulSet( statefulset.Spec.Template.Spec.NodeSelector = instance.Spec.NodeSelector } - initContainerDetails := cinder.APIDetails{ - ContainerImage: instance.Spec.ContainerImage, - DatabaseHost: instance.Spec.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: cinder.DatabaseName, - OSPSecret: instance.Spec.Secret, - TransportURLSecret: instance.Spec.TransportURLSecret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: GetInitVolumeMounts(instance.Spec.CustomServiceConfigSecrets, instance.Spec.ExtraMounts), - Debug: instance.Spec.Debug.InitContainer, - } - - statefulset.Spec.Template.Spec.InitContainers = cinder.InitContainer(initContainerDetails) - - // TODO: Clean up this hack - // Add custom config for the Backup Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - statefulset.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(statefulset.Spec.Template.Spec.InitContainers[0].Env, envVars) - return statefulset } diff --git a/pkg/cinderbackup/volumes.go b/pkg/cinderbackup/volumes.go index 485ab92c..7e8a0ed7 100644 --- a/pkg/cinderbackup/volumes.go +++ b/pkg/cinderbackup/volumes.go @@ -44,19 +44,6 @@ func GetVolumes(parentName string, name string, secretNames []string, extraVol [ return append(cinder.GetVolumes(parentName, true, extraVol, cinder.CinderBackupPropagation), volumes...) } -// GetInitVolumeMounts - Cinder Backup init task VolumeMounts -func GetInitVolumeMounts(secretNames []string, extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { - initVolumeMounts := []corev1.VolumeMount{ - { - Name: "config-data-custom", - MountPath: "/var/lib/config-data/custom", - ReadOnly: true, - }, - } - - return append(cinder.GetInitVolumeMounts(extraVol, cinder.CinderBackupPropagation), initVolumeMounts...) -} - // GetVolumeMounts - Cinder Backup VolumeMounts func GetVolumeMounts(extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{ diff --git a/pkg/cinderscheduler/statefulset.go b/pkg/cinderscheduler/statefulset.go index accb4909..f9dc394f 100644 --- a/pkg/cinderscheduler/statefulset.go +++ b/pkg/cinderscheduler/statefulset.go @@ -167,26 +167,5 @@ func StatefulSet( statefulset.Spec.Template.Spec.NodeSelector = instance.Spec.NodeSelector } - initContainerDetails := cinder.APIDetails{ - ContainerImage: instance.Spec.ContainerImage, - DatabaseHost: instance.Spec.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: cinder.DatabaseName, - OSPSecret: instance.Spec.Secret, - TransportURLSecret: instance.Spec.TransportURLSecret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: GetInitVolumeMounts(instance.Spec.CustomServiceConfigSecrets, instance.Spec.ExtraMounts), - Debug: instance.Spec.Debug.InitContainer, - } - - statefulset.Spec.Template.Spec.InitContainers = cinder.InitContainer(initContainerDetails) - - // TODO: Clean up this hack - // Add custom config for the Scheduler Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - statefulset.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(statefulset.Spec.Template.Spec.InitContainers[0].Env, envVars) - return statefulset } diff --git a/pkg/cinderscheduler/volumes.go b/pkg/cinderscheduler/volumes.go index b2aab828..d7ac2a02 100644 --- a/pkg/cinderscheduler/volumes.go +++ b/pkg/cinderscheduler/volumes.go @@ -25,19 +25,6 @@ func GetVolumes(parentName string, name string, secretNames []string, extraVol [ return append(cinder.GetVolumes(parentName, false, extraVol, cinder.CinderSchedulerPropagation), volumes...) } -// GetInitVolumeMounts - Cinder Scheduler init task VolumeMounts -func GetInitVolumeMounts(secretNames []string, extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { - initVolumeMounts := []corev1.VolumeMount{ - { - Name: "config-data-custom", - MountPath: "/var/lib/config-data/custom", - ReadOnly: true, - }, - } - - return append(cinder.GetInitVolumeMounts(extraVol, cinder.CinderSchedulerPropagation), initVolumeMounts...) -} - // GetVolumeMounts - Cinder Scheduler VolumeMounts func GetVolumeMounts(extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{ diff --git a/pkg/cindervolume/statefulset.go b/pkg/cindervolume/statefulset.go index 3c9394b8..658e5821 100644 --- a/pkg/cindervolume/statefulset.go +++ b/pkg/cindervolume/statefulset.go @@ -182,26 +182,5 @@ func StatefulSet( statefulset.Spec.Template.Spec.NodeSelector = instance.Spec.NodeSelector } - initContainerDetails := cinder.APIDetails{ - ContainerImage: instance.Spec.ContainerImage, - DatabaseHost: instance.Spec.DatabaseHostname, - DatabaseUser: instance.Spec.DatabaseUser, - DatabaseName: cinder.DatabaseName, - OSPSecret: instance.Spec.Secret, - TransportURLSecret: instance.Spec.TransportURLSecret, - DBPasswordSelector: instance.Spec.PasswordSelectors.Database, - UserPasswordSelector: instance.Spec.PasswordSelectors.Service, - VolumeMounts: GetInitVolumeMounts(instance.Name, instance.Spec.CustomServiceConfigSecrets, instance.Spec.ExtraMounts), - Debug: instance.Spec.Debug.InitContainer, - } - - statefulset.Spec.Template.Spec.InitContainers = cinder.InitContainer(initContainerDetails) - - // TODO: Clean up this hack - // Add custom config for the Volume Service - envVars = map[string]env.Setter{} - envVars["CustomConf"] = env.SetValue(common.CustomServiceConfigFileName) - statefulset.Spec.Template.Spec.InitContainers[0].Env = env.MergeEnvs(statefulset.Spec.Template.Spec.InitContainers[0].Env, envVars) - return statefulset } diff --git a/pkg/cindervolume/volumes.go b/pkg/cindervolume/volumes.go index 81a5ab13..12e32363 100644 --- a/pkg/cindervolume/volumes.go +++ b/pkg/cindervolume/volumes.go @@ -49,21 +49,6 @@ func GetVolumes(parentName string, name string, secretNames []string, extraVol [ return append(cinder.GetVolumes(parentName, true, extraVol, propagation), volumes...) } -// GetInitVolumeMounts - Cinder Volume init task VolumeMounts -func GetInitVolumeMounts(name string, secretNames []string, extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { - initVolumeMounts := []corev1.VolumeMount{ - { - Name: "config-data-custom", - MountPath: "/var/lib/config-data/custom", - ReadOnly: true, - }, - } - - // Set the propagation levels for CinderVolume, including the backend name - propagation := append(cinder.CinderVolumePropagation, storage.PropagationType(strings.TrimPrefix(name, "cinder-volume-"))) - return append(cinder.GetInitVolumeMounts(extraVol, propagation), initVolumeMounts...) -} - // GetVolumeMounts - Cinder Volume VolumeMounts func GetVolumeMounts(name string, extraVol []cinderv1beta1.CinderExtraVolMounts) []corev1.VolumeMount { volumeVolumeMounts := []corev1.VolumeMount{ diff --git a/templates/cinder/bin/init.sh b/templates/cinder/bin/init.sh deleted file mode 100755 index 080e3d0c..00000000 --- a/templates/cinder/bin/init.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# -# Copyright 2020 Red Hat Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -set -ex - -exit 0 - -# This script generates cinder.conf.d files and copies the result to the -# ephemeral /var/lib/config-data/merged volume. -# -# Secrets are obtained from ENV variables. -export DB=${DatabaseName:-"cinder"} -export DBHOST=${DatabaseHost:?"Please specify a DatabaseHost variable."} -export DBUSER=${DatabaseUser:-"cinder"} -export DBPASSWORD=${DatabasePassword:?"Please specify a DatabasePassword variable."} -export PASSWORD=${CinderPassword:?"Please specify a CinderPassword variable."} -export TRANSPORTURL=${TransportURL:-""} - -DEFAULT_DIR=/var/lib/config-data/default -CUSTOM_DIR=/var/lib/config-data/custom -MERGED_DIR=/var/lib/config-data/merged -SVC_CFG=/etc/cinder/cinder.conf -SVC_CFG_MERGED=${MERGED_DIR}/cinder.conf -SVC_CFG_MERGED_DIR=${MERGED_DIR}/cinder.conf.d - -mkdir -p ${SVC_CFG_MERGED_DIR} - -cp ${DEFAULT_DIR}/* ${MERGED_DIR} - -# Save the default service config from container image as cinder.conf.sample, -# and create a small cinder.conf file that directs people to files in -# cinder.conf.d. -cp -a ${SVC_CFG} ${SVC_CFG_MERGED}.sample -cat < ${SVC_CFG_MERGED} -# Service configuration snippets are stored in the cinder.conf.d subdirectory. -EOF - -cp ${DEFAULT_DIR}/cinder.conf ${SVC_CFG_MERGED_DIR}/00-default.conf - -# Generate 01-deployment-secrets.conf -DEPLOYMENT_SECRETS=${SVC_CFG_MERGED_DIR}/01-deployment-secrets.conf -if [ -n "$TRANSPORTURL" ]; then - cat < ${DEPLOYMENT_SECRETS} -[DEFAULT] -transport_url = ${TRANSPORTURL} - -EOF -fi - -# TODO: service token -cat <> ${DEPLOYMENT_SECRETS} -[database] -connection = mysql+pymysql://${DBUSER}:${DBPASSWORD}@${DBHOST}/${DB} - -[keystone_authtoken] -password = ${PASSWORD} - -[nova] -password = ${PASSWORD} - -[service_user] -password = ${PASSWORD} -EOF - -if [ -f ${DEFAULT_DIR}/custom.conf ]; then - cp ${DEFAULT_DIR}/custom.conf ${SVC_CFG_MERGED_DIR}/02-global.conf -fi - -if [ -f ${CUSTOM_DIR}/custom.conf ]; then - cp ${CUSTOM_DIR}/custom.conf ${SVC_CFG_MERGED_DIR}/03-service.conf -fi - -SECRET_FILES="$(ls /var/lib/config-data/secret-*/* 2>/dev/null || true)" -if [ -n "${SECRET_FILES}" ]; then - cat ${SECRET_FILES} > ${SVC_CFG_MERGED_DIR}/04-secrets.conf -fi - -# Probes cannot run kolla_set_configs because it uses the 'cinder' uid -# and gid and doesn't have permission to make files be owned by root. -# This means the probe must use files in the "merged" location, and the -# files must be readable by 'cinder'. -chown -R :cinder ${SVC_CFG_MERGED_DIR} diff --git a/templates/common/common.sh b/templates/common/common.sh deleted file mode 100755 index 0e2515eb..00000000 --- a/templates/common/common.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# -# Copyright 2022 Red Hat Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -set -e - -function merge_config_dir { - echo merge config dir $1 - for conf in $(find $1 -type f);do - conf_base=$(basename $conf) - - # If CFG already exist in ../merged and is not a json file, - # we expect for now it can be merged using crudini. - # Else, just copy the full file. - if [[ -f /var/lib/config-data/merged/${conf_base} && ${conf_base} != *.json && ${conf_base} != nfs_shares ]]; then - echo merging ${conf} into /var/lib/config-data/merged/${conf_base} - crudini --merge /var/lib/config-data/merged/${conf_base} < ${conf} - else - echo copy ${conf} to /var/lib/config-data/merged/ - cp -f ${conf} /var/lib/config-data/merged/ - fi - done -} diff --git a/tests/kuttl/common/assert_sample_deployment.yaml b/tests/kuttl/common/assert_sample_deployment.yaml index 24fe1427..ee483519 100644 --- a/tests/kuttl/common/assert_sample_deployment.yaml +++ b/tests/kuttl/common/assert_sample_deployment.yaml @@ -117,53 +117,6 @@ spec: - mountPath: /etc/cinder/cinder.conf.d name: config-data-custom dnsPolicy: ClusterFirst - initContainers: - - args: - - -c - - /usr/local/bin/container-scripts/init.sh - command: - - /bin/bash - env: - - name: DatabasePassword - valueFrom: - secretKeyRef: - key: CinderDatabasePassword - name: osp-secret - - name: CinderPassword - valueFrom: - secretKeyRef: - key: CinderPassword - name: osp-secret - - name: TransportURL - valueFrom: - secretKeyRef: - key: transport_url - name: rabbitmq-transport-url-cinder-cinder-transport - - name: DatabaseHost - value: openstack - - name: DatabaseName - value: cinder - - name: DatabaseUser - value: cinder - - name: CustomConf - value: custom.conf - image: quay.io/podified-antelope-centos9/openstack-cinder-api:current-podified - imagePullPolicy: IfNotPresent - name: init - resources: {} - securityContext: - runAsUser: 0 - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - volumeMounts: - - mountPath: /usr/local/bin/container-scripts - name: scripts - readOnly: true - - mountPath: /var/lib/config-data/default - name: config-data - readOnly: true - - mountPath: /var/lib/config-data/custom - name: config-data-custom restartPolicy: Always serviceAccount: cinder-cinder serviceAccountName: cinder-cinder