@@ -31,25 +31,34 @@ func (b *DatabaseBuilder) Unwrap() *api.Database {
3131 return b .DeepCopy ()
3232}
3333
34- func DatabaseLabels ( database * api. Database ) labels.Labels {
35- l := labels .Common (database .Name , database .Labels )
34+ func ( b * DatabaseBuilder ) NewLabels ( ) labels.Labels {
35+ l := labels .Common (b .Name , b .Labels )
3636
37- l .Merge (database .Spec .AdditionalLabels )
38- l .Merge (map [string ]string {
39- labels .ComponentKey : labels .DynamicComponent ,
40- })
37+ l .Merge (b .Spec .AdditionalLabels )
38+ l .Merge (map [string ]string {labels .ComponentKey : labels .DynamicComponent })
4139
4240 return l
4341}
4442
43+ func (b * DatabaseBuilder ) NewAnnotations () map [string ]string {
44+ an := annotations .GetYdbTechAnnotations (b .Annotations )
45+ an [annotations .ConfigurationChecksum ] = GetSHA256Checksum (b .Spec .Configuration )
46+ delete (an , annotations .LastAppliedAnnotation )
47+
48+ for k , v := range b .Spec .AdditionalAnnotations {
49+ an [k ] = v
50+ }
51+
52+ return an
53+ }
54+
4555func (b * DatabaseBuilder ) GetResourceBuilders (restConfig * rest.Config ) []ResourceBuilder {
4656 if b .Spec .ServerlessResources != nil {
4757 return []ResourceBuilder {}
4858 }
4959
50- databaseLabels := DatabaseLabels (b .Unwrap ())
51- databaseAnnotations := annotations .GetYdbTechAnnotations (b .Annotations )
52- delete (databaseAnnotations , annotations .LastAppliedAnnotation )
60+ databaseLabels := b .NewLabels ()
61+ databaseAnnotations := b .NewAnnotations ()
5362
5463 grpcServiceLabels := databaseLabels .Copy ()
5564 grpcServiceLabels .Merge (b .Spec .Service .GRPC .AdditionalLabels )
@@ -67,11 +76,6 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
6776 datastreamsServiceLabels .Merge (b .Spec .Service .Datastreams .AdditionalLabels )
6877 datastreamsServiceLabels .Merge (map [string ]string {labels .ServiceComponent : labels .DatastreamsComponent })
6978
70- statefulSetAnnotations := CopyDict (databaseAnnotations )
71- for k , v := range b .Spec .AdditionalAnnotations {
72- statefulSetAnnotations [k ] = v
73- }
74-
7579 var optionalBuilders []ResourceBuilder
7680
7781 if b .Spec .Configuration != "" {
@@ -197,7 +201,7 @@ func (b *DatabaseBuilder) GetResourceBuilders(restConfig *rest.Config) []Resourc
197201
198202 Name : b .Name ,
199203 Labels : databaseLabels ,
200- Annotations : statefulSetAnnotations ,
204+ Annotations : databaseAnnotations ,
201205 },
202206 )
203207 } else {
@@ -221,6 +225,8 @@ func (b *DatabaseBuilder) getNodeSetBuilders(
221225
222226 nodeSetLabels := databaseLabels .Copy ()
223227 nodeSetLabels .Merge (nodeSetSpecInline .Labels )
228+
229+ nodeSetLabels [labels .DatabaseNodeSetComponent ] = nodeSetSpecInline .Name
224230 if nodeSetSpecInline .Remote != nil {
225231 nodeSetLabels [labels .RemoteClusterKey ] = nodeSetSpecInline .Remote .Cluster
226232 }
@@ -230,7 +236,7 @@ func (b *DatabaseBuilder) getNodeSetBuilders(
230236 nodeSetAnnotations [k ] = v
231237 }
232238
233- databaseNodeSetSpec := b .recastDatabaseNodeSetSpecInline (nodeSetSpecInline .DeepCopy ())
239+ nodeSetSpec := b .recastDatabaseNodeSetSpecInline (nodeSetSpecInline .DeepCopy ())
234240
235241 if nodeSetSpecInline .Remote != nil {
236242 nodeSetBuilders = append (
@@ -242,7 +248,7 @@ func (b *DatabaseBuilder) getNodeSetBuilders(
242248 Labels : nodeSetLabels ,
243249 Annotations : nodeSetAnnotations ,
244250
245- DatabaseNodeSetSpec : databaseNodeSetSpec ,
251+ DatabaseNodeSetSpec : nodeSetSpec ,
246252 },
247253 )
248254 } else {
@@ -255,7 +261,7 @@ func (b *DatabaseBuilder) getNodeSetBuilders(
255261 Labels : nodeSetLabels ,
256262 Annotations : nodeSetAnnotations ,
257263
258- DatabaseNodeSetSpec : databaseNodeSetSpec ,
264+ DatabaseNodeSetSpec : nodeSetSpec ,
259265 },
260266 )
261267 }
@@ -297,15 +303,14 @@ func (b *DatabaseBuilder) recastDatabaseNodeSetSpecInline(nodeSetSpecInline *api
297303 }
298304
299305 if nodeSetSpecInline .TopologySpreadConstraints != nil {
300- nodeSetSpec .TopologySpreadConstraints = append ([]corev1. TopologySpreadConstraint {}, nodeSetSpecInline .TopologySpreadConstraints ... )
306+ nodeSetSpec .TopologySpreadConstraints = nodeSetSpecInline .TopologySpreadConstraints
301307 }
302308
303309 if nodeSetSpecInline .Tolerations != nil {
304310 nodeSetSpec .Tolerations = append (nodeSetSpec .Tolerations , nodeSetSpecInline .Tolerations ... )
305311 }
306312
307313 nodeSetSpec .AdditionalLabels = CopyDict (b .Spec .AdditionalLabels )
308- nodeSetSpec .AdditionalLabels [labels .DatabaseNodeSetComponent ] = nodeSetSpecInline .Name
309314 if nodeSetSpecInline .AdditionalLabels != nil {
310315 for k , v := range nodeSetSpecInline .AdditionalLabels {
311316 nodeSetSpec .AdditionalLabels [k ] = v
0 commit comments