mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 14:49:14 +02:00
Support inherited annotations for all major objects (#1236)
* add comments where inherited annotations could be added * add inheritedAnnotations feature * return nil if no annotations are set * minor changes * first downscaler then inherited annotations * add unit test for inherited annotations * add pvc to test + minor changes * missing comma * fix nil map assignment * set annotations in the same order it is done in other places * replace acidClientSet with acid getters in K8s client * more fixes on clientSet vs getters * minor changes * remove endpoints from annotation test * refine unit test - but deployment and sts are still empty * fix checkinng sts and deployment * make annotations setter one liners * no need for len check anymore Co-authored-by: Rafia Sabih <rafia.sabih@zalando.de>
This commit is contained in:
co-authored by
Rafia Sabih
parent
549f71bb49
commit
6a97316a69
@@ -117,7 +117,7 @@ class K8s:
|
||||
for svc in svcs:
|
||||
for key, value in annotations.items():
|
||||
if not svc.metadata.annotations or key not in svc.metadata.annotations or svc.metadata.annotations[key] != value:
|
||||
print("Expected key {} not found in annotations {}".format(key, svc.metadata.annotations))
|
||||
print("Expected key {} not found in service annotations {}".format(key, svc.metadata.annotations))
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -126,7 +126,7 @@ class K8s:
|
||||
for sset in ssets:
|
||||
for key, value in annotations.items():
|
||||
if key not in sset.metadata.annotations or sset.metadata.annotations[key] != value:
|
||||
print("Expected key {} not found in annotations {}".format(key, sset.metadata.annotations))
|
||||
print("Expected key {} not found in statefulset annotations {}".format(key, sset.metadata.annotations))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -852,6 +852,7 @@ class EndToEndTestCase(unittest.TestCase):
|
||||
patch_sset_propagate_annotations = {
|
||||
"data": {
|
||||
"downscaler_annotations": "deployment-time,downscaler/*",
|
||||
"inherited_annotations": "owned-by",
|
||||
}
|
||||
}
|
||||
k8s.update_config(patch_sset_propagate_annotations)
|
||||
@@ -861,6 +862,7 @@ class EndToEndTestCase(unittest.TestCase):
|
||||
"annotations": {
|
||||
"deployment-time": "2020-04-30 12:00:00",
|
||||
"downscaler/downtime_replicas": "0",
|
||||
"owned-by": "acid",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -870,10 +872,9 @@ class EndToEndTestCase(unittest.TestCase):
|
||||
annotations = {
|
||||
"deployment-time": "2020-04-30 12:00:00",
|
||||
"downscaler/downtime_replicas": "0",
|
||||
"owned-by": "acid",
|
||||
}
|
||||
|
||||
self.eventuallyTrue(lambda: k8s.check_statefulset_annotations(cluster_label, annotations), "Annotations missing")
|
||||
|
||||
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
|
||||
self.eventuallyTrue(lambda: k8s.check_statefulset_annotations(cluster_label, annotations), "Annotations missing")
|
||||
|
||||
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
|
||||
|
||||
Reference in New Issue
Block a user