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: handle wildcard hostnames when name resolution not available, fixes #4881 #6025

Merged
merged 6 commits into from Apr 1, 2024

Conversation

rfay
Copy link
Member

@rfay rfay commented Mar 27, 2024

The Issue

There are a few problems with creating hostnames in /etc/hosts when name lookup fails.

How This PR Solves The Issue

Tell when we can't do it and don't try doing it.

Manual Testing Instructions

ddev config --use-dns-when-possible=false
ddev config --additional-hostnames="*.junk"
ddev start

You should get a warning that *.junk.ddev.site can't be added to hosts file... because hosts file doesn't do wildcards.

Release/Deployment Notes

  • Followup: A ddev.com article explaining all of the issues with name resolution and wildcards.

pkg/ddevapp/hostname_mgt.go Outdated Show resolved Hide resolved
if err != nil {
return err
if strings.Contains(name, `*`) {
util.Warning("DDEV cannot add unresolvable wildcard hostnames like `%s` to your hosts file", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this also point to docs or mention that there are probably ways to resolve this? The message is completely true, but still makes me think I misconfigured the project rather than having a general networking issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added link to new doc.

@github-actions github-actions bot added the dependencies Pull requests that update a dependency file label Mar 28, 2024
rfay and others added 2 commits March 28, 2024 13:10
Co-authored-by: Stanislav Zhuk <stasadev@gmail.com>
@rfay rfay marked this pull request as ready for review March 31, 2024 15:06
@rfay rfay requested review from a team as code owners March 31, 2024 15:06
@rfay rfay requested a review from stasadev March 31, 2024 15:07
Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

Tested, works fine, no sudo for unresolvable hostnames.

A little confusion with:

ddev start
...
Successfully started d10 
Project can be reached at https://d10.ddev.site https://*.junk.ddev.site https://127.0.0.1:32774

https://*.junk.ddev.site is added to the list of hostnames anyway.

I thought about moving the warning to app.GetHostnames(), but that's probably not the best idea because it's used in so many places.

And hiding it in pkg/ddevapp/hostname_mgt.go doesn't hide it when running ddev describe or when checking the value of $DDEV_HOSTNAME.

Either way, I'm fine with this PR, the user is informed of the problem and has to solve it on their own.

@rfay rfay merged commit 2334386 into ddev:master Apr 1, 2024
27 checks passed
@rfay rfay deleted the 20240327_star_hostnames branch April 1, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants