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 additionalPrinterColumns WORKLOAD-KIND for Work CRD #2066

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

lonelyCZ
Copy link
Member

@lonelyCZ lonelyCZ commented Jun 27, 2022

Signed-off-by: lonelyCZ 531187475@qq.com

What type of PR is this?
/kind feature

What this PR does / why we need it:
When we debug, kubectl get work -A is only shown the NAME, not KIND, which will take more time to check the kind of manifests of work.

So directly show the kind by additionalPrinterColumns.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

The best is to show all kind of manifests, because it possibly contains multi manifests in one work. But I don't find an easy way to implement it. Now, it only show the first manifests kind.

[root@master67 ~]# kapi get work -A
NAMESPACE            NAME                              KIND                 APPLIED   AGE
karmada-es-member1   cert-manager-674b866f4c           Namespace            True      8d
karmada-es-member1   karmada-impersonator-7cbb6bd5c9   ClusterRole          True      8d
karmada-es-member1   karmada-impersonator-84f8c8f8c6   ClusterRoleBinding   True      8d
karmada-es-member1   nginx-7f8d449df9                  Workload             False     8d
karmada-es-member2   cert-manager-674b866f4c           Namespace            True      46d
karmada-es-member2   karmada-impersonator-7cbb6bd5c9   ClusterRole          True      53d
karmada-es-member2   karmada-impersonator-84f8c8f8c6   ClusterRoleBinding   True      53d
karmada-es-member2   nginx-7f8d449df9                  Workload             False     8d

/cc @RainbowMango

Does this PR introduce a user-facing change?:

Added additional printer columns `KIND` for `Work` CRD.

@karmada-bot karmada-bot requested a review from RainbowMango June 27, 2022 13:31
@karmada-bot karmada-bot added kind/feature Categorizes issue or PR as related to a new feature. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 27, 2022
@prodanlabs
Copy link
Member

cool, i like this.

Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -16,6 +16,9 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.workload.manifests[*].kind
Copy link
Member

Choose a reason for hiding this comment

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

kind can be directly parsed from runtime.RawExtension, it looks amazing! 👍

@@ -16,6 +16,9 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.workload.manifests[*].kind
name: Kind
Copy link
Member

Choose a reason for hiding this comment

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

The work Kind can be a bit confusing, IMOP, WorkloadKind feel a little better.

Copy link
Member Author

Choose a reason for hiding this comment

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

How is WORKLOAD-KIND? like CLUSTER-IP with splited by -.

NAMESPACE            NAME                              WORKLOAD-KIND        APPLIED   AGE
karmada-es-member1   cert-manager-674b866f4c           Namespace            True      9d
karmada-es-member1   karmada-impersonator-7cbb6bd5c9   ClusterRole          True      9d
NAMESPACE        NAME                           TYPE           CLUSTER-IP   EXTERNAL-IP                                                     PORT(S)   AGE
default          kubernetes                     ClusterIP      10.96.0.1    <none>                                                          443/TCP   88d
karmada-system   karmada-aggregated-apiserver   ExternalName   <none>       karmada-aggregated-apiserver.karmada-system.svc.cluster.local   <none>    88d

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@RainbowMango
Copy link
Member

I totally agree with the idea that showing more info out.

The best is to show all kind of manifests, because it possibly contains multi manifests in one work. But I don't find an easy way to implement it. Now, it only show the first manifests kind.

In my opinion, it's still possible to put more than one manifests into a single Work. My concern is it might become technical debt.

So, let's hold for a while, and see if we can solve it.

@lonelyCZ
Copy link
Member Author

I just researched it, the crd only support simple JsonPath. If we need to customize it, we could put it in aggregated-apiserver, but for now, this seems unnecessary and too complicated.

The CustomResourceDefinition "works.work.karmada.io" is invalid: spec.additionalPrinterColumns[0].JSONPath: Invalid value: "{.spec.workload.manifests[*]}{.kind}{'\t'}{end}": must be a simple json path starting with .

@RainbowMango
Copy link
Member

Thanks for your time. Yes, aggregated-apiserver is way too complicated for this.
I'll look at it.

@jwcesign
Copy link
Member

jwcesign commented Dec 7, 2023

/cc @RainbowMango

I think we can push this forward

@RainbowMango
Copy link
Member

Yeah, I agree, we have to do this now. I'll get back to it later.

@RainbowMango RainbowMango added this to the v1.9 milestone Dec 7, 2023
@XiShanYongYe-Chang
Copy link
Member

Hi @lonelyCZ, can you help rebase the master branch and push it again?

Signed-off-by: lonelyCZ <chengzhe@zju.edu.cn>
@@ -20,6 +20,9 @@ spec:
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.workload.manifests[*].kind
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between manifests[*] and manifests[0]?

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 looks the same, that only print the fisrt one.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (58b1790) 51.87% compared to head (fd7139d) 51.87%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2066   +/-   ##
=======================================
  Coverage   51.87%   51.87%           
=======================================
  Files         243      243           
  Lines       24114    24114           
=======================================
  Hits        12509    12509           
+ Misses      10923    10922    -1     
- Partials      682      683    +1     
Flag Coverage Δ
unittests 51.87% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Just echo the test report here:

-bash-5.0# kubectl get works.work.karmada.io -n karmada-es-member1 
NAME                              WORKLOAD-KIND        APPLIED   AGE
karmada-impersonator-7cbb6bd5c9   ClusterRole          True      2m55s
karmada-impersonator-84f8c8f8c6   ClusterRoleBinding   True      2m55s
nginx-687f7fb96f                  Deployment           True      13s

It looks good, and I think we still have the chance to update without breaking compatibility.

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 8, 2023
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 8, 2023
@karmada-bot karmada-bot merged commit b168d9c into karmada-io:master Dec 8, 2023
13 checks passed
@RainbowMango RainbowMango changed the title Add additionalPrinterColumns KIND for Work CRD Add additionalPrinterColumns WORKLOAD-KIND for Work CRD Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants