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

Add additional printer columns for CRDs #2881

Conversation

zubron
Copy link
Contributor

@zubron zubron commented Aug 31, 2020

This change modifies the kubebuilder annotations for the Velero CRDs to
include additionalPrinterColumns so that more information is exposed
when using kubectl get.

For each of the CRDs, annotations have been added to make the output
for kubectl get match the output from the equivalent velero get
command as closely as possible. There are some cases where this output
could not be replicated, such as the EXPIRES column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no velero get equivalent, such as
PodVolumeBackup and PodVolumeRestore, a best effort has been made to
expose information that provides value.

Fixes #1780

Signed-off-by: Bridget McErlean [email protected]

@zubron zubron force-pushed the define-printer-columns-for-velero-crds-1780 branch from 473eec3 to a2028e9 Compare August 31, 2020 21:57
@nrb nrb added this to the v1.5.1 milestone Sep 1, 2020
@nrb
Copy link
Contributor

nrb commented Sep 1, 2020

@zubron Since we've locked the v1.5.0 list except for critical fixes, I'm going to mark this for v1.5.1 in the GitHub milestones.

Copy link
Member

@ashish-amarnath ashish-amarnath left a comment

Choose a reason for hiding this comment

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

@zubron I added a few minor comments. PTAL

// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="Backup status such as InProgress/Completed"
// +kubebuilder:printcolumn:name="Errors",type="integer",JSONPath=".status.errors",description="Count of all error messages that were generated during execution of this backup"
// +kubebuilder:printcolumn:name="Warnings",type="integer",JSONPath=".status.warnings",description="Count of all warning messages that were generated during execution of this backup"
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".status.startTimestamp",description="Time when this backup was started"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Start Time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted for the "Created" title to match the equivalent column from velero get backups. Same with "Age" to match the final column in standard kubectl get output (we already had that field/column for BSLs). Is consistency with those important?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for being consistent with the columns for backups and using Created .

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I would prefer consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would prefer to match the current velero get backups output, since that's established and updating it may break user scripts, so Created works for me.

That does, however, put us in an awkward spot since I think all other .status.startTimestamp fields should match, due to the existence of the creationTimestamp field. Ideally, we'd have clean mappings between the field name in the YAML and printer column, but I think due to historical reasons we're a little stuck.

So my vote is this mapping:

Print .status.startTimestamp under Created
Print .metadata.creationTimestamp under Age

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I'm not sure I understand what you mean by:

That does, however, put us in an awkward spot since I think all other .status.startTimestamp fields should match, due to the existence of the creationTimestamp field.

As for the mapping you'd prefer, that is what is in this file. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

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

The awkward spot I was referring to is that we have creationTimestamp that isn't mapped to the Created display name. It's probably not a big deal except for people looking at the code.

It looks like there's 2 instances where status.startTimestamp is mapped to Start Time, rather than Created:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. Thanks for the explanation!

I used Started as those column names which matches the output from velero get restores... another inconsistency :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha - yeah, that was our past mistake.

I think we could put that on the docket for v2.0 to update those velero commands so we don't break any scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created #2989 to address this.

pkg/apis/velero/v1/delete_backup_request.go Show resolved Hide resolved
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="DownloadRequest status such as New/Processed"
// +kubebuilder:printcolumn:name="Target Name",type="string",JSONPath=".spec.target.name",description="Name of the associated Kubernetes resource"
// +kubebuilder:printcolumn:name="Target Kind",type="string",JSONPath=".spec.target.kind",description="Type of file to download"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Created At

Copy link
Contributor

Choose a reason for hiding this comment

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

See above

@@ -100,6 +100,14 @@ type PodVolumeBackupStatus struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="Pod Volume Backup status such as New/InProgress"
// +kubebuilder:printcolumn:name="Created",type="date",JSONPath=".status.startTimestamp",description="Time when this backup was started"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Start Time

Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be helpful to know the reasoning for this request. Otherwise, Created is consistent with the column name for our other resources.

