Skip to content
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

Simplify Condition Checking in toolkit #68

Open
learnitall opened this issue Oct 17, 2022 · 0 comments
Open

Simplify Condition Checking in toolkit #68

learnitall opened this issue Oct 17, 2022 · 0 comments

Comments

@learnitall
Copy link
Collaborator

Background

In toolkit/k8s/verify.go, there's a function named CheckUnstructuredForReadyState, which takes in an unstructured kubernetes resources and checks if it is in a good state or not. It does this by checking if the resource's phase and conditions, (and container statuses if applicable), are all in a 'good' state. This gets a bit tricky, as each resource can have a different set of applicable phases and conditions. Additionally for conditions, it's not as simple as checking if they are all 'true' as some conditions are only considered 'good' if they are in a false state. For instance, Ready needs to be true, but DiskPressure needs to be false.

Problem

There are two main helper functions invoked by CheckUnstructuredForReadyState to check phases and conditions:

They both use a switch statement to check for known-goods and known-bads, then return an error if something unknown is given. This means that if we want to cover every resource available to kubernetes, we have to 'encode' all the relevant phase and condition info into these functions. This becomes an explosion problem over time as more environments and resources are to be supported. Recently, support for GKE-specific NodeConditions was brought up: #60

How can these functions be simplified to avoid having to update them over time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant