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

dns: fix headless service handling #1056

Merged
merged 2 commits into from
May 15, 2024

Conversation

howardjohn
Copy link
Member

@howardjohn howardjohn commented May 15, 2024

Before, we treated any service without a VIP as headless. This is not
correct. Consider

apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: external
  hosts:
  - httpbin.org
  location: MESH_EXTERNAL
  ports:
  - number: 80
    name: http
  resolution: DNS

We should NOT treat this as headless.

The implementation is a total hack, but a better fix requires WDS
changes so for now a short approach is best

Fixes #909
Fixes #554

Before, we treated any service without a VIP as headless. This is not
correct. Consider

```yaml
apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: external
  hosts:
  - httpbin.org
  location: MESH_EXTERNAL
  ports:
  - number: 80
    name: http
  resolution: DNS
```

We should NOT treat this as headless.

The implementation is a total hack, but a better fix requires WDS
changes so for now a short approach is best
@howardjohn howardjohn requested a review from a team as a code owner May 15, 2024 17:59
@howardjohn howardjohn added release-notes-none Indicates a PR that does not require release notes. cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch labels May 15, 2024
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 15, 2024
Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

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

This mostly seems ok... not sure about blind trimming 1 character though

// Domain will be like `.svc.cluster.local.` (trailing .), so ignore the last character.
let domain = self.svc_domain.to_utf8();
!service.vips.is_empty()
|| service.hostname.ends_with(&domain[..domain.len() - 1])
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use strip_suffix(...).expect("the svc domain must have a trailing '.'") which is a firmer assertion of the form of the svc_domain since malformed will cause a panic but won't quietly behave badly if our assumptions were false.

Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

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

lgtm

@istio-testing istio-testing merged commit 7937d6d into istio:master May 15, 2024
3 checks passed
@istio-testing
Copy link
Contributor

In response to a cherrypick label: new pull request created: #1058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick/release-1.22 Set this label on a PR to auto-merge it to the release-1.22 branch release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DNS incorrect treats all services without VIP as headless Add headless service support
3 participants