Skip to content

Commit 963f2d1

Browse files
authored
Remove hard coded name (#103)
1 parent 658585c commit 963f2d1

File tree

3 files changed

+35
-8
lines changed

3 files changed

+35
-8
lines changed

.evergreen.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ functions:
5050
local_files_include_filter:
5151
- e2e/*.txt
5252
- e2e/*.log
53+
- e2e/*.json
5354
region: us-east-1
5455
remote_file: logs/${task_id}/${execution}/
5556
bucket: community-operator-e2e-logs
@@ -132,7 +133,7 @@ functions:
132133

133134
task_groups:
134135
- name: e2e_test_group
135-
max_hosts: 3
136+
max_hosts: 4
136137
setup_group:
137138
- func: clone
138139
- func: setup_virtualenv

scripts/dev/dump_diagnostic.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ def dump_configmap_keys_namespaced(
8383
)
8484

8585

86+
def dump_automation_configs(namespace: str) -> None:
87+
mongodb_resources = k8s_request_data.get_all_mongodb_namespaced(namespace)
88+
if mongodb_resources is None:
89+
print("No MongoDB resources found, not dumping any automation configs")
90+
return
91+
for mdb in mongodb_resources:
92+
name = mdb["metadata"]["name"]
93+
dump_configmap_keys_namespaced(
94+
namespace, ["automation-config"], f"{name}-config"
95+
)
96+
97+
8698
def dump_all(namespace: str) -> None:
8799

88100
if os.path.exists("logs"):
@@ -103,4 +115,4 @@ def dump_all(namespace: str) -> None:
103115
with open("logs/e2e/crd.log", mode="w", encoding="utf-8") as crd_log:
104116
dump_crd(crd_log)
105117

106-
dump_configmap_keys_namespaced(namespace, ["automation-config"], "mdb0-config")
118+
dump_automation_configs(namespace)

scripts/dev/k8s_request_data.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from kubernetes.client.rest import ApiException
22
from kubernetes import client
33

4-
from typing import Optional
4+
from typing import Optional, List, Dict
55

66

7-
def get_crds() -> Optional[dict]:
7+
def get_crds() -> Optional[Dict]:
88
crdv1 = client.ApiextensionsV1beta1Api()
99
try:
1010
crd = crdv1.list_custom_resource_definition(pretty="true")
@@ -14,7 +14,20 @@ def get_crds() -> Optional[dict]:
1414
return crd.to_dict()
1515

1616

17-
def get_persistent_volumes() -> Optional[dict]:
17+
def get_all_mongodb_namespaced(namespace: str) -> Optional[List]:
18+
customv1 = client.CustomObjectsApi()
19+
try:
20+
return list(
21+
customv1.list_namespaced_custom_object(
22+
"mongodb.com", "v1", namespace, "mongodb", pretty=True
23+
)["items"]
24+
)
25+
except ApiException as e:
26+
print("Exception when calling get_namespaced_custom_object %s\n" % e)
27+
return None
28+
29+
30+
def get_persistent_volumes() -> Optional[Dict]:
1831
corev1 = client.CoreV1Api()
1932
try:
2033
pv = corev1.list_persistent_volume(pretty="true")
@@ -24,7 +37,7 @@ def get_persistent_volumes() -> Optional[dict]:
2437
return pv.to_dict()
2538

2639

27-
def get_stateful_sets_namespaced(namespace: str) -> Optional[dict]:
40+
def get_stateful_sets_namespaced(namespace: str) -> Optional[Dict]:
2841
av1beta1 = client.AppsV1Api()
2942
try:
3043
sst = av1beta1.list_namespaced_stateful_set(namespace, pretty="true")
@@ -34,7 +47,7 @@ def get_stateful_sets_namespaced(namespace: str) -> Optional[dict]:
3447
return sst.to_dict()
3548

3649

37-
def get_configmap_namespaced(namespace: str, name: str) -> Optional[dict]:
50+
def get_configmap_namespaced(namespace: str, name: str) -> Optional[Dict]:
3851
corev1 = client.CoreV1Api()
3952
try:
4053
config_map = corev1.read_namespaced_config_map(name, namespace, pretty="true")
@@ -44,7 +57,7 @@ def get_configmap_namespaced(namespace: str, name: str) -> Optional[dict]:
4457
return config_map.to_dict()
4558

4659

47-
def get_pods_namespaced(namespace: str) -> Optional[list]:
60+
def get_pods_namespaced(namespace: str) -> Optional[List]:
4861
corev1 = client.CoreV1Api()
4962
try:
5063
pods = corev1.list_namespaced_pod(namespace)
@@ -60,6 +73,7 @@ def get_pod_namespaced(namespace: str, pod_name: str) -> Optional[client.V1Pod]:
6073
pod = corev1.read_namespaced_pod(name=pod_name, namespace=namespace)
6174
except ApiException as e:
6275
print("Exception when calling read_namespaced_pod: %s\n" % e)
76+
return None
6377
return pod
6478

6579

0 commit comments

Comments
 (0)