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

Distinguish missing Serving/Eventing API from unsupported version #1868

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xiangpingjiang
Copy link
Contributor

Description

Distinguish missing Serving/Eventing API from unsupported version

Changes

Reference

Fixes #1858

Release Note


@knative-prow
Copy link

knative-prow bot commented Sep 20, 2023

Hi @xiangpingjiang. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 20, 2023
@knative-prow
Copy link

knative-prow bot commented Sep 20, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: xiangpingjiang
Once this PR has been reviewed and has the lgtm label, please assign maximilien for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

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

@xiangpingjiang: 2 warnings.

In response to this:

Description

Distinguish missing Serving/Eventing API from unsupported version

Changes

Reference

Fixes #1858

Release Note


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

msg := fmt.Sprintf("no or newer Knative %s API found on the backend, please verify the installation or "+
"update the 'kn' client", firstCharToUpper(name))
return NewKNError(msg)
func NewInvalidCRD(apiGroup string, resourceName string) *KNError {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported function NewInvalidCRD should have comment or be unexported. More info.

"update the 'kn' client", resourceName)
return NewKNError(msg)

} else {
Copy link

Choose a reason for hiding this comment

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

Golint indent: if block ends with a return statement, so drop this else and outdent its block. More info.

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 20, 2023
@xiangpingjiang xiangpingjiang marked this pull request as draft September 20, 2023 16:47
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 20, 2023
@dsimansk
Copy link
Contributor

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 24, 2023
Signed-off-by: pingjiang <xiangpingjiang1998@gmail.com>
Signed-off-by: pingjiang <xiangpingjiang1998@gmail.com>
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Attention: Patch coverage is 44.00000% with 28 lines in your changes missing coverage. Please review.

Project coverage is 79.49%. Comparing base (f620968) to head (8bdc3fb).
Report is 72 commits behind head on main.

Files with missing lines Patch % Lines
pkg/errors/factory.go 15.15% 27 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1868      +/-   ##
==========================================
- Coverage   79.62%   79.49%   -0.14%     
==========================================
  Files         179      179              
  Lines       13927    13969      +42     
==========================================
+ Hits        11090    11104      +14     
- Misses       2070     2097      +27     
- Partials      767      768       +1     

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

@xiangpingjiang xiangpingjiang marked this pull request as ready for review September 25, 2023 13:04
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 25, 2023
@knative-prow knative-prow bot requested review from creydr and rhuss September 25, 2023 13:04
@xiangpingjiang
Copy link
Contributor Author

/retest

Comment on lines +68 to +75
if home := homedir.HomeDir(); home != "" {
kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
} else {
kubeconfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
}
flag.Parse()
// use the current context in kubeconfig
config, _ := clientcmd.BuildConfigFromFlags("", *kubeconfig)
Copy link
Contributor

@dsimansk dsimansk Sep 26, 2023

Choose a reason for hiding this comment

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

I'm not a huge fan of initializing new kube client instance in such a manner. We carry-over KnParams instance that holds all the clients commonly used, in addition it covers Kube's ClientConfig parsing, reflecting --kubeconfig and --context flags. I.e. you would need to cover more edge cases here.

I'd rather inject the KnParams into the new error functions and retrieve the needed clients from it.

Copy link
Contributor Author

@xiangpingjiang xiangpingjiang Sep 26, 2023

Choose a reason for hiding this comment

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

@dsimansk ,
I also want to reuse the KnParams, but I didn't find the right way. I will try to find how to inject the KnParams.

@@ -21,12 +21,23 @@ import (
"unicode/utf8"
)

func NewInvalidCRD(apiGroup string) *KNError {
func NewInvalidCRD(apiGroup string, canFindResource string) *KNError {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about creating a specific cause functions per message. E.g. NewInvalidCRDCauseUnknown, or define cause as a const string?

It might be easier to understand and consume whenever such new error is going to be added elsewhere etc.

Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 26, 2023
@xiangpingjiang
Copy link
Contributor Author

/remove-lifecycle stale

@knative-prow knative-prow bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 26, 2023
Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 26, 2024
@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 27, 2024
Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 25, 2024
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 5, 2024
@knative-prow-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Distinguish missing Serving/Eventing API from unsupported version
3 participants