// +kubebuilder:printcolumn:name="Volume",type="string",JSONPath=".spec.volume",description="Name of the volume to be backed up"
// +kubebuilder:printcolumn:name="Restic Repo",type="string",JSONPath=".spec.repoIdentifier",description="Restic repository identifier for this backup"
// +kubebuilder:printcolumn:name="Storage Location",type="string",JSONPath=".spec.backupStorageLocation",description="Name of the Backup Storage Location where this backup should be stored"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Copy link
Member

Choose a reason for hiding this comment

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

Suggest: Created At

// +kubebuilder:printcolumn:name="Volume",type="string",JSONPath=".spec.volume",description="Name of volume to restore"
// +kubebuilder:printcolumn:name="Bytes Done",type="string",JSONPath=".status.progress.bytesDone",description="Number of bytes restored"
// +kubebuilder:printcolumn:name="Total Bytes",type="string",JSONPath=".status.progress.totalBytes",description="Total number of bytes to be restored"
// +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time when the restore operation was started"
Copy link
Member

Choose a reason for hiding this comment

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

nit: Start Time
for consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll note that this doesn't match what we've got specified in the backup.go file right now; I think whichever we choose, the column name should be consistent across object types.

// +kubebuilder:printcolumn:name="Total Bytes",type="string",JSONPath=".status.progress.totalBytes",description="Total number of bytes to be restored"
// +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time when the restore operation was started"
// +kubebuilder:printcolumn:name="Completed",type="date",JSONPath=".status.completionTimestamp",description="Time when the restore operation was completed"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Created At

