Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add posibilities to specify metadata password selector per cell #809

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,15 @@ spec:
description: MetadataSecret - the name of the field to get the
metadata secret from the Secret
type: string
prefixMetadataCellsSecret:
default: MetadataCellsSecret
description: prefixMetadataCellsSecret - the prefix name of the
field to get the metadata secret from the Secret for cells.
Vale of metadata_proxy_shared_secret information for the nova-metadata
service. This secret is shared between nova and neutron ovn-metadata
inside selected cell and if this is not defined the global metadata_proxy_shared_secret
secret will be used
type: string
service:
default: NovaPassword
description: Service - Selector to get the keystone service user
Expand Down
9 changes: 9 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ type PasswordSelector struct {
// MetadataSecret - the name of the field to get the metadata secret from the
// Secret
MetadataSecret string `json:"metadataSecret"`
// +kubebuilder:validation:Optional
// +kubebuilder:default="MetadataCellsSecret"
// prefixMetadataCellsSecret - the prefix name of the field to get the metadata secret from the
// Secret for cells. Vale of metadata_proxy_shared_secret
// information for the nova-metadata service. This secret is shared
// between nova and neutron ovn-metadata inside selected cell
// and if this is not defined the global metadata_proxy_shared_secret
// secret will be used
PrefixMetadataCellsSecret string `json:"prefixMetadataCellsSecret"`
}

type NovaImages struct {
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,15 @@ spec:
description: MetadataSecret - the name of the field to get the
metadata secret from the Secret
type: string
prefixMetadataCellsSecret:
default: MetadataCellsSecret
description: prefixMetadataCellsSecret - the prefix name of the
field to get the metadata secret from the Secret for cells.
Vale of metadata_proxy_shared_secret information for the nova-metadata
service. This secret is shared between nova and neutron ovn-metadata
inside selected cell and if this is not defined the global metadata_proxy_shared_secret
secret will be used
type: string
service:
default: NovaPassword
description: Service - Selector to get the keystone service user
Expand Down
7 changes: 6 additions & 1 deletion controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,12 @@ func (r *NovaReconciler) ensureCellSecret(
// If metadata is enabled in the cell then the cell secret needs the
// metadata shared secret
if *cellTemplate.MetadataServiceTemplate.Enabled {
data[MetadataSecretSelector] = string(externalSecret.Data[instance.Spec.PasswordSelectors.MetadataSecret])
val, ok := externalSecret.Data[instance.Spec.PasswordSelectors.PrefixMetadataCellsSecret+cellName]
if ok {
data[MetadataSecretSelector] = string(val)
} else {
data[MetadataSecretSelector] = string(externalSecret.Data[instance.Spec.PasswordSelectors.MetadataSecret])
}
}

// NOTE(gibi): When we switch to immutable secrets then we need to include
Expand Down
14 changes: 12 additions & 2 deletions test/functional/nova_multicell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,15 @@ var _ = Describe("Nova multi cell", func() {
})
When("Nova CR instance is created with metadata per cell", func() {
BeforeEach(func() {
DeferCleanup(k8sClient.Delete, ctx, CreateNovaSecret(novaNames.NovaName.Namespace, SecretName))
novaSecret := th.CreateSecret(
types.NamespacedName{Namespace: novaNames.NovaName.Namespace, Name: SecretName},
map[string][]byte{
"NovaPassword": []byte("service-password"),
"MetadataSecret": []byte("metadata-secret"),
"MetadataCellsSecret" + cell1.CellName: []byte("metadata-secret-cell1"),
},
)
DeferCleanup(k8sClient.Delete, ctx, novaSecret)
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell0))
DeferCleanup(k8sClient.Delete, ctx, CreateNovaMessageBusSecret(cell1))

Expand Down Expand Up @@ -935,10 +943,12 @@ var _ = Describe("Nova multi cell", func() {

cell1Secret := th.GetSecret(cell1.InternalCellSecretName)
Expect(cell1Secret.Data).To(
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret")))
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret-cell1")))
cell0Secret := th.GetSecret(cell0.InternalCellSecretName)
Expect(cell0Secret.Data).NotTo(
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret")))
Expect(cell0Secret.Data).NotTo(
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret-cell1")))
})
})
})
Loading