Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Test "kubectl logs" #9

Closed
wants to merge 3 commits into from
Closed

Test "kubectl logs" #9

wants to merge 3 commits into from

Conversation

siegfriedweber
Copy link
Member

@siegfriedweber siegfriedweber requested a review from a team April 22, 2021 13:28
@siegfriedweber siegfriedweber self-assigned this Apr 22, 2021
soenkeliebau
soenkeliebau previously approved these changes Apr 29, 2021
Copy link
Member

@soenkeliebau soenkeliebau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - left some questions, but I have no strong feelings over any of them and am happy for this to go in as is!

impl<'a, T: DeletableResource> Drop for TemporaryResource<'a, T> {
fn drop(&mut self) {
let resource = mem::take(&mut self.resource);
self.client.delete(resource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will panic if the resource was deleted before the struct goes out of scope.
Should we be more forgiving here, as I understand this to mostly be a helper struct that cleans up.
Any actual assertions about the objects existance or content should be part of the test cases, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be impossible to delete the resource elsewhere in the code. The resource could be deleted by the user with kubectl delete while the test is running but then a what-are-you-doing?-panic is okay.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about that, to me that is just plumbing. As long as the test case finished successfully, all relevant assertions should have been made and fulfilled in there. Why would we care if the resource is gone when we try to clean it up?
But as I said, happy for this to stay as it is as well. Time will tell if it ever even becomes relevant, then we can revisit this with more context if needed.

"#});
setup_repository(&client);

let pod = TemporaryResource::new(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed the check for an existing object - which I understand to be due to the new usage of TemporaryResource - but I'm fairly sure there are scenarios where cleanup might fail.
Would it perhaps make sense to add the check for and removal of old objects to TemporaryObject? Could be split up in new() and new_and_remove_if_exists() or something similar in case a test ever needs the distinction..

Copy link
Member Author

@siegfriedweber siegfriedweber Apr 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also my first thought. But if it is not possible to delete a resource for the first time why should it be possible to delete it the second (or third) time? Sure, time passes and the system could have changed to allow the deletion meanwhile, but when do you stop trying?

In the former code the resource was not deleted if the test case failed/panicked. So it was necessary to do the check. With the introduction of TemporaryResource I never encountered this problem anymore.

One remaining problem is that system signals like SIGINT are not handled. If the user presses Ctrl+C while the tests are running, chances are high that pods remain. As the pods often have unique names with UUIDs included, the former existence check would not help. It would be necessary to implement correct signal handling, e.g. with the ctrlc crate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main scenario that I considered was network trouble that makes Kubernetes briefly unavailable during the test which causes the test to fail without removing the resource.
Same as with the comment above though, happy to leave as is and see if it ever becomes an issue.


/// Newline character for LOG_OUTPUT
///
/// Source code: \\\\\\\\n
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for documenting this, I can only imagine the pain that went into these five lines!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the layers which eat backslashes are under our control. We could try to make them less voracious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not worth the effort unless it creates issues.

@siegfriedweber
Copy link
Member Author

Work is continued in branch test_logs_with_t2

@siegfriedweber siegfriedweber deleted the logs branch April 30, 2021 07:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functionality to tail logs via kubectl (or similar tools)
2 participants