Skip to content

Remove hard coded name #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ functions:
local_files_include_filter:
- e2e/*.txt
- e2e/*.log
- e2e/*.json
region: us-east-1
remote_file: logs/${task_id}/${execution}/
bucket: community-operator-e2e-logs
Expand Down Expand Up @@ -132,7 +133,7 @@ functions:

task_groups:
- name: e2e_test_group
max_hosts: 3
max_hosts: 4
setup_group:
- func: clone
- func: setup_virtualenv
Expand Down
14 changes: 13 additions & 1 deletion scripts/dev/dump_diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ def dump_configmap_keys_namespaced(
)


def dump_automation_configs(namespace: str) -> None:
mongodb_resources = k8s_request_data.get_all_mongodb_namespaced(namespace)
if mongodb_resources is None:
print("No MongoDB resources found, not dumping any automation configs")
return
for mdb in mongodb_resources:
name = mdb["metadata"]["name"]
dump_configmap_keys_namespaced(
namespace, ["automation-config"], f"{name}-config"
)


def dump_all(namespace: str) -> None:

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

dump_configmap_keys_namespaced(namespace, ["automation-config"], "mdb0-config")
dump_automation_configs(namespace)
26 changes: 20 additions & 6 deletions scripts/dev/k8s_request_data.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from kubernetes.client.rest import ApiException
from kubernetes import client

from typing import Optional
from typing import Optional, List, Dict


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


def get_persistent_volumes() -> Optional[dict]:
def get_all_mongodb_namespaced(namespace: str) -> Optional[List]:
customv1 = client.CustomObjectsApi()
try:
return list(
customv1.list_namespaced_custom_object(
"mongodb.com", "v1", namespace, "mongodb", pretty=True
)["items"]
)
except ApiException as e:
print("Exception when calling get_namespaced_custom_object %s\n" % e)
return None


def get_persistent_volumes() -> Optional[Dict]:
corev1 = client.CoreV1Api()
try:
pv = corev1.list_persistent_volume(pretty="true")
Expand All @@ -24,7 +37,7 @@ def get_persistent_volumes() -> Optional[dict]:
return pv.to_dict()


def get_stateful_sets_namespaced(namespace: str) -> Optional[dict]:
def get_stateful_sets_namespaced(namespace: str) -> Optional[Dict]:
av1beta1 = client.AppsV1Api()
try:
sst = av1beta1.list_namespaced_stateful_set(namespace, pretty="true")
Expand All @@ -34,7 +47,7 @@ def get_stateful_sets_namespaced(namespace: str) -> Optional[dict]:
return sst.to_dict()


def get_configmap_namespaced(namespace: str, name: str) -> Optional[dict]:
def get_configmap_namespaced(namespace: str, name: str) -> Optional[Dict]:
corev1 = client.CoreV1Api()
try:
config_map = corev1.read_namespaced_config_map(name, namespace, pretty="true")
Expand All @@ -44,7 +57,7 @@ def get_configmap_namespaced(namespace: str, name: str) -> Optional[dict]:
return config_map.to_dict()


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


Expand Down