Skip to content

Commit d2881bd

Browse files
authored
YDBOPS-9722 fillMissingSections for ConfigMap on operator upgrade (#210)
1 parent b7a1c0e commit d2881bd

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

api/v1alpha1/configuration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func tryFillMissingSections(
8989
}
9090
}
9191

92-
func buildConfiguration(cr *Storage, crDB *Database) (string, error) {
92+
func BuildConfiguration(cr *Storage, crDB *Database) (string, error) {
9393
config := make(map[string]interface{})
9494

9595
// If any kind of configuration exists on Database object, then

api/v1alpha1/database_webhook.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (r *DatabaseDefaulter) Default(ctx context.Context, obj runtime.Object) err
142142
}
143143

144144
if database.Spec.Configuration != "" || (database.Spec.Encryption != nil && database.Spec.Encryption.Enabled) {
145-
configuration, err := buildConfiguration(storage, database)
145+
configuration, err := BuildConfiguration(storage, database)
146146
if err != nil {
147147
return err
148148
}

api/v1alpha1/storage_webhook.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (r *StorageDefaulter) Default(ctx context.Context, obj runtime.Object) erro
166166
storage.Spec.Domain = DefaultDatabaseDomain
167167
}
168168

169-
configuration, err := buildConfiguration(storage, nil)
169+
configuration, err := BuildConfiguration(storage, nil)
170170
if err != nil {
171171
return err
172172
}

deploy/ydb-operator/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.5.12
18+
version: 0.5.13
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "0.5.12"
24+
appVersion: "0.5.13"

internal/controllers/remotestoragenodeset/controller_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
192192
Cluster: testRemoteCluster,
193193
},
194194
StorageNodeSpec: v1alpha1.StorageNodeSpec{
195-
Nodes: 8,
195+
Nodes: 2,
196196
},
197197
})
198198
storageSample.Spec.NodeSets = append(storageSample.Spec.NodeSets, v1alpha1.StorageNodeSetSpecInline{
@@ -201,7 +201,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
201201
Cluster: testRemoteCluster,
202202
},
203203
StorageNodeSpec: v1alpha1.StorageNodeSpec{
204-
Nodes: 4,
204+
Nodes: 2,
205205
},
206206
})
207207

@@ -568,7 +568,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
568568
{
569569
Name: testNodeSetName + "-local",
570570
StorageNodeSpec: v1alpha1.StorageNodeSpec{
571-
Nodes: 4,
571+
Nodes: 6,
572572
},
573573
},
574574
{
@@ -577,7 +577,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
577577
Cluster: testRemoteCluster,
578578
},
579579
StorageNodeSpec: v1alpha1.StorageNodeSpec{
580-
Nodes: 8,
580+
Nodes: 2,
581581
},
582582
},
583583
}

internal/resources/database.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,17 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
5050
var optionalBuilders []ResourceBuilder
5151

5252
if b.Spec.Configuration != "" {
53+
// YDBOPS-9722 backward compatibility
54+
cfg, _ := api.BuildConfiguration(b.Storage, b.Unwrap())
55+
5356
optionalBuilders = append(
5457
optionalBuilders,
5558
&ConfigMapBuilder{
5659
Object: b,
5760

5861
Name: b.GetName(),
5962
Data: map[string]string{
60-
api.ConfigFileName: b.Spec.Configuration,
63+
api.ConfigFileName: cfg,
6164
},
6265
Labels: databaseLabels,
6366
},

internal/resources/storage.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ func (b *StorageClusterBuilder) GetResourceBuilders(restConfig *rest.Config) []R
3939
statusServiceLabels.Merge(map[string]string{labels.ServiceComponent: labels.StatusComponent})
4040

4141
var optionalBuilders []ResourceBuilder
42+
43+
// YDBOPS-9722 backward compatibility
44+
cfg, _ := api.BuildConfiguration(b.Unwrap(), nil)
45+
4246
optionalBuilders = append(
4347
optionalBuilders,
4448
&ConfigMapBuilder{
4549
Object: b,
4650
Name: b.Storage.GetName(),
4751
Data: map[string]string{
48-
api.ConfigFileName: b.Spec.Configuration,
52+
api.ConfigFileName: cfg,
4953
},
5054
Labels: storageLabels,
5155
},

0 commit comments

Comments
 (0)