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 ipv6 startup fail #81870 #87108

Merged
merged 8 commits into from May 6, 2024
Merged

Conversation

yincongcyincong
Copy link
Contributor

@yincongcyincong yincongcyincong commented Apr 30, 2024

Which issue(s) does this PR fix?:
When the ipv6 configuration is not enclosed in square brackets,apiserver printed a fatal log and exited.
https://github.com/kubernetes/apiserver/blob/master/pkg/server/config.go#L686
I solve the issue. When the ip is ipv6, it enclose in square brackets.

image

Fixes #81870 #81870

@yincongcyincong yincongcyincong requested a review from a team as a code owner April 30, 2024 07:55
@CLAassistant
Copy link

CLAassistant commented Apr 30, 2024

CLA assistant check
All committers have signed the CLA.

@RGBCube
Copy link

RGBCube commented Apr 30, 2024

Does it still work when you provide the IP in [] brackets? Wouldn't want to break peoples setups.

@yincongcyincong
Copy link
Contributor Author

yincongcyincong commented Apr 30, 2024

Does it still work when you provide the IP in [] brackets? Wouldn't want to break peoples setups.

the IP in [] brackets don't work, apiserver just get ":3000", don't have IP. but the grafana server can startup normally
image

@RGBCube
Copy link

RGBCube commented Apr 30, 2024

I think it should be backwards compatible as a few people might already specify ip addresses with brackets.

@DanCech
Copy link
Collaborator

DanCech commented Apr 30, 2024

There are a few different concerns here, firstly with the current code an ipv6 address wrapped in square brackets will fail because net.ParseIP will fail and return nil in that case, so we can at least exclude that possibility.

The first thing we should likely do is to correctly handle an error parsing the provided address, but to fix that we'll need to update the applyGrafanaConfig function so it can return an error. With that change, if net.ParseIP returns nil we can return an error.

Once we have a valid IP, we can use netip.AddrFromSlice to get a valid Addr from our IP (and handle any errors), then pass that to netip.AddrPortFrom (together with the port) and finally use MarshalText on the returned AddrPort to generate the host string with ipv6 addresses properly wrapped in square brackets (again checking that the returned string is not empty and returning an error).

@yincongcyincong
Copy link
Contributor Author

There are a few different concerns here, firstly with the current code an ipv6 address wrapped in square brackets will fail because net.ParseIP will fail and return nil in that case, so we can at least exclude that possibility.

The first thing we should likely do is to correctly handle an error parsing the provided address, but to fix that we'll need to update the applyGrafanaConfig function so it can return an error. With that change, if net.ParseIP returns nil we can return an error.

Once we have a valid IP, we can use netip.AddrFromSlice to get a valid Addr from our IP (and handle any errors), then pass that to netip.AddrPortFrom (together with the port) and finally use MarshalText on the returned AddrPort to generate the host string with ipv6 addresses properly wrapped in square brackets (again checking that the returned string is not empty and returning an error).

i think this suggestion is very helpeful, i will update my code.

@yincongcyincong
Copy link
Contributor Author

I think it should be backwards compatible as a few people might already specify ip addresses with brackets.

new pr is compatible

@toddtreece toddtreece added no-changelog Skip including change in changelog/release notes backport v11.0.x Mark PR for automatic backport to v11.0.x labels May 1, 2024
Copy link
Contributor

Hello @toddtreece!
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!

Copy link
Contributor

This PR must be merged before a backport PR will be created.

Copy link
Collaborator

@DanCech DanCech left a comment

Choose a reason for hiding this comment

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

LGTM

@DanCech DanCech added this to the 11.1.x milestone May 3, 2024
@DanCech
Copy link
Collaborator

DanCech commented May 3, 2024

@yincongcyincong it looks like your earlier commits have an email address that doesn't match your github account, which is causing the CLA bot to reject the PR. I think you can fix that by adding your baidu email address to your github profile here.

@yincongcyincong
Copy link
Contributor Author

@yincongcyincong it looks like your earlier commits have an email address that doesn't match your github account, which is causing the CLA bot to reject the PR. I think you can fix that by adding your baidu email address to your github profile here.

thanks, bro. i have added my baidu email.

@DanCech DanCech merged commit ba8b4bd into grafana:main May 6, 2024
10 checks passed
grafana-delivery-bot bot pushed a commit that referenced this pull request May 6, 2024
* fix ipv6 startup fail #81870

* ipv6 startup fail

* ipv6 startup fail

(cherry picked from commit ba8b4bd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend backport v11.0.x Mark PR for automatic backport to v11.0.x no-changelog Skip including change in changelog/release notes pr/external This PR is from external contributor type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot derive external address port without listening on a secure port.
5 participants