Skip to content

Commit ada0a42

Browse files
authored
fix encryption config ID backward compatibility (ydb-platform#244)
* fix encryption config ID backward compatibility * revert database encryption key secret path
1 parent 52154b3 commit ada0a42

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

api/v1alpha1/const.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const (
3030
ConfigDir = "/opt/ydb/cfg"
3131
ConfigFileName = "config.yaml"
3232

33-
DatabaseEncryptionKeySecretDir = "encryption"
34-
DatabaseEncryptionKeySecretFile = "key.pem"
33+
DatabaseEncryptionKeySecretDir = "database_encryption"
34+
DatabaseEncryptionKeySecretFile = "key"
3535
DatabaseEncryptionKeyConfigFile = "key.txt"
3636

3737
BinariesDir = "/opt/ydb/bin"

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.24
18+
version: 0.5.25
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.24"
24+
appVersion: "0.5.25"

internal/controllers/storage/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ var _ = Describe("Storage controller medium tests", func() {
123123
}, &foundStorage)).Should(Succeed())
124124

125125
foundConfigurationChecksumAnnotation := false
126-
if podAnnotations[annotations.ConfigurationChecksum] == resources.GetConfigurationChecksum(foundStorage.Spec.Configuration) {
126+
if podAnnotations[annotations.ConfigurationChecksum] == resources.SHAChecksum(foundStorage.Spec.Configuration) {
127127
foundConfigurationChecksumAnnotation = true
128128
}
129129
Expect(foundConfigurationChecksumAnnotation).To(BeTrue())

internal/resources/database.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
4343
statefulSetLabels.Merge(map[string]string{labels.StatefulsetComponent: b.Name})
4444

4545
statefulSetAnnotations := CopyDict(b.Spec.AdditionalAnnotations)
46-
statefulSetAnnotations[annotations.ConfigurationChecksum] = GetConfigurationChecksum(b.Spec.Configuration)
46+
statefulSetAnnotations[annotations.ConfigurationChecksum] = SHAChecksum(b.Spec.Configuration)
4747

4848
grpcServiceLabels := databaseLabels.Copy()
4949
grpcServiceLabels.Merge(b.Spec.Service.GRPC.AdditionalLabels)
@@ -123,7 +123,7 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
123123
api.DatabaseEncryptionKeySecretDir,
124124
api.DatabaseEncryptionKeySecretFile,
125125
),
126-
ID: b.Name,
126+
ID: SHAChecksum(b.Spec.StorageClusterRef.Name),
127127
Pin: b.Spec.Encryption.Pin,
128128
Version: 1,
129129
},

internal/resources/databasenodeset.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (b *DatabaseNodeSetResource) GetResourceBuilders(restConfig *rest.Config) [
6969
}
7070

7171
statefulSetAnnotations := CopyDict(b.Spec.AdditionalAnnotations)
72-
statefulSetAnnotations[annotations.ConfigurationChecksum] = GetConfigurationChecksum(b.Spec.Configuration)
72+
statefulSetAnnotations[annotations.ConfigurationChecksum] = SHAChecksum(b.Spec.Configuration)
7373

7474
var resourceBuilders []ResourceBuilder
7575
resourceBuilders = append(resourceBuilders,

internal/resources/resource.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -564,9 +564,9 @@ func buildCAStorePatchingCommandArgs(
564564
return command, args
565565
}
566566

567-
func GetConfigurationChecksum(configuration string) string {
567+
func SHAChecksum(text string) string {
568568
hasher := sha256.New()
569-
hasher.Write([]byte(configuration))
569+
hasher.Write([]byte(text))
570570
return hex.EncodeToString(hasher.Sum(nil))
571571
}
572572

internal/resources/storage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (b *StorageClusterBuilder) GetResourceBuilders(restConfig *rest.Config) []R
3636
statefulSetLabels.Merge(map[string]string{labels.StatefulsetComponent: b.Name})
3737

3838
statefulSetAnnotations := CopyDict(b.Spec.AdditionalAnnotations)
39-
statefulSetAnnotations[annotations.ConfigurationChecksum] = GetConfigurationChecksum(b.Spec.Configuration)
39+
statefulSetAnnotations[annotations.ConfigurationChecksum] = SHAChecksum(b.Spec.Configuration)
4040

4141
grpcServiceLabels := storageLabels.Copy()
4242
grpcServiceLabels.Merge(b.Spec.Service.GRPC.AdditionalLabels)

internal/resources/storage_init_job.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func GetInitJobBuilder(storage *api.Storage) ResourceBuilder {
7070
}
7171
if storage.Spec.InitJob.AdditionalAnnotations != nil {
7272
jobAnnotations = CopyDict(storage.Spec.InitJob.AdditionalAnnotations)
73-
jobAnnotations[annotations.ConfigurationChecksum] = GetConfigurationChecksum(storage.Spec.Configuration)
73+
jobAnnotations[annotations.ConfigurationChecksum] = SHAChecksum(storage.Spec.Configuration)
7474
}
7575
}
7676

internal/resources/storagenodeset.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (b *StorageNodeSetResource) GetResourceBuilders(restConfig *rest.Config) []
6969
}
7070

7171
statefulSetAnnotations := CopyDict(b.Spec.AdditionalAnnotations)
72-
statefulSetAnnotations[annotations.ConfigurationChecksum] = GetConfigurationChecksum(b.Spec.Configuration)
72+
statefulSetAnnotations[annotations.ConfigurationChecksum] = SHAChecksum(b.Spec.Configuration)
7373

7474
var resourceBuilders []ResourceBuilder
7575
resourceBuilders = append(

0 commit comments

Comments
 (0)