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

temporal-cli: Fix Darwin builds with sandbox enabled #242721

Merged
merged 2 commits into from
Jul 23, 2023

Conversation

amarshall
Copy link
Member

@amarshall amarshall commented Jul 10, 2023

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jul 10, 2023
@SuperSandro2000
Copy link
Member

What is the actual error that is printed in the logs?

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jul 10, 2023
@tjni
Copy link
Contributor

tjni commented Jul 11, 2023

The tctl derivation seems to only need:

__darwinAllowLocalNetworking = true;

but the tctl-next derivation fails because a test tries to access /etc/protocols:

running tests
ok      github.com/temporalio/tctl/cli  0.657s
ok      github.com/temporalio/tctl/cli/headers  0.012s
ok      github.com/temporalio/tctl/cli/stringify        0.016s
ok      github.com/temporalio/tctl/cli/trace    0.012s
panic: open /etc/protocols: operation not permitted

goroutine 1 [running]:
modernc.org/libc/honnef.co/go/netdb.init.0()
        /private/tmp/nix-build-tctl-next-0.9.0.drv-1/source/vendor/modernc.org/libc/honnef.co/go/netdb/netdb.go:700 +0x784
FAIL    github.com/temporalio/cli/app   0.043s
FAIL

@amarshall
Copy link
Member Author

@tjni TIL about __darwinAllowLocalNetworking, thanks! Are there any downsides to that i.e. why is it not enabled by default?

Indeed, the /etc/protocols (and then hiding behind that will also be /etc/services) is occurring within a dependency; it’s possible to patch it but it’s quite cumbersome with the way the monolithic buildGoModule works.

@amarshall
Copy link
Member Author

@tjni I cannot reproduce either succeeding with only __darwinAllowLocalNetworking = true, they both have the same dep that causes the /etc/protocols access failure.

@tjni
Copy link
Contributor

tjni commented Jul 11, 2023

TIL about __darwinAllowLocalNetworking, thanks! Are there any downsides to that i.e. why is it not enabled by default?

We can see from the code that it also enables access to some other things as well, but I don't know why it isn't enabled by default :)

Indeed, the /etc/protocols (and then hiding behind that will also be /etc/services) is occurring within a dependency; it’s possible to patch it but it’s quite cumbersome with the way the monolithic buildGoModule works.

Yes, I don't know how to move past this yet aside from disabling the test (and I don't even know how to do that properly in buildGoModule).

@tjni
Copy link
Contributor

tjni commented Jul 11, 2023

I cannot reproduce either succeeding with only __darwinAllowLocalNetworking = true, they both have the same dep that causes the /etc/protocols access failure.

You're right, I just checked again. Adding __darwinAllowLocalNetworking does remove this log message:

Upserted cluster localhost:7233
current-env: tctl-test-env
--- FAIL: Test_fetchCACertFromUrl (0.00s)
panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: bind: operation not permitted [recovered]
        panic: httptest: failed to listen on a port: listen tcp6 [::1]:0: bind: operation not permitted

but still runs into the same error. I jumped the gun there, sorry for the noise!

@amarshall
Copy link
Member Author

@tjni Go tests may be skipped with e.g. checkFlags = [ "-skip=TestFoo" ];


So I felt more ambitious today, have pushed a version that does not disable tests and instead patches the dependency in the go-modules drv (along with opening a PR upstream) and applied the local net exception. The builds are now succeeding.

@amarshall amarshall force-pushed the temporal-cli-darwin-sandbox branch from a0e7816 to bb66cd8 Compare July 11, 2023 21:45
Unfortunately one of the issues is within a dependency, so have to do
some awkward patching of the go-modules. This patch is pending merge to
the upstream dep and will hopefully eventually trickle down. We do *not*
optionally apply the patch for Darwin only because then we would have a
different hash per system, which seems even more awkward.
@amarshall amarshall force-pushed the temporal-cli-darwin-sandbox branch from bb66cd8 to 77f010e Compare July 11, 2023 21:47
@tjni
Copy link
Contributor

tjni commented Jul 11, 2023

Result of nixpkgs-review pr 242721 run on aarch64-darwin 1

1 package built:
  • temporal-cli

Built with sandbox enabled.

Copy link
Contributor

@tjni tjni left a comment

Choose a reason for hiding this comment

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

LGTM!

@ofborg ofborg bot added 10.rebuild-linux: 1-10 10.rebuild-linux: 1 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jul 11, 2023
@amarshall amarshall changed the title temporal-cli: Disable tests on darwin to fix sandbox builds temporal-cli: Fix Darwin builds with sandbox enabled Jul 12, 2023
@SuperSandro2000 SuperSandro2000 merged commit d3ec974 into NixOS:master Jul 23, 2023
@amarshall amarshall deleted the temporal-cli-darwin-sandbox branch July 23, 2023 22:49
@github-actions
Copy link
Contributor

Successfully created backport PR for release-23.05:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants