@@ -524,7 +524,9 @@ func TestServiceAnnotations(t *testing.T) {
524
524
enableReplicaLoadBalancerOC bool
525
525
enableTeamIdClusterPrefix bool
526
526
operatorAnnotations map [string ]string
527
- clusterAnnotations map [string ]string
527
+ serviceAnnotations map [string ]string
528
+ masterServiceAnnotations map [string ]string
529
+ replicaServiceAnnotations map [string ]string
528
530
expect map [string ]string
529
531
}{
530
532
//MASTER
@@ -535,7 +537,7 @@ func TestServiceAnnotations(t *testing.T) {
535
537
enableMasterLoadBalancerOC : false ,
536
538
enableTeamIdClusterPrefix : false ,
537
539
operatorAnnotations : make (map [string ]string ),
538
- clusterAnnotations : make (map [string ]string ),
540
+ serviceAnnotations : make (map [string ]string ),
539
541
expect : make (map [string ]string ),
540
542
},
541
543
{
@@ -545,7 +547,7 @@ func TestServiceAnnotations(t *testing.T) {
545
547
enableMasterLoadBalancerOC : false ,
546
548
enableTeamIdClusterPrefix : false ,
547
549
operatorAnnotations : make (map [string ]string ),
548
- clusterAnnotations : make (map [string ]string ),
550
+ serviceAnnotations : make (map [string ]string ),
549
551
expect : map [string ]string {
550
552
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
551
553
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -558,7 +560,7 @@ func TestServiceAnnotations(t *testing.T) {
558
560
enableMasterLoadBalancerOC : true ,
559
561
enableTeamIdClusterPrefix : false ,
560
562
operatorAnnotations : make (map [string ]string ),
561
- clusterAnnotations : make (map [string ]string ),
563
+ serviceAnnotations : make (map [string ]string ),
562
564
expect : make (map [string ]string ),
563
565
},
564
566
{
@@ -567,7 +569,7 @@ func TestServiceAnnotations(t *testing.T) {
567
569
enableMasterLoadBalancerOC : true ,
568
570
enableTeamIdClusterPrefix : false ,
569
571
operatorAnnotations : make (map [string ]string ),
570
- clusterAnnotations : make (map [string ]string ),
572
+ serviceAnnotations : make (map [string ]string ),
571
573
expect : map [string ]string {
572
574
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
573
575
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -579,7 +581,7 @@ func TestServiceAnnotations(t *testing.T) {
579
581
enableMasterLoadBalancerOC : true ,
580
582
enableTeamIdClusterPrefix : false ,
581
583
operatorAnnotations : make (map [string ]string ),
582
- clusterAnnotations : map [string ]string {"foo" : "bar" },
584
+ serviceAnnotations : map [string ]string {"foo" : "bar" },
583
585
expect : map [string ]string {
584
586
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
585
587
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -593,7 +595,7 @@ func TestServiceAnnotations(t *testing.T) {
593
595
enableMasterLoadBalancerOC : true ,
594
596
enableTeamIdClusterPrefix : false ,
595
597
operatorAnnotations : make (map [string ]string ),
596
- clusterAnnotations : map [string ]string {"foo" : "bar" },
598
+ serviceAnnotations : map [string ]string {"foo" : "bar" },
597
599
expect : map [string ]string {"foo" : "bar" },
598
600
},
599
601
{
@@ -602,7 +604,7 @@ func TestServiceAnnotations(t *testing.T) {
602
604
enableMasterLoadBalancerOC : true ,
603
605
enableTeamIdClusterPrefix : false ,
604
606
operatorAnnotations : map [string ]string {"foo" : "bar" },
605
- clusterAnnotations : make (map [string ]string ),
607
+ serviceAnnotations : make (map [string ]string ),
606
608
expect : map [string ]string {
607
609
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
608
610
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -617,7 +619,7 @@ func TestServiceAnnotations(t *testing.T) {
617
619
operatorAnnotations : map [string ]string {
618
620
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
619
621
},
620
- clusterAnnotations : make (map [string ]string ),
622
+ serviceAnnotations : make (map [string ]string ),
621
623
expect : map [string ]string {
622
624
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
623
625
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
@@ -629,7 +631,7 @@ func TestServiceAnnotations(t *testing.T) {
629
631
enableMasterLoadBalancerOC : true ,
630
632
enableTeamIdClusterPrefix : false ,
631
633
operatorAnnotations : make (map [string ]string ),
632
- clusterAnnotations : map [string ]string {
634
+ serviceAnnotations : map [string ]string {
633
635
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
634
636
},
635
637
expect : map [string ]string {
@@ -643,7 +645,7 @@ func TestServiceAnnotations(t *testing.T) {
643
645
enableMasterLoadBalancerOC : true ,
644
646
enableTeamIdClusterPrefix : false ,
645
647
operatorAnnotations : make (map [string ]string ),
646
- clusterAnnotations : map [string ]string {
648
+ serviceAnnotations : map [string ]string {
647
649
"external-dns.alpha.kubernetes.io/hostname" : "wrong.external-dns-name.example.com" ,
648
650
},
649
651
expect : map [string ]string {
@@ -656,13 +658,30 @@ func TestServiceAnnotations(t *testing.T) {
656
658
role : "master" ,
657
659
enableMasterLoadBalancerOC : true ,
658
660
enableTeamIdClusterPrefix : true ,
659
- clusterAnnotations : make (map [string ]string ),
661
+ serviceAnnotations : make (map [string ]string ),
660
662
operatorAnnotations : make (map [string ]string ),
661
663
expect : map [string ]string {
662
664
"external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
663
665
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
664
666
},
665
667
},
668
+ {
669
+ about : "Master with master service annotations override service annotations" ,
670
+ role : "master" ,
671
+ enableMasterLoadBalancerOC : true ,
672
+ enableTeamIdClusterPrefix : false ,
673
+ operatorAnnotations : make (map [string ]string ),
674
+ serviceAnnotations : map [string ]string {
675
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
676
+ },
677
+ masterServiceAnnotations : map [string ]string {
678
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "2000" ,
679
+ },
680
+ expect : map [string ]string {
681
+ "external-dns.alpha.kubernetes.io/hostname" : "acid-test.test.db.example.com,test.acid.db.example.com" ,
682
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "2000" ,
683
+ },
684
+ },
666
685
// REPLICA
667
686
{
668
687
about : "Replica with no annotations and EnableReplicaLoadBalancer disabled on spec and OperatorConfig" ,
@@ -671,7 +690,7 @@ func TestServiceAnnotations(t *testing.T) {
671
690
enableReplicaLoadBalancerOC : false ,
672
691
enableTeamIdClusterPrefix : false ,
673
692
operatorAnnotations : make (map [string ]string ),
674
- clusterAnnotations : make (map [string ]string ),
693
+ serviceAnnotations : make (map [string ]string ),
675
694
expect : make (map [string ]string ),
676
695
},
677
696
{
@@ -681,7 +700,7 @@ func TestServiceAnnotations(t *testing.T) {
681
700
enableReplicaLoadBalancerOC : false ,
682
701
enableTeamIdClusterPrefix : false ,
683
702
operatorAnnotations : make (map [string ]string ),
684
- clusterAnnotations : make (map [string ]string ),
703
+ serviceAnnotations : make (map [string ]string ),
685
704
expect : map [string ]string {
686
705
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
687
706
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -694,7 +713,7 @@ func TestServiceAnnotations(t *testing.T) {
694
713
enableReplicaLoadBalancerOC : true ,
695
714
enableTeamIdClusterPrefix : false ,
696
715
operatorAnnotations : make (map [string ]string ),
697
- clusterAnnotations : make (map [string ]string ),
716
+ serviceAnnotations : make (map [string ]string ),
698
717
expect : make (map [string ]string ),
699
718
},
700
719
{
@@ -703,7 +722,7 @@ func TestServiceAnnotations(t *testing.T) {
703
722
enableReplicaLoadBalancerOC : true ,
704
723
enableTeamIdClusterPrefix : false ,
705
724
operatorAnnotations : make (map [string ]string ),
706
- clusterAnnotations : make (map [string ]string ),
725
+ serviceAnnotations : make (map [string ]string ),
707
726
expect : map [string ]string {
708
727
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
709
728
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -715,7 +734,7 @@ func TestServiceAnnotations(t *testing.T) {
715
734
enableReplicaLoadBalancerOC : true ,
716
735
enableTeamIdClusterPrefix : false ,
717
736
operatorAnnotations : make (map [string ]string ),
718
- clusterAnnotations : map [string ]string {"foo" : "bar" },
737
+ serviceAnnotations : map [string ]string {"foo" : "bar" },
719
738
expect : map [string ]string {
720
739
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
721
740
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -729,7 +748,7 @@ func TestServiceAnnotations(t *testing.T) {
729
748
enableReplicaLoadBalancerOC : true ,
730
749
enableTeamIdClusterPrefix : false ,
731
750
operatorAnnotations : make (map [string ]string ),
732
- clusterAnnotations : map [string ]string {"foo" : "bar" },
751
+ serviceAnnotations : map [string ]string {"foo" : "bar" },
733
752
expect : map [string ]string {"foo" : "bar" },
734
753
},
735
754
{
@@ -738,7 +757,7 @@ func TestServiceAnnotations(t *testing.T) {
738
757
enableReplicaLoadBalancerOC : true ,
739
758
enableTeamIdClusterPrefix : false ,
740
759
operatorAnnotations : map [string ]string {"foo" : "bar" },
741
- clusterAnnotations : make (map [string ]string ),
760
+ serviceAnnotations : make (map [string ]string ),
742
761
expect : map [string ]string {
743
762
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
744
763
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
@@ -753,7 +772,7 @@ func TestServiceAnnotations(t *testing.T) {
753
772
operatorAnnotations : map [string ]string {
754
773
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
755
774
},
756
- clusterAnnotations : make (map [string ]string ),
775
+ serviceAnnotations : make (map [string ]string ),
757
776
expect : map [string ]string {
758
777
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
759
778
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
@@ -765,7 +784,7 @@ func TestServiceAnnotations(t *testing.T) {
765
784
enableReplicaLoadBalancerOC : true ,
766
785
enableTeamIdClusterPrefix : false ,
767
786
operatorAnnotations : make (map [string ]string ),
768
- clusterAnnotations : map [string ]string {
787
+ serviceAnnotations : map [string ]string {
769
788
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
770
789
},
771
790
expect : map [string ]string {
@@ -779,7 +798,7 @@ func TestServiceAnnotations(t *testing.T) {
779
798
enableReplicaLoadBalancerOC : true ,
780
799
enableTeamIdClusterPrefix : false ,
781
800
operatorAnnotations : make (map [string ]string ),
782
- clusterAnnotations : map [string ]string {
801
+ serviceAnnotations : map [string ]string {
783
802
"external-dns.alpha.kubernetes.io/hostname" : "wrong.external-dns-name.example.com" ,
784
803
},
785
804
expect : map [string ]string {
@@ -792,21 +811,38 @@ func TestServiceAnnotations(t *testing.T) {
792
811
role : "replica" ,
793
812
enableReplicaLoadBalancerOC : true ,
794
813
enableTeamIdClusterPrefix : true ,
795
- clusterAnnotations : make (map [string ]string ),
814
+ serviceAnnotations : make (map [string ]string ),
796
815
operatorAnnotations : make (map [string ]string ),
797
816
expect : map [string ]string {
798
817
"external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
799
818
"service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "3600" ,
800
819
},
801
820
},
821
+ {
822
+ about : "Replica with replica service annotations override service annotations" ,
823
+ role : "replica" ,
824
+ enableReplicaLoadBalancerOC : true ,
825
+ enableTeamIdClusterPrefix : false ,
826
+ operatorAnnotations : make (map [string ]string ),
827
+ serviceAnnotations : map [string ]string {
828
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "1800" ,
829
+ },
830
+ replicaServiceAnnotations : map [string ]string {
831
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "2000" ,
832
+ },
833
+ expect : map [string ]string {
834
+ "external-dns.alpha.kubernetes.io/hostname" : "acid-test-repl.test.db.example.com,test-repl.acid.db.example.com" ,
835
+ "service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout" : "2000" ,
836
+ },
837
+ },
802
838
// COMMON
803
839
{
804
840
about : "cluster annotations append to operator annotations" ,
805
841
role : "replica" ,
806
842
enableReplicaLoadBalancerOC : false ,
807
843
enableTeamIdClusterPrefix : false ,
808
844
operatorAnnotations : map [string ]string {"foo" : "bar" },
809
- clusterAnnotations : map [string ]string {"post" : "gres" },
845
+ serviceAnnotations : map [string ]string {"post" : "gres" },
810
846
expect : map [string ]string {"foo" : "bar" , "post" : "gres" },
811
847
},
812
848
{
@@ -815,7 +851,7 @@ func TestServiceAnnotations(t *testing.T) {
815
851
enableReplicaLoadBalancerOC : false ,
816
852
enableTeamIdClusterPrefix : false ,
817
853
operatorAnnotations : map [string ]string {"foo" : "bar" , "post" : "gres" },
818
- clusterAnnotations : map [string ]string {"post" : "greSQL" },
854
+ serviceAnnotations : map [string ]string {"post" : "greSQL" },
819
855
expect : map [string ]string {"foo" : "bar" , "post" : "greSQL" },
820
856
},
821
857
}
@@ -833,7 +869,9 @@ func TestServiceAnnotations(t *testing.T) {
833
869
834
870
cl .Postgresql .Spec .ClusterName = ""
835
871
cl .Postgresql .Spec .TeamID = "acid"
836
- cl .Postgresql .Spec .ServiceAnnotations = tt .clusterAnnotations
872
+ cl .Postgresql .Spec .ServiceAnnotations = tt .serviceAnnotations
873
+ cl .Postgresql .Spec .MasterServiceAnnotations = tt .masterServiceAnnotations
874
+ cl .Postgresql .Spec .ReplicaServiceAnnotations = tt .replicaServiceAnnotations
837
875
cl .Postgresql .Spec .EnableMasterLoadBalancer = tt .enableMasterLoadBalancerSpec
838
876
cl .Postgresql .Spec .EnableReplicaLoadBalancer = tt .enableReplicaLoadBalancerSpec
839
877
0 commit comments