Skip to content

Commit

Permalink
fixed key error in getting default storage class
Browse files Browse the repository at this point in the history
Signed-off-by: Katharina Trentau <[email protected]>
  • Loading branch information
fraugabel committed Nov 11, 2024
1 parent f9436e5 commit 78872c5
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def check_default_storageclass(k8s_client_storage):
for item in storageclasses_dict["items"]:
storage_class_name = item["metadata"]["name"]
annotations = item["metadata"]["annotations"]

if annotations["storageclass.kubernetes.io/is-default-class"] == "true":
if annotations.get("storageclass.kubernetes.io/is-default-class") == "true":
ndefault_class += 1
default_storage_class = storage_class_name
provisioner = item["provisioner"]
Expand Down Expand Up @@ -225,6 +224,7 @@ def __init__(self, kubeconfig):
self.return_code = 0
self.return_message = "return_message: FAILED"
self.kubeconfig = kubeconfig
self.cleanup = False

def prepare(self):
"""
Expand Down Expand Up @@ -297,7 +297,9 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_value, traceback):
self.clean()
logger.debug("exiting")
if self.cleanup:
self.clean()
if self.return_code == 0:
self.return_message = "all tests passed"
if isinstance(exc_value, SCSTestException):
Expand Down Expand Up @@ -356,7 +358,7 @@ def main(argv):
env.return_code = 1
logger.debug("check_default_storageclass() failed")
return env.return_code

env.cleanup = True
try:
env.return_code = create_pvc_pod(k8s_core_api, default_class_name)
except ApiException as api_exception:
Expand Down

0 comments on commit 78872c5

Please sign in to comment.