-
Notifications
You must be signed in to change notification settings - Fork 23
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
Issue/662 default storage class #745
base: main
Are you sure you want to change the base?
Changes from 10 commits
6cb6530
16dcee6
e8ea514
22061f9
10bf140
f021a04
9cc32ce
9952be3
7e9061a
92093b0
91678b1
8901137
3afa301
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
**/__pycache__/ | ||
.venv/ | ||
.idea | ||
.sandbox | ||
.DS_Store | ||
node_modules | ||
Tests/kaas/results/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import sys | ||
import logging | ||
from kubernetes import client, config | ||
import os | ||
|
||
manual_result_file_template = { | ||
"name": None, | ||
|
@@ -38,7 +39,6 @@ def __init__(self, *args, return_code: int): | |
|
||
|
||
def setup_k8s_client(kubeconfigfile=None): | ||
|
||
if kubeconfigfile: | ||
logger.debug(f"using kubeconfig file '{kubeconfigfile}'") | ||
config.load_kube_config(kubeconfigfile) | ||
|
@@ -56,19 +56,17 @@ def setup_k8s_client(kubeconfigfile=None): | |
|
||
|
||
def gen_sonobuoy_result_file(error_n: int, error_msg: str, test_file_name: str): | ||
|
||
test_name = test_file_name.replace(".py", "") | ||
|
||
test_status = "passed" | ||
|
||
if error_n != 0: | ||
test_status = test_name + "_" + str(error_n) | ||
result_file = manual_result_file_template | ||
result_file["name"] = test_name | ||
result_file["status"] = test_status | ||
result_file["details"]["messages"] = error_msg | ||
|
||
result_file = manual_result_file_template | ||
|
||
result_file["name"] = test_name | ||
result_file["status"] = test_status | ||
result_file["details"]["messages"] = error_msg | ||
directory_path = os.path.dirname(f"./{test_name}.result.yaml") | ||
os.makedirs(directory_path, exist_ok=True) | ||
|
||
with open(f"./{test_name}.result.yaml", "w") as file: | ||
yaml.dump(result_file, file) | ||
with open(f"./{test_name}.result.yaml", "w") as file: | ||
yaml.dump(result_file, file) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still creates a file hierarchy replicating the absolute path to the script file, e.g. for me it creates:
The reason is that In There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes you're right. ithought i already changed that |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ | |
|
||
|
||
def check_default_storageclass(k8s_client_storage): | ||
|
||
api_response = k8s_client_storage.list_storage_class(_preload_content=False) | ||
storageclasses = api_response.read().decode("utf-8") | ||
storageclasses_dict = json.loads(storageclasses) | ||
|
@@ -81,6 +80,15 @@ def check_default_persistentvolumeclaim_readwriteonce(k8s_api_instance, storage_ | |
4. Delete resources used for testing | ||
""" | ||
|
||
# 0. Define CleanUp | ||
def cleanup(): | ||
logger.debug(f"delete pod:{pod_name}") | ||
api_response = k8s_api_instance.delete_namespaced_pod(pod_name, namespace) | ||
logger.debug(f"delete pvc:{pvc_name}") | ||
api_response = k8s_api_instance.delete_namespaced_persistent_volume_claim( | ||
pvc_name, namespace | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
namespace = "default" | ||
pvc_name = "test-pvc" | ||
pv_name = "test-pv" | ||
|
@@ -135,10 +143,9 @@ def check_default_persistentvolumeclaim_readwriteonce(k8s_api_instance, storage_ | |
pod_info = json.loads(api_response.read().decode("utf-8")) | ||
pod_status = pod_info["status"]["phase"] | ||
|
||
# Check if pod is up and running: | ||
# Check if pod is up and running: Default Retries 30 | ||
fraugabel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
retries = 0 | ||
while pod_status != "Running" and retries <= 30: | ||
|
||
api_response = k8s_api_instance.read_namespaced_pod( | ||
pod_name, namespace, _preload_content=False | ||
) | ||
|
@@ -152,6 +159,7 @@ def check_default_persistentvolumeclaim_readwriteonce(k8s_api_instance, storage_ | |
if pod_status != "Running": | ||
raise SCSTestException( | ||
"pod is not Running not able to setup test Enviornment", | ||
cleanup(), | ||
fraugabel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return_code=13, | ||
) | ||
|
||
|
@@ -172,28 +180,24 @@ def check_default_persistentvolumeclaim_readwriteonce(k8s_api_instance, storage_ | |
if pv["status"]["phase"] != "Bound": | ||
raise SCSTestException( | ||
"Not able to bind pv to pvc", | ||
cleanup(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
return_code=41, | ||
) | ||
|
||
if "ReadWriteOnce" not in pv["spec"]["accessModes"]: | ||
raise SCSTestException( | ||
"access mode 'ReadWriteOnce' is not supported", | ||
cleanup(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
return_code=42, | ||
) | ||
|
||
# 4. Delete resources used for testing | ||
logger.debug(f"delete pod:{pod_name}") | ||
api_response = k8s_api_instance.delete_namespaced_pod(pod_name, namespace) | ||
logger.debug(f"delete pvc:{pvc_name}") | ||
api_response = k8s_api_instance.delete_namespaced_persistent_volume_claim( | ||
pvc_name, namespace | ||
) | ||
cleanup() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are four places were a My suggestion would be to make use of the Or you could build a context manager that supports the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks, i'll checkout the context manager, that seems to be pretty neat. i also intend to make a precheck, whether the environment is cleaned up or whether, there are left overs |
||
|
||
return 0 | ||
|
||
|
||
def main(argv): | ||
|
||
initialize_logging() | ||
return_code = 0 | ||
return_message = "return_message: FAILED" | ||
|
@@ -226,7 +230,7 @@ def main(argv): | |
return_message = f"{exception_message}" | ||
return_code = 1 | ||
|
||
# Check if default storage class is defined (MENTETORY) | ||
# Check if default storage class is defined (MANDATORY) | ||
try: | ||
logger.info("check_default_storageclass()") | ||
default_class_name = check_default_storageclass(k8s_storage_api) | ||
|
@@ -239,7 +243,7 @@ def main(argv): | |
return_message = f"{exception_message}" | ||
return_code = 1 | ||
|
||
# Check if default_persistent volume has ReadWriteOnce defined (MENTETORY) | ||
# Check if default_persistent volume has ReadWriteOnce defined (MANDATORY) | ||
try: | ||
logger.info("check_default_persistentvolume_readwriteonce()") | ||
return_code = check_default_persistentvolumeclaim_readwriteonce( | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,8 +1,11 @@ | ||||
aiohttp | ||||
click | ||||
fabric | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This seems like a leftover from the rebase. The Please regenerate the |
||||
kubernetes | ||||
kubernetes_asyncio | ||||
python-dateutil | ||||
PyYAML | ||||
openstacksdk | ||||
requests | ||||
tomli | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.