Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Implement BackendNotFound reason for backendRef that does not exist #291

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

nathancoleman
Copy link
Member

@nathancoleman nathancoleman commented Jul 15, 2022

Will want to review + merge #290 first which this PR is based on

Changes proposed in this PR:

The contract for HTTPBackendRef has changed to include a new reason, BackendNotFound, for the ResolvedRefs condition when a known backendRef kind is used but the backend does not exist (docs). This change set implements that reason.

How I've tested this PR:

Created HTTPRoute w/ non-existent Service for backendRef, verifying that the new BackendNotFound reason is assigned to the status.

Example

By making a small change to the backendRef on this HTTPRoute from the Learn guide:

apiVersion: gateway.networking.k8s.io/v1alpha2
kind: HTTPRoute
metadata:
  name: example-route-2
  namespace: consul
spec:
  parentRefs:
  - name: api-gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /
    backendRefs:
    - kind: Service
      name: nginx-not-here
      namespace: consul
      port: 80
### How I expect reviewers to test this PR:

Checklist:

  • Tests added
  • CHANGELOG entry added

    Run make changelog-entry for guidance in authoring a changelog entry, and
    commit the resulting file, which should have a name matching your PR number.
    Entries should use imperative present tense (e.g. Add support for...)

@nathancoleman nathancoleman changed the title Implement BackendNotFound reason for ResolvedRefs condition on xRoute Implement BackendNotFound reason for backendRef that does not exist Jul 15, 2022
@nathancoleman nathancoleman force-pushed the route-backend-not-found branch from 4f339eb to fd79e76 Compare July 19, 2022 15:39
@nathancoleman nathancoleman marked this pull request as ready for review July 19, 2022 15:42
Copy link
Contributor

@mikemorris mikemorris left a comment

Choose a reason for hiding this comment

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

LGTM to merge before #290, as it's not impacted by the potential upstream logic conflict described in #290 (review)

I think the usage of NewConsulResolutionError at

return NewConsulResolutionError(fmt.Sprintf("consul service %s not found", namespacedName))
could be updated to instead return NewBackendNotFoundError too.

I was curious if there are any remaining valid uses of NewConsulResolutionError, or could if it be removed now, but I'm not sure if

NewConsulResolutionError(fmt.Sprintf(
"must have a single service map to a kubernetes service, found - (%q, %q) and (%q, %q)",
serviceNamespace, serviceName, service.Namespace, service.Service,
))
sufficiently maps to NewBackendNotFoundError to remove it entirely? Maybe?

Holding at least until #290 merges and this gets rebased for CI tests actually run.

Looks like there's a failing e2e test.

Base automatically changed from route-invalid-kind to main July 19, 2022 18:43
@mikemorris mikemorris force-pushed the route-backend-not-found branch from f19a977 to 18d5cc8 Compare July 19, 2022 18:57
@mikemorris
Copy link
Contributor

Force pushed because GitHub's auto-retarget didn't resolve the conflicts from squash-merging the prior base branch.

@andrewstucki
Copy link
Contributor

@mikemorris yeah, I think that the line you commented here:

I was curious if there are any remaining valid uses of NewConsulResolutionError, or could if it be removed now, but I'm not sure if ... sufficiently maps to NewBackendNotFoundError to remove it entirely? Maybe?

is different enough from not being able to find a backend -- i.e. it found one, but problematically it found more than one -- that it probably should be kept its own error type.

@nathancoleman nathancoleman force-pushed the route-backend-not-found branch from ed03aeb to 561fa47 Compare July 20, 2022 16:16
@nathancoleman nathancoleman requested a review from mikemorris July 20, 2022 16:30
@nathancoleman nathancoleman merged commit 7f22b09 into main Jul 20, 2022
@nathancoleman nathancoleman deleted the route-backend-not-found branch July 20, 2022 16:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants