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

YDBOPS-9635 use configMap from Storage if Database .spec.configuration empty #199

Merged
merged 4 commits into from
May 13, 2024
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
10 changes: 6 additions & 4 deletions api/v1alpha1/database_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ func (r *DatabaseDefaulter) Default(ctx context.Context, obj runtime.Object) err
database.Spec.StorageEndpoint = storage.GetStorageEndpointWithProto()
}

configuration, err := buildConfiguration(storage, database)
if err != nil {
return err
if database.Spec.Configuration != "" || (database.Spec.Encryption != nil && database.Spec.Encryption.Enabled) {
configuration, err := buildConfiguration(storage, database)
if err != nil {
return err
}
database.Spec.Configuration = configuration
}
database.Spec.Configuration = configuration

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions deploy/ydb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.5.6
version: 0.5.7

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.5.6"
appVersion: "0.5.7"
4 changes: 2 additions & 2 deletions internal/controllers/remotedatabasenodeset/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ var _ = Describe("RemoteDatabaseNodeSet controller tests", func() {

foundConfigMap := corev1.ConfigMap{}
Expect(remoteClient.Get(ctx, types.NamespacedName{
Name: databaseSample.Name,
Name: storageSample.Name,
Namespace: testobjects.YdbNamespace,
}, &foundConfigMap)).Should(Succeed())

Expand Down Expand Up @@ -791,7 +791,7 @@ var _ = Describe("RemoteDatabaseNodeSet controller tests", func() {

foundConfigMap := corev1.ConfigMap{}
Expect(remoteClient.Get(ctx, types.NamespacedName{
Name: databaseSample.Name,
Name: storageSample.Name,
Namespace: testobjects.YdbNamespace,
}, &foundConfigMap)).Should(Succeed())

Expand Down
22 changes: 12 additions & 10 deletions internal/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,20 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc

var optionalBuilders []ResourceBuilder

optionalBuilders = append(
optionalBuilders,
&ConfigMapBuilder{
Object: b,
if b.Spec.Configuration != "" {
optionalBuilders = append(
optionalBuilders,
&ConfigMapBuilder{
Object: b,

Name: b.GetName(),
Data: map[string]string{
api.ConfigFileName: b.Spec.Configuration,
Name: b.GetName(),
Data: map[string]string{
api.ConfigFileName: b.Spec.Configuration,
},
Labels: databaseLabels,
},
Labels: databaseLabels,
},
)
)
}

if b.Spec.Monitoring != nil && b.Spec.Monitoring.Enabled {
optionalBuilders = append(optionalBuilders,
Expand Down
5 changes: 4 additions & 1 deletion internal/resources/database_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSp
}

func (b *DatabaseStatefulSetBuilder) buildVolumes() []corev1.Volume {
configMapName := b.Database.Name
configMapName := b.Spec.StorageClusterRef.Name
if b.Spec.Configuration != "" {
configMapName = b.GetName()
}

volumes := []corev1.Volume{
{
Expand Down
24 changes: 17 additions & 7 deletions internal/resources/remotedatabasenodeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,23 @@ func (b *RemoteDatabaseNodeSetResource) GetRemoteObjects(
}

// sync ConfigMap
remoteObjects = append(remoteObjects,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: b.Spec.DatabaseRef.Name,
Namespace: b.Namespace,
},
})
if b.Spec.Configuration != "" {
remoteObjects = append(remoteObjects,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: b.Spec.DatabaseRef.Name,
Namespace: b.Namespace,
},
})
} else {
remoteObjects = append(remoteObjects,
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: b.Spec.StorageClusterRef.Name,
Namespace: b.Namespace,
},
})
}

// sync Services
remoteObjects = append(remoteObjects,
Expand Down
Loading