@@ -1752,9 +1752,13 @@ def test_password_rotation(self):
1752
1752
Test password rotation and removal of users due to retention policy
1753
1753
'''
1754
1754
k8s = self .k8s
1755
+ cluster_label = 'application=spilo,cluster-name=acid-minimal-cluster'
1755
1756
leader = k8s .get_cluster_leader_pod ()
1756
1757
today = date .today ()
1757
1758
1759
+ # remember number of secrets to make sure it stays the same
1760
+ secret_count = k8s .count_secrets_with_label (cluster_label )
1761
+
1758
1762
# enable password rotation for owner of foo database
1759
1763
pg_patch_rotation_single_users = {
1760
1764
"spec" : {
@@ -1810,6 +1814,7 @@ def test_password_rotation(self):
1810
1814
enable_password_rotation = {
1811
1815
"data" : {
1812
1816
"enable_password_rotation" : "true" ,
1817
+ "inherited_annotations" : "environment" ,
1813
1818
"password_rotation_interval" : "30" ,
1814
1819
"password_rotation_user_retention" : "30" , # should be set to 60
1815
1820
},
@@ -1856,13 +1861,29 @@ def test_password_rotation(self):
1856
1861
self .eventuallyEqual (lambda : len (self .query_database_with_user (leader .metadata .name , "postgres" , "SELECT 1" , "foo_user" )), 1 ,
1857
1862
"Could not connect to the database with rotation user {}" .format (rotation_user ), 10 , 5 )
1858
1863
1864
+ # add annotation which triggers syncSecrets call
1865
+ pg_annotation_patch = {
1866
+ "metadata" : {
1867
+ "annotations" : {
1868
+ "environment" : "test" ,
1869
+ }
1870
+ }
1871
+ }
1872
+ k8s .api .custom_objects_api .patch_namespaced_custom_object (
1873
+ "acid.zalan.do" , "v1" , "default" , "postgresqls" , "acid-minimal-cluster" , pg_annotation_patch )
1874
+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1875
+ time .sleep (10 )
1876
+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (cluster_label ), secret_count , "Unexpected number of secrets" )
1877
+
1859
1878
# check if rotation has been ignored for user from test_cross_namespace_secrets test
1860
1879
db_user_secret = k8s .get_secret (username = "test.db_user" , namespace = "test" )
1861
1880
secret_username = str (base64 .b64decode (db_user_secret .data ["username" ]), 'utf-8' )
1862
-
1863
1881
self .assertEqual ("test.db_user" , secret_username ,
1864
1882
"Unexpected username in secret of test.db_user: expected {}, got {}" .format ("test.db_user" , secret_username ))
1865
1883
1884
+ # check if annotation for secret has been updated
1885
+ self .assertTrue ("environment" in db_user_secret .metadata .annotations , "Added annotation was not propagated to secret" )
1886
+
1866
1887
# disable password rotation for all other users (foo_user)
1867
1888
# and pick smaller intervals to see if the third fake rotation user is dropped
1868
1889
enable_password_rotation = {
@@ -2100,7 +2121,7 @@ def test_statefulset_annotation_propagation(self):
2100
2121
patch_sset_propagate_annotations = {
2101
2122
"data" : {
2102
2123
"downscaler_annotations" : "deployment-time,downscaler/*" ,
2103
- "inherited_annotations" : "owned-by" ,
2124
+ "inherited_annotations" : "environment, owned-by" ,
2104
2125
}
2105
2126
}
2106
2127
k8s .update_config (patch_sset_propagate_annotations )
0 commit comments