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

fix: execution fails when istio CRD is not installed in the cluster #144

Closed
wants to merge 1 commit into from

Conversation

YTGhost
Copy link
Contributor

@YTGhost YTGhost commented Mar 20, 2024

What type of PR is this?
/kind bug

What this PR does / why we need it:

  1. Enforce to specify --providers, and not default to all providers
  2. Fail soft with a warning if the provider specified is not the provider whose CRDs are not installed

Which issue(s) this PR fixes:

Fixes #138

Does this PR introduce a user-facing change?:


@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 20, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: YTGhost
Once this PR has been reviewed and has the lgtm label, please assign youngnick 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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 20, 2024
@k8s-ci-robot
Copy link
Contributor

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 /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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 20, 2024
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 20, 2024
@YTGhost
Copy link
Contributor Author

YTGhost commented Mar 20, 2024

@dpasiukevich @LiorLieberman PTAL

cmd/print.go Outdated Show resolved Hide resolved
Copy link
Member

@LiorLieberman LiorLieberman left a 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,
Copy link
Member

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)

Comment on lines +48 to +53
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
}

Copy link
Member

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

Copy link
Member

@mlavacca mlavacca left a 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 TCPIngresses 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.

Copy link
Member

@levikobi levikobi left a 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).

@LiorLieberman
Copy link
Member

@YTGhost This is a very important fix to add.
Do you still have the bandwidth to work on this?

@levikobi
Copy link
Member

This is a very important fix to add.

+1

@YTGhost
Copy link
Contributor Author

YTGhost commented Mar 27, 2024

@YTGhost This is a very important fix to add. Do you still have the bandwidth to work on this?

@LiorLieberman Sorry for the delay, I will fix it as soon as possible.

And let me confirm what we need to do now:

  • Not enforcing the specification of --providers
  • Implement a general helper that checks whether the list of CRDs passed to it are installed in the cluster. If not installed, it will return a typed error. For this typed error, we will use a soft fail logic to handle it at a higher level.
  • Introduce this helper to check each current provider.

@mlavacca
Copy link
Member

@YTGhost This is a very important fix to add. Do you still have the bandwidth to work on this?

@LiorLieberman Sorry for the delay, I will fix it as soon as possible.

And let me confirm what we need to do now:

  • Not enforcing the specification of --providers

👍

  • Implement a general helper that checks whether the list of CRDs passed to it are installed in the cluster. If not installed, it will return a typed error. For this typed error, we will use a soft fail logic to handle it at a higher level.

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:

  • The providers' readResourcesFromCluster functions returns a typed error when the CRD is not installed in the cluster (instead of a general error)
  • the caller of readResourcesFromCluster checks the error type. If it is related to missing CRDs, we add the provider to the list of the ones who did not provide translation, as @levikobi suggested.

@LiorLieberman
Copy link
Member

@YTGhost can we help to speed this up?
It is also ok if you have had limited bandwidth recently, just that this feature is really important so if you did, someone else would implement this.

@YTGhost
Copy link
Contributor Author

YTGhost commented Apr 10, 2024

@YTGhost can we help to speed this up? It is also ok if you have had limited bandwidth recently, just that this feature is really important so if you did, someone else would implement this.

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.

@mlavacca
Copy link
Member

closing as superseded by #153

@mlavacca mlavacca closed this Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it 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.

Execution fails when CRDs are not installed in the cluster
5 participants