Skip to content

fix: transfer resolveGranularity to ApisixUpstream to fix errors #18

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

Merged
merged 13 commits into from
Jun 4, 2024

Conversation

Revolyssup
Copy link
Contributor

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches
  • Documentation
  • Refactor
  • Chore
  • CI/CD or Tests

What this PR does / why we need it:

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 561 files.

Valid Invalid Ignored Fixed
400 2 159 0
Click to see the invalid file list
  • samples/deploy/crd/v1/ApisixRoute.yaml
  • samples/deploy/crd/v1/ApisixUpstream.yaml

@Revolyssup Revolyssup marked this pull request as draft May 30, 2024 11:34
@Revolyssup Revolyssup marked this pull request as ready for review May 30, 2024 21:06
"fmt"
"net/http"
"time"
// var _ = ginkgo.Describe("suite-chore: ApisixRoute resolvegranularity Testing", func() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

just delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Collaborator

@nic-6443 nic-6443 left a comment

Choose a reason for hiding this comment

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

we can delete CodeQL action too.

@nic-6443 nic-6443 requested a review from AlinsRan June 3, 2024 01:54
goto updateStatus
}
err = c.updateUpstream(ctx, apisixv1.ComposeUpstreamName(namespace, name, subset.Name, port.Port, types.ResolveGranularity.Service), &cfg, ev.Type.IsSyncEvent())
err := c.updateUpstream(ctx, apisixv1.ComposeUpstreamName(namespace, name, subset.Name, port.Port), &cfg, ev.Type.IsSyncEvent(), svc.Spec.ClusterIP)
Copy link
Contributor

@AlinsRan AlinsRan Jun 3, 2024

Choose a reason for hiding this comment

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

pls ref: https://kubernetes.io/docs/concepts/services-networking/service/#externalname.

This type of service is only for DNS mapping. Are you sure you can use clusterip.

For accessing external services, the lack of SNI prevents TLS handshake.

Copy link
Contributor Author

@Revolyssup Revolyssup Jun 3, 2024

Choose a reason for hiding this comment

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

But the upstream controller is triggered and uses the service even if the service type is not external name. Am I missing something? @AlinsRan

Copy link
Contributor

@AlinsRan AlinsRan Jun 3, 2024

Choose a reason for hiding this comment

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

I mean that services of externalName type are not compatible here.

Because ExternalName services do not have endpoints, the main purpose of resolveGranularity is to enable gateways to access external services.

Similarly, it does not have clusterIP.

For external services, simply use the domain name.

Copy link
Contributor Author

@Revolyssup Revolyssup Jun 3, 2024

Choose a reason for hiding this comment

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

Okay so the logic should be that when service is of type external name then even if granularity was passed in the ApisixUpstream, it should be ignored. Because if granularity is not passed then by default, ApisixUpstream doesn't change the value of nodes that was created in upstream when ApisixRoute was created. So no change required on ApisixUpstream sync.

And currently the TranslateService which creates upstream for k8s service doesn't take into account. So this issue already exists,right? I just need to add logic in translate service that when service type is ExternalName, just use externalName as node value instead of getting endpoints.
@AlinsRan Right?

Copy link
Contributor Author

@Revolyssup Revolyssup Jun 3, 2024

Choose a reason for hiding this comment

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

@AlinsRan Since thats an existing issue and not something introduced by this PR. Should I create another PR for it. Because even in current scenario before my change this problem exists.

Copy link
Contributor

@AlinsRan AlinsRan Jun 3, 2024

Choose a reason for hiding this comment

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

I just need to add logic in translate service that when service type is ExternalName, just use externalName as node value instead of getting endpoints.

Yes.

The current PR does not need to solve this problem, I just mentioned the possible issues that this feature may encounter.

@@ -317,9 +297,6 @@ spec:
- type: integer
- type: string
x-kubernetes-int-or-string: true
resolveGranularity:
Copy link
Contributor

Choose a reason for hiding this comment

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

The management method of the K8S API does not allow this. pls refs: https://kubernetes.io/docs/concepts/overview/kubernetes-api/#api-changes

I reserve my opinion on the enterprise version, but the open source version cannot do so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes the open source version cant do so but as discussed with @nic-6443 , compatibility is not an issue here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, we confirmed with our enterprise user, It's ok to introduce break changes in the CRD

@Revolyssup Revolyssup merged commit 45538f0 into release/1.8.2 Jun 4, 2024
74 checks passed
@starsz starsz deleted the revolyssup/fixupstreamerror branch June 7, 2024 07:58
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.

3 participants