Skip to content

Commit e50c1ad

Browse files
committed
fixes last-applied annotation
1 parent a313d8c commit e50c1ad

File tree

5 files changed

+8
-32
lines changed

5 files changed

+8
-32
lines changed

internal/annotations/annotations.go

+2-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const (
88
RemoteResourceVersionAnnotation = "ydb.tech/remote-resource-version"
99
ConfigurationChecksum = "ydb.tech/configuration-checksum"
1010
RemoteFinalizerKey = "ydb.tech/remote-finalizer"
11-
LastAppliedAnnotation = "ydb.tech/last-applied"
11+
LastApplied = "ydb.tech/last-applied"
1212
)
1313

1414
func GetYdbTechAnnotations(annotations map[string]string) map[string]string {
@@ -23,31 +23,13 @@ func GetYdbTechAnnotations(annotations map[string]string) map[string]string {
2323

2424
func GetLastAppliedAnnotation(annotations map[string]string) string {
2525
for key, value := range annotations {
26-
if key == LastAppliedAnnotation {
26+
if key == LastApplied {
2727
return value
2828
}
2929
}
3030
return ""
3131
}
3232

33-
func CompareMaps(map1, map2 map[string]string) bool {
34-
if len(map1) != len(map2) {
35-
return false
36-
}
37-
for key1, value1 := range map1 {
38-
if value2, ok := map2[key1]; !ok || value2 != value1 {
39-
return false
40-
}
41-
}
42-
return true
43-
}
44-
45-
func CompareYdbTechAnnotations(map1, map2 map[string]string) bool {
46-
map1 = GetYdbTechAnnotations(map1)
47-
map2 = GetYdbTechAnnotations(map2)
48-
return CompareMaps(map1, map2)
49-
}
50-
5133
func CompareLastAppliedAnnotation(map1, map2 map[string]string) bool {
5234
value1 := GetLastAppliedAnnotation(map1)
5335
value2 := GetLastAppliedAnnotation(map2)

internal/resources/database.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ func (b *DatabaseBuilder) NewLabels() labels.Labels {
4242

4343
func (b *DatabaseBuilder) NewAnnotations() map[string]string {
4444
an := annotations.GetYdbTechAnnotations(b.Annotations)
45-
an[annotations.ConfigurationChecksum] = GetSHA256Checksum(b.Spec.Configuration)
46-
delete(an, annotations.LastAppliedAnnotation)
47-
4845
for k, v := range b.Spec.AdditionalAnnotations {
4946
an[k] = v
5047
}
51-
48+
an[annotations.ConfigurationChecksum] = GetSHA256Checksum(b.Spec.Configuration)
49+
delete(an, annotations.LastApplied)
5250
return an
5351
}
5452

internal/resources/resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ type ResourceBuilder interface {
8585
}
8686

8787
var (
88-
annotator = patch.NewAnnotator(ydbannotations.LastAppliedAnnotation)
88+
annotator = patch.NewAnnotator(ydbannotations.LastApplied)
8989
patchMaker = patch.NewPatchMaker(annotator)
9090
)
9191

internal/resources/storage.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ func (b *StorageClusterBuilder) NewLabels() labels.Labels {
4242

4343
func (b *StorageClusterBuilder) NewAnnotations() map[string]string {
4444
an := annotations.GetYdbTechAnnotations(b.Annotations)
45-
an[annotations.ConfigurationChecksum] = GetSHA256Checksum(b.Spec.Configuration)
46-
delete(an, annotations.LastAppliedAnnotation)
47-
4845
for k, v := range b.Spec.AdditionalAnnotations {
4946
an[k] = v
5047
}
51-
48+
an[annotations.ConfigurationChecksum] = GetSHA256Checksum(b.Spec.Configuration)
49+
delete(an, annotations.LastApplied)
5250
return an
5351
}
5452

internal/resources/storage_init_job.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ func GetInitJobBuilder(storage *api.Storage) ResourceBuilder {
6060
jobName := fmt.Sprintf(InitJobNameFormat, storage.Name)
6161

6262
jobLabels := labels.Common(storage.Name, labels.Labels{})
63-
jobLabels.Merge(storage.Spec.AdditionalLabels)
64-
65-
jobAnnotations := CopyDict(storage.Spec.AdditionalAnnotations)
63+
jobAnnotations := make(map[string]string)
6664

6765
if storage.Spec.InitJob != nil {
6866
if storage.Spec.InitJob.AdditionalLabels != nil {

0 commit comments

Comments
 (0)