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: network-scoped alias is supported only for containers in user defined networks #2075

Merged
merged 2 commits into from
Nov 12, 2023

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Nov 2, 2023

This Windows only issue is caused by the missing !n.IsHost() in the n.IsUserDefined() function for windows. Act sends the network alias for the host network on windows, linux sees that and calls the same IsUserDefined (but uses the unix definition on the server side), which detects the host network as non user defined network.

On linux and macOS it is impossible to reproduce at the time of creating this change. I don't get why windows has it's own definition, but bad maintained.

The actual code uses IsUserDefined to detect if network aliases are supported, which didn't work on windows due to the mess in the docker client go library.

Thank you docker client.

go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_unix.go

// IsUserDefined indicates user-created network
func (n NetworkMode) IsUserDefined() bool {
	return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer()
}

go\pkg\mod\github.com\docker\docker@v24.0.7+incompatible\api\types\container\hostconfig_windows.go

// IsUserDefined indicates user-created network
func (n NetworkMode) IsUserDefined() bool {
	return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer()
}

Why did docker this?

Seems like we have to replace the convenience function with it's unix definition

Important bug fix, I don't have the power

network-scoped alias is supported only for containers in user defined networks
Copy link
Contributor

github-actions bot commented Nov 2, 2023

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 1 0 0.02s
✅ REPOSITORY gitleaks yes no 3.08s
✅ REPOSITORY git_diff yes no 0.22s
✅ REPOSITORY grype yes no 11.64s
✅ REPOSITORY secretlint yes no 1.89s
✅ REPOSITORY trivy-sbom yes no 0.86s
✅ REPOSITORY trufflehog yes no 22.77s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #2075 (a006b92) into master (4989f44) will increase coverage by 0.24%.
Report is 269 commits behind head on master.
The diff coverage is 59.88%.

@@            Coverage Diff             @@
##           master    #2075      +/-   ##
==========================================
+ Coverage   61.22%   61.46%   +0.24%     
==========================================
  Files          46       53       +7     
  Lines        7141     8780    +1639     
==========================================
+ Hits         4372     5397    +1025     
- Misses       2462     2955     +493     
- Partials      307      428     +121     
Files Coverage Δ
pkg/common/executor.go 51.69% <100.00%> (+1.69%) ⬆️
pkg/container/docker_cli.go 82.23% <ø> (ø)
pkg/container/docker_logger.go 52.08% <ø> (ø)
pkg/runner/step_action_local.go 93.54% <100.00%> (ø)
pkg/runner/step_action_remote.go 91.56% <100.00%> (+0.65%) ⬆️
pkg/runner/step_docker.go 93.18% <100.00%> (ø)
pkg/container/file_collector.go 37.30% <0.00%> (ø)
pkg/container/util.go 0.00% <0.00%> (ø)
pkg/container/docker_build.go 60.00% <80.00%> (+1.02%) ⬆️
...ontainer/linux_container_environment_extensions.go 23.07% <0.00%> (-1.25%) ⬇️
... and 31 more

... and 2 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@arashi-dev
Copy link

Thanks for your work. I really need it

@0x78f1935
Copy link

This would solve Error: failed to start container: Error response from daemon: network-scoped alias is supported only for containers in user defined networks, please approve! Thank you for your contribution!

@Ironeer
Copy link

Ironeer commented Nov 8, 2023

This would solve Error: failed to start container: Error response from daemon: network-scoped alias is supported only for containers in user defined networks, please approve! Thank you for your contribution!

I also ran into the issue that is fixed by this PR. Thank you for fixing it @ChristopherHX

Please review and approve! @ALL

Copy link

@tyeth tyeth left a comment

Choose a reason for hiding this comment

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

Thank you for this, I only wish my approval mattered ;)

@mergify mergify bot merged commit 74b0fe8 into master Nov 12, 2023
10 checks passed
@mergify mergify bot deleted the fix-network-scoped-alias-regression branch November 12, 2023 18:09
jmikedupont2 pushed a commit to meta-introspector/act that referenced this pull request Mar 10, 2024
network-scoped alias is supported only for containers in user defined networks

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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.

network-scoped alias is supported only for containers in user defined networks
6 participants