Repository navigation
Conversation
be2c002 to
7e9061a
Compare
martinmo
left a comment
There was a problem hiding this comment.
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.
| openstacksdk | ||
| requests | ||
| tomli | ||
|
|
| 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.
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.
yes you're right. ithought i already changed that
mbuechse
left a comment
There was a problem hiding this comment.
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.
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
| 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.
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.
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.
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.
looks like a mistake, this file does not belong to this PR
There was a problem hiding this comment.
this file seems to have been added in error as well
There was a problem hiding this comment.
strange.. at checkout they should be reseted
There was a problem hiding this comment.
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: Matthias Büchse <[email protected]>
Signed-off-by: Matthias Büchse <[email protected]>
mbuechse
left a comment
There was a problem hiding this comment.
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).
| pvc_name, namespace | ||
| ) | ||
|
|
||
| def check_csi_provider(k8s_core_api, allowed_csi_prov=ALLOWED_CSI_PROV): |
There was a problem hiding this comment.
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.
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.
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.
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.
its not an error, in case a kind cluster is used (where no csi privider is used)
There was a problem hiding this comment.
it should simply filter out "wrong" csi providers
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
it's not an error, if e.g. a kind cluster is used.. we only test the csi-providers in use (these should sadisfy the standard), if no csi-providers are involved than this should not be an issue, this test should just filter out csi-providers in use, that are not sadisfing the standard
| logger.error(f"Error preparing Environment: {e}") | ||
| return False | ||
|
|
||
| def clean(self): |
There was a problem hiding this comment.
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.
this is a good idea
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
i have done so now.. this leads to another problem: when the 404 is triggered, it doesn' t distinguish between the resources that are not found, so if e.g. the pvc is already built and only the pod is not found it will not delete the pvc.. so i will need to establish a flag or catch the ApiException on another level
| env.return_code = 1 | ||
| logger.debug("check_default_storageclass() failed") | ||
| return env.return_code |
There was a problem hiding this comment.
| env.return_code = 1 | |
| logger.debug("check_default_storageclass() failed") | |
| return env.return_code | |
| logger.debug("check_default_storageclass() failed") | |
| return 1 |
There was a problem hiding this comment.
unfortunately env.return_code has to be set otherwise it's not detected as an error in the exit part.. remember: i need the env.return_code variable everywhere in the context to print it in the report afterwards
| env.return_code = 3 | ||
| env.return_message = "(409) conflicting resources" | ||
| return |
There was a problem hiding this comment.
I think the return is in error here.
There was a problem hiding this comment.
no it needs the return to get to the exit where the error is handled and printed out (however, this whole exception might be unnedeeded as the conflicted resources is already dealed with in the prepare part )
|
|
||
| def __exit__(self, exc_type, exc_value, traceback): | ||
| if self.cleanup: | ||
| self.clean() |
There was a problem hiding this comment.
(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.
This file seems to be here in error.
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]>
|
closing in favor of #930 |
fixed two bugs: