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

frontend: Use net.JoinHostPort to support IPv6 addresses #10650

Merged
merged 3 commits into from
Dec 14, 2023

Conversation

matthewpi
Copy link
Contributor

@matthewpi matthewpi commented Sep 19, 2023

What this PR does / why we need it:

Fixes an issue when using IPv6 where IPv6 addresses are not properly joined with ports resulting in the ring attempting to incorrectly use ::1:7946 instead of the proper [::1]:7946 notation.

With this change it's fully possible to use Loki within an IPv6 only network.

This PR also changes a few other areas that incorrectly join ports. But the main area where people are likely to run into this issue is with the frontend and worker service, hence the title and changelog entry referring to those only.

Which issue(s) this PR fixes:
Fixes #10532 (issue was closed with a workaround that shouldn't be required)

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
    • If the change is worth mentioning in the release notes, add add-to-release-notes label
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR

For those interested in trying this out, here is a shortened snippet of the configuration changes I needed to make in order to get IPv6 working.

common:
  ring:
    instance_enable_ipv6: true
compactor:
  compactor_ring:
    instance_enable_ipv6: true
distributor:
  ring:
    instance_enable_ipv6: true
memberlist:
  bind_addr:
    - '::'
  bind_port: 7946
  cluster_label: loki
  randomize_node_name: false
ingester:
  lifecycler:
    enable_inet6: true
query_scheduler:
  scheduler_ring:
    instance_enable_ipv6: true
ruler:
  ring:
    instance_enable_ipv6: true
index_gateway:
  ring:
    instance_enable_ipv6: true

@matthewpi matthewpi requested a review from a team as a code owner September 19, 2023 20:54
@CLAassistant
Copy link

CLAassistant commented Sep 19, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

github-actions bot commented Nov 24, 2023

Trivy scan found the following vulnerabilities:

  • HIGH, Target: docker.io/grafana/loki:main-cd74ddf (alpine 3.18.4), Type: alpine openssl: Incorrect cipher key and IV length processing in libcrypto3 v3.1.3-r0. Fixed in v3.1.4-r0
  • HIGH, Target: docker.io/grafana/loki:main-cd74ddf (alpine 3.18.4), Type: alpine openssl: Incorrect cipher key and IV length processing in libssl3 v3.1.3-r0. Fixed in v3.1.4-r0
    \nTo see more details on these vulnerabilities, and how/where to fix them, please run docker build -t grafana/loki:main-cd74ddf -f cmd/loki/Dockerfile .
    trivy i grafana/loki:main-cd74ddf on your branch. If these were not introduced by your PR, please considering fixing them in via a subsequent PR. Thanks!

@periklis
Copy link
Collaborator

I thought I got everything the last time I fixed IPv6 support with #11121. Thanks a lot!

@matthewpi
Copy link
Contributor Author

I thought I got everything the last time I fixed IPv6 support with #11121. Thanks a lot!

I believe you did get all the one's for the rings, but this one is for the front-ends. I should probably update the title and description for this PR to more accurately match that.

Fixes an issue when using IPv6 where IPv6 addresses are not properly
joined with ports resulting in the ring attempting to incorrectly
use `::1:7946` instead of the proper `[::1]:7946` notation.

With this change it's fully possible to use Loki within an IPv6 only
network.

Signed-off-by: Matthew Penner <[email protected]>
@matthewpi matthewpi changed the title ring: Use net.JoinHostPort to support IPv6 addresses frontend: Use net.JoinHostPort to support IPv6 addresses Dec 4, 2023
@dbazhal
Copy link

dbazhal commented Dec 14, 2023

Hey guys!
Would be great to continue moving this. Can I help somehow? I could test it in my environment if that would help.

@periklis periklis merged commit a91f3f1 into grafana:main Dec 14, 2023
7 checks passed
@grafanabot
Copy link
Collaborator

Hello @periklis!
Backport pull requests need to be either:

  • Pull requests which address bugs,
  • Urgent fixes which need product approval, in order to get merged,
  • Docs changes.

Please, if the current pull request addresses a bug fix, label it with the type/bug label.
If it already has the product approval, please add the product-approved label. For docs changes, please add the type/docs label.
If the pull request modifies CI behaviour, please add the type/ci label.
If none of the above applies, please consider removing the backport label and target the next major/minor release.
Thanks!

@periklis periklis added the type/bug Somehing is not working as expected label Feb 5, 2024
@grafanabot
Copy link
Collaborator

The backport to release-2.9.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-10650-to-release-2.9.x origin/release-2.9.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x a91f3f11b3bf15d559b7b9206fc7c2791ca71fdc

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-10650-to-release-2.9.x
# Create the PR body template
PR_BODY=$(gh pr view 10650 --json body --template 'Backport a91f3f11b3bf15d559b7b9206fc7c2791ca71fdc from #10650{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title "[release-2.9.x] frontend: Use `net.JoinHostPort` to support IPv6 addresses" --body-file - --label "size/S" --label "type/bug" --label "backport" --base release-2.9.x --milestone release-2.9.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-10650-to-release-2.9.x

# Create a pull request where the `base` branch is `release-2.9.x` and the `compare`/`head` branch is `backport-10650-to-release-2.9.x`.

# Remove the local backport branch
git switch main
git branch -D backport-10650-to-release-2.9.x

periklis pushed a commit to periklis/loki that referenced this pull request Feb 5, 2024
…0650)

Signed-off-by: Matthew Penner <[email protected]>
Co-authored-by: Periklis Tsirakidis <[email protected]>
Co-authored-by: J Stickler <[email protected]>
(cherry picked from commit a91f3f1)
periklis pushed a commit to periklis/loki that referenced this pull request Feb 29, 2024
…0650)

Signed-off-by: Matthew Penner <[email protected]>
Co-authored-by: Periklis Tsirakidis <[email protected]>
Co-authored-by: J Stickler <[email protected]>
(cherry picked from commit a91f3f1)
periklis added a commit that referenced this pull request Mar 4, 2024
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
…0650)

Signed-off-by: Matthew Penner <[email protected]>
Co-authored-by: Periklis Tsirakidis <[email protected]>
Co-authored-by: J Stickler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scheduler IPv6 error: too many colons in address
6 participants