-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Sort containers in index order #2878
base: master
Are you sure you want to change the base?
Conversation
Add a new index column for containers, which is the index in either the InitContainer or Containers.
- render.ContainerRes: too many instance variables - dao.makeContainerRes: Too many function arguments By changing Container and Status fields into methods that read from Pod
Just pushed up 2af813b and 0e70b11 to resolve the Codebeat issues where |
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.
@ryanbrainard Thank you for this PR Ryan!
I think that are a few issues here.
In summary, I think the actual update is simple if we determine at the call site what kind of container we are dealing with. Altering the model lead you to much more pain than necessary and resorting to lazy eval could account for additional perf implications.
@derailed Thanks for the review. I can switch this over to being precomputed. I had something more like that originally and caused Codebeat issues, but I can fully precompute it by removing the isInit arg and likely keep within Codebeat's rules. |
@derailed I just pushed up the requested changes. Looks like this now: A few things to call out:
|
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.
@ryanbrainard Thank you for the updates Ryan.
for _, co := range po.Spec.InitContainers { | ||
res = append(res, makeContainerRes(co, po, cmx[co.Name], true)) | ||
|
||
type containerGroup struct { |
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 don't think we need to introduce these groups. If we modified makeContainerRes signature to take in a kind (I,M,E) and an index should be sufficient. Then getContainerStatus can just look up statuses based on kind and index.
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.
@derailed It might be useful to add sidecar containers (S) to the type list. This would help solve this issue #2912
This is an implementation of the idea I submitted in #2843. While my follow up questions were not answered yet, I took a stab at this with my own preferences how it should work. I'm happy to adjust as needed.
IDX
as column header to save horizontal space.ⓘ
and then the index number. I did it this way to keep the visuals simple in the regular case, but mark index when it's in theInitContainers
array. This also preserves the actual index in the pod spec. Another benefit of using the Unicode characters as prefixes here is that theⓘ
sorts first so it visually represents the run order of the init containers that run first.INIT
column because it is now redundant with theⓘ
marker. This further saves horizontal space.IDX
the default sort order for containers. This ensures that the containers are listed in the order defined and run (in the case of init containers), which will improve the default UX.Demo
Pod Spec
Given a pod with these init containers and containers:
k9s Containers View
Here is how it is represented in k9s in the same order it is defined. Note the
IDX
column on the left with the init container withⓘ
and their index and regular containers with just their index.