-
Notifications
You must be signed in to change notification settings - Fork 58
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
fix: execution fails when istio CRD is not installed in the cluster #144
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: YTGhost 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 |
Hi @YTGhost. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
c9b11fd
to
6210c15
Compare
Signed-off-by: Liang Deng <[email protected]>
6210c15
to
050dcb8
Compare
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.
Thanks, left some comments.
A general comment, you made two proposed solutions to the same problem. if we change the code to fail soft we might not need to enforce specifying providers.
@@ -245,7 +248,7 @@ func newPrintCommand() *cobra.Command { | |||
`If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even | |||
if specified with --namespace.`) | |||
|
|||
cmd.Flags().StringSliceVar(&pr.providers, "providers", i2gw.GetSupportedProviders(), | |||
cmd.Flags().StringSliceVar(&pr.providers, "providers", nil, |
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.
maybe an empty list instead of nil?
Ca you check if we get the desired functionality with this and marking the flag required (see my previous comment)
crd := &apiextensionsv1.CustomResourceDefinition{} | ||
if err := r.conf.Client.Get(ctx, types.NamespacedName{Name: CRDName}, crd); err != nil { | ||
log.Printf("CRD '%s' is not installed in the cluster, will not continue reading resources", CRDName) | ||
return res, nil | ||
} | ||
|
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.
Sorry this was not added to the previous review.
The intention was to change the call to read ANY CRD. In this case you only cover Istio Gateway but it is also relevant for VirtualServices and any other provider's CRD that will be added in the future.
So either you change istio calls to "fail soft" or you create a general helper that doing it
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 lean toward not requiring any provider when calling the CLI, instead, I propose the fail soft as @LiorLieberman proposed. I think the soft fail logic should be introduced one level abve. If a provider fails to read resources, we might want to just log the error and continue with other providers. We should implement this outside the istio provider as we might have the same issue with other Providers (Kong just implemented TCPIngress
es conversion, and I think we have the same issue there).
At the moment, logging messages is problematic because of #145, but that's a separate issue.
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.
+1 to what @mlavacca and @LiorLieberman said. I also would not want to see an enforcement of specifying the providers
flags, as this would be one more friction point that users have to figure out.
Alongside Kong, Apisix also faces this issue now. We need to solve this problem for all the providers (one level above, again, as @mlavacca said).
I think a reasonable solution is to have each provider check if his CRDs are installed; if they're not, return a typed error that specifies that. This error will result in a "fail soft" behavior one level above.
At the end of the run, we can specify which providers participated in the translation instead of describing which didn't. I think that's a better choice since a naive user who has some manifests but doesn't specify providers shouldn't receive multiple error messages about missing CRDs from different providers (which he might not even be familiar with).
@YTGhost This is a very important fix to add. |
+1 |
@LiorLieberman Sorry for the delay, I will fix it as soon as possible. And let me confirm what we need to do now:
|
👍
I don't think we need a helper to check the CRDs are installed in the cluster. This is the flow I have in mind:
|
@YTGhost can we help to speed this up? |
Yes, sorry, I've been busy with some school matters recently, and don't have enough bandwidth. It would be great if someone could help implement it. Apologies once again. |
closing as superseded by #153 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #138
Does this PR introduce a user-facing change?: