Skip to content

✨ [WIP] Add support for kubectl printer columns #1019

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1alpha1/clusterextension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ type ClusterExtensionStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Installed Version",type=string,JSONPath=`.status.installedBundle.version`
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to float up any of the conditions or errors? As a user it would be good to understand: where the CR is in its progression, version state (as above), and some kind of sense of where it stopped (and possibly why?)

Copy link
Member

Choose a reason for hiding this comment

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

I think it is possible to write JSON path to do something like "find condition with type "Installed" and tell me it's reason", but that might not be all that helpful because:

  1. Showing details of every condition type would get pretty verbose
  2. Only showing details of some condition types could be misleading.

I wonder if, after @bentito's work to wrangle condition updates to reflect reality better, we could do something where right before we send out the status update we pass the conditions into a function that returns $something that somewhat summarizes the state of the conditions. For example:

  • Installed=False, Progressing=False => "Failed"
  • Installed=False, Progressing=True => "Installing"
  • Installed=True, Progressing=False, Healthy=False => "Unhealthy"
  • Installed=True, Progressing=False, Healthy=True => "Ready"
  • Installed=True, Progressing=True => "Upgrading"
  • etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

That could be cool. It would just be nice to get some signal without having to inspect the whole status.

Copy link
Contributor

@tmshort tmshort Sep 13, 2024

Choose a reason for hiding this comment

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

I've been looking into this, and it appears the JSON is limited to being very simple, and you really can't do something that complicated without another field having that value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Error I got when I tried to be a bit more "advanced":

The CustomResourceDefinition "clusterextensions.olm.operatorframework.io" is invalid: spec.additionalPrinterColumns[4].JSONPath: Invalid value: "{range .status.conditions[?(@.type=='Installed' && @.status=='False')]}{range .status.conditions[?(@.type=='Progressing' && @.status=='True')]}{'Installed'}{end}{end}": must be a simple json path starting with .

//+kubebuilder:printcolumn:name="Resolved Version",type=string,JSONPath=`.status.resolvedBundle.version`
//+kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`

// ClusterExtension is the Schema for the clusterextensions API
type ClusterExtension struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ spec:
singular: clusterextension
scope: Cluster
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .status.installedBundle.version
name: Installed Version
type: string
- jsonPath: .status.resolvedBundle.version
name: Resolved Version
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ClusterExtension is the Schema for the clusterextensions API
Expand Down
Loading