-
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?
Conversation
be2c002
to
7e9061a
Compare
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.
First round of review done, see inline comments.
Some general observations:
If the connection to the cluster fails, the script tries to continue anyway with the all the steps, which it shouldn't do.
The script still doesn't check if a provisioner such as cinder-csi is used.
kubernetes_asyncio | ||
python-dateutil | ||
PyYAML | ||
openstacksdk | ||
requests | ||
tomli | ||
|
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.
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
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 comment
The 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:
/home/martinmorgenstern/workspace/scs/standards/Tests/home/martinmorgenstern/workspace/scs/standards/Tests/kaas/k8s-default-storage-class
The reason is that __file__
(which is the absolute path to the script) is used as the test_file_name
argument passed to gen_sonobuoy_result_file
and used without further processing.
In main()
, you should use os.path.basename(__file__)
to get only the script filename without the directories.
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.
yes you're right. ithought i already changed that
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.
I'm not sure I can follow, but it does seem to be work in progress anyway.
namespace = "default" | ||
pvc_name = "test-pvc" | ||
pv_name = "test-pv" | ||
pod_name = "test-pod" |
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.
please turn these into arguments with default values, i.e.,
namespace=NAMESPACE, pvc_name=PVC_NAME, ...
this makes the function more versatile, and we don't litter the code with these allcaps identifiers
Tests/kaas/k8s-default-storage-class/k8s-default-storage-class-check.py
Outdated
Show resolved
Hide resolved
if isinstance(exc_value, SCSTestException): | ||
self.return_message = exc_value.args[0] | ||
self.return_code = exc_value.return_code | ||
print(f"SCSTestException occurred with return_code: {self.return_code}") | ||
else: | ||
# No specific exception, handle normally | ||
print(f"Exiting the context with return_code: {self.return_code}") |
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.
This seems really convoluted. The exceptions are being caught in the main function anyway. And why should the test environment carry the burden of storing the return code? That violates the single-responsibility principle (aka separation of concerns).
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.
because in this case I assumed that these exceptions are only intercepted afterwards. i'll check this again.
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.
the return code is kept there to feed it into the sonobuoy result, which is created in the exit, to make sure it gets created, after any error whatsoever. This is actually the reason why i created this context management to avoid having the same exception (SCSTestException) raised in 5 different places.
@berendt Hi Christian, can you provide us with a k8s cluster for testing this? |
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.
looks like a mistake, this file does not belong to this PR
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.
true
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.
this file seems to have been added in error as well
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.
strange.. at checkout they should be reseted
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.
i'll fix this asap
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
…_readwriteonce() Signed-off-by: Katharina Trentau <[email protected]>
…_readwriteonce() Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
f3fcb43
to
f9436e5
Compare
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
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.
Overall this is going into the right direction. I'm afraid a few problems are still left to tackle. I also altered a few things myself (see the commits).
|
||
def check_csi_provider(k8s_core_api, allowed_csi_prov=ALLOWED_CSI_PROV): |
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.
What is this good for, and how was the list ALLOWED_CSI_PROV
determined? I can't see any mention of this in the standard nor the testing notes. A comment in the code is required, but also some explanation in the testing notes.
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.
it was a suggestion by @martinmo to provide a list of allowed csi-providers, that work accordingly to the standard
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.
Okay, but this doesn't address any of my points.
return_code=33, | ||
) | ||
if not csi_list: | ||
logger.info("CSI-Provider: No CSI Provider found.") |
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.
Why is this not an error? (I really don't know. Maybe a comment would help)
Also please note that the indentation is wrong here.
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.
its not an error, in case a kind cluster is used (where no csi privider is used)
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.
it should simply filter out "wrong" csi providers
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.
I'm not sure if Kind is supposed to pass the test. Why have a special case for Kind? But this whole thing should AT MOST produce a warning anyway for the standard makes not mention of it whatsoever.
logger.error(f"Error preparing Environment: {e}") | ||
return False | ||
|
||
def clean(self): |
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.
I think we can get rid of (big parts of) prepare
as well as the variable cleanup
by making this method ignore any error that says "resource not found". To me, this would be very much preferable. (It would in principle also reduce the risk of race conditions.)
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.
this is a good idea
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.
well, i can catch a "404 resource not found" now and then skip the clean() execution, but if only one of both (pvc,pod) is missing the other one does not get deleted. so i am thinking, that i should ratehr catch that in the clean() function itself. what do you think?
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.
My proposal was to call delete_namespace_pod
and delete_namespaced_persistent_volume_claim
unconditionally, and to swallow any exception that indicates that deletion was unsuccessful because the resource didn't exist in the first place.
env.return_code = 1 | ||
logger.debug("check_default_storageclass() failed") | ||
return env.return_code |
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.
env.return_code = 1 | |
logger.debug("check_default_storageclass() failed") | |
return env.return_code | |
logger.debug("check_default_storageclass() failed") | |
return 1 |
env.return_code = 3 | ||
env.return_message = "(409) conflicting resources" | ||
return |
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.
I think the return
is in error here.
|
||
def __exit__(self, exc_type, exc_value, traceback): | ||
if self.cleanup: | ||
self.clean() |
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.
(as reported by flake8: indention is wrong here as well)
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
Signed-off-by: Katharina Trentau <[email protected]>
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.
This file seems to be here in error.
fixed two bugs: