Skip to content

Commit

Permalink
Merge pull request #1158 from dprince/lib-common-storage
Browse files Browse the repository at this point in the history
Update to support new lib-common storage structs
  • Loading branch information
openshift-merge-bot[bot] authored Nov 5, 2024
2 parents 75a2208 + 8f09364 commit f6f541e
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 4,323 deletions.
1,902 changes: 51 additions & 1,851 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Large diffs are not rendered by default.

300 changes: 0 additions & 300 deletions apis/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20241016184335-60fb2a3ccf1a
github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20241028071533-ae2b9a574fda
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241028071009-a8404d0ab6bb
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d
github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241021160008-f0273be177b4
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241028074300-17b2cf83d27e
github.com/openstack-k8s-operators/neutron-operator/api v0.5.1-0.20241028134914-0bd44d6dcb1d
Expand Down
4 changes: 2 additions & 2 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.2024102807
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241028071009-a8404d0ab6bb/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.0 h1:A8bwCA5B4AyIjt0Qzg0JgvF+HrZ9OQJOrSNq9jOFDpg=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.0/go.mod h1:djfljx3jfHqywhY3oDvPg/GLKwiFVkds6v7P7/Yg+8g=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0 h1:iVGCAds5eVjKEoZS0KSBwYziLeLW3ZBs8PqPMrljPcg=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0/go.mod h1:cGynoLGY9NfyIeWXI3zZ+hgZdHF3SUi8ht5ygZ8CmhI=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d h1:6fA7kvhKRelVwNWxcMVe2d2lkN8MITY0OIudTBnmT+A=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w=
github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241021160008-f0273be177b4 h1:Nlo+upyp9BVdP2yA9l4Y0T4VvXp5O0nGVm4W5RJsxWU=
github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241021160008-f0273be177b4/go.mod h1:Gi9t38UJU4opGJIS55qhunX2qC4oihlVdRhn7IJhQAg=
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241028074300-17b2cf83d27e h1:rgaVwQErBFpGMS2pbB9MneshkFnzAz0LgU5Mb/YSu84=
Expand Down
1,902 changes: 51 additions & 1,851 deletions config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.5.0
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.4.1-0.20241028071009-a8404d0ab6bb
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241028071009-a8404d0ab6bb
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.0
github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241021160008-f0273be177b4
github.com/openstack-k8s-operators/mariadb-operator/api v0.5.1-0.20241028074300-17b2cf83d27e
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.2024102807
github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241028071009-a8404d0ab6bb/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.0 h1:A8bwCA5B4AyIjt0Qzg0JgvF+HrZ9OQJOrSNq9jOFDpg=
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.0/go.mod h1:djfljx3jfHqywhY3oDvPg/GLKwiFVkds6v7P7/Yg+8g=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0 h1:iVGCAds5eVjKEoZS0KSBwYziLeLW3ZBs8PqPMrljPcg=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.0/go.mod h1:cGynoLGY9NfyIeWXI3zZ+hgZdHF3SUi8ht5ygZ8CmhI=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d h1:6fA7kvhKRelVwNWxcMVe2d2lkN8MITY0OIudTBnmT+A=
github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241104140916-71a0e9d9766d/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w=
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.0 h1:rUVJUKFWQuXYQ3LPNs7wIJdka5EqUmLMT3RRpWkuqRo=
github.com/openstack-k8s-operators/lib-common/modules/test v0.5.0/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o=
github.com/openstack-k8s-operators/manila-operator/api v0.5.1-0.20241021160008-f0273be177b4 h1:Nlo+upyp9BVdP2yA9l4Y0T4VvXp5O0nGVm4W5RJsxWU=
Expand Down
16 changes: 8 additions & 8 deletions pkg/dataplane/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ func (d *Deployer) addCertMounts(
hash := sha256.Sum224([]byte(volumeName))
volumeName = "cert" + hex.EncodeToString(hash[:])
}
certVolume := corev1.Volume{
certVolume := storage.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
VolumeSource: storage.VolumeSource{
Projected: &projectedVolumeSource,
},
}
Expand Down Expand Up @@ -353,9 +353,9 @@ func (d *Deployer) addCertMounts(
hash := sha256.Sum224([]byte(volumeName))
volumeName = "cacert" + hex.EncodeToString(hash[:])
}
cacertVolume := corev1.Volume{
cacertVolume := storage.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
VolumeSource: storage.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: service.Spec.CACerts,
},
Expand Down Expand Up @@ -418,9 +418,9 @@ func (d *Deployer) addServiceExtraMounts(
hash := sha256.Sum224([]byte(volumeName))
volumeName = "cm" + hex.EncodeToString(hash[:])
}
volume := corev1.Volume{
volume := storage.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
VolumeSource: storage.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: cm.Name,
Expand Down Expand Up @@ -464,9 +464,9 @@ func (d *Deployer) addServiceExtraMounts(
hash := sha256.Sum224([]byte(volumeName))
volumeName = "sec" + hex.EncodeToString(hash[:])
}
volume := corev1.Volume{
volume := storage.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
VolumeSource: storage.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: sec.Name,
Items: []corev1.KeyToPath{
Expand Down
4 changes: 2 additions & 2 deletions pkg/dataplane/util/ansible_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ func SetAeeInvMounts(
}

func CreateVolume(ansibleEEMounts *storage.VolMounts, volumeName string, volumeMountPath string, secretName string, keyToPathKey string) {
volume := corev1.Volume{
volume := storage.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
VolumeSource: storage.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: secretName,
Items: []corev1.KeyToPath{
Expand Down
22 changes: 17 additions & 5 deletions pkg/dataplane/util/ansibleee.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
hashes["deployIdentifier"] = a.Labels["deployIdentifier"]
}

a.addMounts(job)
errMounts := a.addMounts(job)
if errMounts != nil {
return nil, errMounts
}
a.addEnvFrom(job)

// if we have any extra vars for ansible to use set them in the RUNNER_EXTRA_VARS
Expand Down Expand Up @@ -236,10 +239,9 @@ func (a *EEJob) addEnvFrom(job *batchv1.Job) {
}
}

func (a *EEJob) addMounts(job *batchv1.Job) {
func (a *EEJob) addMounts(job *batchv1.Job) error {
var volumeMounts []corev1.VolumeMount
var volumes []corev1.Volume

var volumes []storage.Volume
// ExtraMounts propagation: for each volume defined in the top-level CR
// the propagation function provided by lib-common/modules/storage is
// called, and the resulting corev1.Volumes and corev1.Mounts are added
Expand All @@ -252,7 +254,17 @@ func (a *EEJob) addMounts(job *batchv1.Job) {
}

job.Spec.Template.Spec.Containers[0].VolumeMounts = volumeMounts
job.Spec.Template.Spec.Volumes = volumes

var coreVols []corev1.Volume
for _, vol := range volumes {
coreVol, errVol := vol.ToCoreVolume()
if errVol != nil {
return errVol
}
coreVols = append(coreVols, *coreVol)
}
job.Spec.Template.Spec.Volumes = coreVols
return nil
}

func hashPodSpec(
Expand Down

0 comments on commit f6f541e

Please sign in to comment.