77 "log"
88 "regexp"
99 "strconv"
10+ "strings"
1011
1112 appsv1 "k8s.io/api/apps/v1"
1213 corev1 "k8s.io/api/core/v1"
@@ -16,6 +17,7 @@ import (
1617 "sigs.k8s.io/controller-runtime/pkg/client"
1718
1819 api "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
20+ "github.com/ydb-platform/ydb-kubernetes-operator/internal/annotations"
1921 "github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
2022 "github.com/ydb-platform/ydb-kubernetes-operator/internal/ptr"
2123)
@@ -63,9 +65,11 @@ func (b *DatabaseStatefulSetBuilder) Build(obj client.Object) error {
6365 Template : b .buildPodTemplateSpec (),
6466 }
6567
66- if value , ok := b .ObjectMeta .Annotations [api .AnnotationUpdateStrategyOnDelete ]; ok && value == api .AnnotationValueTrue {
67- sts .Spec .UpdateStrategy = appsv1.StatefulSetUpdateStrategy {
68- Type : "OnDelete" ,
68+ if value , ok := b .ObjectMeta .Annotations [api .AnnotationUpdateStrategyOnDelete ]; ok {
69+ if isTrue , _ := strconv .ParseBool (value ); isTrue {
70+ sts .Spec .UpdateStrategy = appsv1.StatefulSetUpdateStrategy {
71+ Type : "OnDelete" ,
72+ }
6973 }
7074 }
7175
@@ -129,12 +133,10 @@ func (b *DatabaseStatefulSetBuilder) buildPodTemplateSpec() corev1.PodTemplateSp
129133 }
130134
131135 if value , ok := b .ObjectMeta .Annotations [api .AnnotationUpdateDNSPolicy ]; ok {
132- switch value {
133- case string (corev1 .DNSClusterFirstWithHostNet ), string (corev1 .DNSClusterFirst ), string (corev1 .DNSDefault ), string (corev1 .DNSNone ):
134- podTemplate .Spec .DNSPolicy = corev1 .DNSPolicy (value )
135- case "" :
136- podTemplate .Spec .DNSPolicy = corev1 .DNSClusterFirst
137- default :
136+ for _ , acceptedPolicy := range annotations .AcceptedDNSPolicy {
137+ if value == acceptedPolicy {
138+ podTemplate .Spec .DNSPolicy = corev1 .DNSPolicy (value )
139+ }
138140 }
139141 }
140142
@@ -412,13 +414,17 @@ func (b *DatabaseStatefulSetBuilder) buildContainer() corev1.Container {
412414 },
413415 }
414416
415- if value , ok := b .ObjectMeta .Annotations [api .AnnotationDisableLivenessProbe ]; ! ok || value != api .AnnotationValueTrue {
416- container .LivenessProbe = & corev1.Probe {
417- ProbeHandler : corev1.ProbeHandler {
418- TCPSocket : & corev1.TCPSocketAction {
419- Port : intstr .FromInt (api .GRPCPort ),
420- },
417+ container .LivenessProbe = & corev1.Probe {
418+ ProbeHandler : corev1.ProbeHandler {
419+ TCPSocket : & corev1.TCPSocketAction {
420+ Port : intstr .FromInt (api .GRPCPort ),
421421 },
422+ },
423+ }
424+
425+ if value , ok := b .ObjectMeta .Annotations [api .AnnotationDisableLivenessProbe ]; ok {
426+ if isTrue , _ := strconv .ParseBool (value ); isTrue {
427+ container .LivenessProbe = nil
422428 }
423429 }
424430
@@ -648,6 +654,9 @@ func (b *DatabaseStatefulSetBuilder) buildContainerArgs() ([]string, []string) {
648654 }
649655
650656 if value , ok := b .ObjectMeta .Annotations [api .AnnotationNodeHost ]; ok {
657+ if ! strings .HasPrefix (value , "$(NODE_NAME)." ) {
658+ value = fmt .Sprintf ("%s.%s" , "$(NODE_NAME)" , value )
659+ }
651660 args = append (args ,
652661 "--node-host" ,
653662 value ,
0 commit comments