@@ -251,6 +251,13 @@ type RestoreStatus struct {

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:name="Backup",type="string",JSONPath=".spec.backupName",description="Name of backup to restore from"
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="Restore status such as InProgress/Completed"
// +kubebuilder:printcolumn:name="Started",type="date",JSONPath=".status.startTimestamp",description="Time when the restore operation was started"
Copy link
Member

Choose a reason for hiding this comment

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

nit: Start Time
for consistency

// +kubebuilder:printcolumn:name="Completed",type="date",JSONPath=".status.completionTimestamp",description="Time when the restore operation was completed"
// +kubebuilder:printcolumn:name="Errors",type="integer",JSONPath=".status.errors",description="Count of all errors generated during the restore"
// +kubebuilder:printcolumn:name="Warnings",type="integer",JSONPath=".status.warnings",description="Count of all warnings generated during the restore"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Created At

@@ -20,6 +20,8 @@ import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:printcolumn:name="Provider",type="string",JSONPath=".spec.provider"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Copy link
Member

Choose a reason for hiding this comment

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

suggest: Created At

@carlisia
Copy link
Contributor

@zubron when you have a chance please resolve the conflicts, thanks.

This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
@zubron zubron force-pushed the define-printer-columns-for-velero-crds-1780 branch from a2028e9 to 97037ff Compare September 15, 2020 14:11
@carlisia carlisia modified the milestones: v1.5.1, v1.5.2 Sep 17, 2020
nrb
nrb previously requested changes Sep 17, 2020
Copy link
Contributor

@nrb nrb left a comment

Choose a reason for hiding this comment

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

I know we had a discussion about calculated fields in the community meeting, and we can't do them without extra code.

With that in mind, I think renaming the current Age fields would be desirable, because kubectl uses a calculated value as opposed to a bare timestamp for this when querying for built-in resources.

For example, here's what it looks like when querying for nodes:

% kubectl get nodes
NAME                 STATUS   ROLES    AGE   VERSION
kind-control-plane   Ready    master   19h   v1.17.0

In this case, the Age column is actually the difference between now and the creation timestamp. If we use the creationTimestamp directly, I worry about overloading the field's name with a different type of data.

@carlisia carlisia requested a review from nrb September 17, 2020 18:51
Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

👍

@nrb nrb dismissed their stale review September 18, 2020 18:31

My change request was based on inaccurate information.

@nrb
Copy link
Contributor

nrb commented Oct 13, 2020

I think I'm going to lean towards keeping the fields internally consistent, and letting this PR merge as is. We now have an action item to clean things up in v2.0, so I think that will work.

@nrb
Copy link
Contributor

nrb commented Oct 26, 2020

@ashish-amarnath Could you review the comments and update your review?

@ashish-amarnath ashish-amarnath merged commit 4178d9d into vmware-tanzu:main Oct 27, 2020
georgettica pushed a commit to georgettica/velero that referenced this pull request Dec 23, 2020
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
georgettica pushed a commit to georgettica/velero that referenced this pull request Jan 26, 2021
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
vadasambar pushed a commit to vadasambar/velero that referenced this pull request Feb 3, 2021
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
carlisia pushed a commit to carlisia/velero that referenced this pull request Mar 31, 2021
carlisia pushed a commit to carlisia/velero that referenced this pull request Mar 31, 2021
ashish-amarnath pushed a commit that referenced this pull request Mar 31, 2021
* Revert "Add additional printer columns for CRDs (#2881)"

This reverts commit 4178d9d.

Signed-off-by: Carlisia <[email protected]>

* Add generated files

Signed-off-by: Carlisia <[email protected]>
pradeep288 pushed a commit to pradeep288/velero that referenced this pull request May 4, 2021
* Revert "Add additional printer columns for CRDs (vmware-tanzu#2881)"

This reverts commit 4178d9d.

Signed-off-by: Carlisia <[email protected]>

* Add generated files

Signed-off-by: Carlisia <[email protected]>
Signed-off-by: Pradeep Jigalur <[email protected]>
dharmab pushed a commit to dharmab/velero that referenced this pull request May 25, 2021
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
dharmab pushed a commit to dharmab/velero that referenced this pull request May 25, 2021
* Revert "Add additional printer columns for CRDs (vmware-tanzu#2881)"

This reverts commit 4178d9d.

Signed-off-by: Carlisia <[email protected]>

* Add generated files

Signed-off-by: Carlisia <[email protected]>
ywk253100 pushed a commit to ywk253100/velero that referenced this pull request Jun 29, 2021
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
ywk253100 pushed a commit to ywk253100/velero that referenced this pull request Jun 29, 2021
* Revert "Add additional printer columns for CRDs (vmware-tanzu#2881)"

This reverts commit 4178d9d.

Signed-off-by: Carlisia <[email protected]>

* Add generated files

Signed-off-by: Carlisia <[email protected]>
gyaozhou pushed a commit to gyaozhou/velero-read that referenced this pull request May 14, 2022
This change modifies the kubebuilder annotations for the Velero CRDs to
include `additionalPrinterColumns` so that more information is exposed
when using `kubectl get`.

For each of the CRDs, annotations have been added to make the output
for `kubectl get` match the output from the equivalent `velero get`
command as closely as possible. There are some cases where this output
could not be replicated, such as the `EXPIRES` column for Backups, due
to the limitations of JSONPath expressions within the resulting CRD
defition. Some columns undergo processing and formatting before being
printed by the Velero CLI which cannot be replicated using JSONPath. In
these cases, these printer columns have been omitted.

For other CRDs where there is no `velero get` equivalent, such as
`PodVolumeBackup` and `PodVolumeRestore`, a best effort has been made to
expose information that provides value.

Signed-off-by: Bridget McErlean <[email protected]>
gyaozhou pushed a commit to gyaozhou/velero-read that referenced this pull request May 14, 2022
* Revert "Add additional printer columns for CRDs (vmware-tanzu#2881)"

This reverts commit 4178d9d.

Signed-off-by: Carlisia <[email protected]>

* Add generated files

Signed-off-by: Carlisia <[email protected]>
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

Successfully merging this pull request may close these issues.

Define printer columns for Velero CRDs for kubectl interoperability
4 participants