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-9722 fillMissingSections for ConfigMap on operator upgrade #210

Merged
merged 4 commits into from
Jun 14, 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
2 changes: 1 addition & 1 deletion api/v1alpha1/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func tryFillMissingSections(
}
}

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

// If any kind of configuration exists on Database object, then
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/database_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (r *DatabaseDefaulter) Default(ctx context.Context, obj runtime.Object) err
}

if database.Spec.Configuration != "" || (database.Spec.Encryption != nil && database.Spec.Encryption.Enabled) {
configuration, err := buildConfiguration(storage, database)
configuration, err := BuildConfiguration(storage, database)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/storage_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (r *StorageDefaulter) Default(ctx context.Context, obj runtime.Object) erro
storage.Spec.Domain = DefaultDatabaseDomain
}

configuration, err := buildConfiguration(storage, nil)
configuration, err := BuildConfiguration(storage, nil)
if err != nil {
return err
}
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.12
version: 0.5.13

# 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.12"
appVersion: "0.5.13"
8 changes: 4 additions & 4 deletions internal/controllers/remotestoragenodeset/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
Cluster: testRemoteCluster,
},
StorageNodeSpec: v1alpha1.StorageNodeSpec{
Nodes: 8,
Nodes: 2,
},
})
storageSample.Spec.NodeSets = append(storageSample.Spec.NodeSets, v1alpha1.StorageNodeSetSpecInline{
Expand All @@ -201,7 +201,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
Cluster: testRemoteCluster,
},
StorageNodeSpec: v1alpha1.StorageNodeSpec{
Nodes: 4,
Nodes: 2,
},
})

Expand Down Expand Up @@ -568,7 +568,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
{
Name: testNodeSetName + "-local",
StorageNodeSpec: v1alpha1.StorageNodeSpec{
Nodes: 4,
Nodes: 6,
},
},
{
Expand All @@ -577,7 +577,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
Cluster: testRemoteCluster,
},
StorageNodeSpec: v1alpha1.StorageNodeSpec{
Nodes: 8,
Nodes: 2,
},
},
}
Expand Down
5 changes: 4 additions & 1 deletion internal/resources/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
var optionalBuilders []ResourceBuilder

if b.Spec.Configuration != "" {
// YDBOPS-9722 backward compatibility
cfg, _ := api.BuildConfiguration(b.Storage, b.Unwrap())

optionalBuilders = append(
optionalBuilders,
&ConfigMapBuilder{
Object: b,

Name: b.GetName(),
Data: map[string]string{
api.ConfigFileName: b.Spec.Configuration,
api.ConfigFileName: cfg,
},
Labels: databaseLabels,
},
Expand Down
6 changes: 5 additions & 1 deletion internal/resources/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ func (b *StorageClusterBuilder) GetResourceBuilders(restConfig *rest.Config) []R
statusServiceLabels.Merge(map[string]string{labels.ServiceComponent: labels.StatusComponent})

var optionalBuilders []ResourceBuilder

// YDBOPS-9722 backward compatibility
cfg, _ := api.BuildConfiguration(b.Unwrap(), nil)

optionalBuilders = append(
optionalBuilders,
&ConfigMapBuilder{
Object: b,
Name: b.Storage.GetName(),
Data: map[string]string{
api.ConfigFileName: b.Spec.Configuration,
api.ConfigFileName: cfg,
},
Labels: storageLabels,
},
Expand Down
Loading