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

kapacitor: fix build of embedded libflux dependency with current rust #270233

Merged
merged 2 commits into from
Nov 27, 2023

Conversation

mfrischknecht
Copy link
Contributor

The embedded libflux dependency of kapacitor fails to build with more current rust tooling due to an unneeded .clone() call that is promoted into an error message by a strict linting build config.

This introduces a patch that removes the offending method call. The issue is already resolved upstream, but even the current kapacitor version still depends on this specific version of libflux 1, and the respective git commit contains a lot of other (automated) changes 2, so cherry-picking the patch via a GitHub URL seems even more brittle.

Description of changes

Adds a patch that removes the offending .clone() call.

Failing hydra build: https://hydra.nixos.org/build/241395053#tabs-summary
Hydra log: https://hydra.nixos.org/build/241395053/nixlog/3

Relevant log excerpt:

error: call to `.clone()` on a reference in this situation does nothing
   --> flux-core/src/semantic/flatbuffers/types.rs:718:45
    |
718 |         let mut p = parser::Parser::new(expr.clone());
    |                                             ^^^^^^^^ help: remove this redundant call
    |
    = note: the type `str` does not implement `Clone`, so calling `clone` on `&str` copies the reference, which does not do anything and can be removed
note: the lint level is defined here
   --> flux-core/src/lib.rs:1:38
    |
1   | #![cfg_attr(feature = "strict", deny(warnings, missing_docs))]
    |                                      ^^^^^^^^
    = note: `#[deny(noop_method_call)]` implied by `#[deny(warnings)]`

error: could not compile `flux-core` (lib test) due to previous error

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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
  • [ x] Fits CONTRIBUTING.md.

The embedded `libflux` dependency of `kapacitor` fails to build with
more current rust tooling due to an unneeded `.clone()` call that
is promoted into an error message by a strict linting build config.

This introduces a patch that removes the offending method call.
The issue is already resolved upstream, but even the current `kapacitor`
version still depends on this specific version of `libflux` [1], and the
respective git commit contains a lot of other (automated) changes [2],
so cherry-picking the patch via a GitHub URL seems even more brittle.

[1]: https://github.com/influxdata/kapacitor/blob/v1.7.1/go.mod#L26
[2]: influxdata/flux@e7f7023#diff-96572e971d9e19b54290a434debbf7db054b21c9ce19035159542756ffb8ab87
@mfrischknecht
Copy link
Contributor Author

@offlinehacker @totoroot

I hope this is an adequate measure to get rid of the build error. If you know of a better fix (or way to include the patch), please let me know :)

@infinisil
Copy link
Member

infinisil commented Nov 26, 2023

This PR looks great, superb job with the explanatory comments! #ZurichZHF :)

I also tested it on Darwin, where it failed with

running tests
ok      github.com/influxdata/kapacitor 0.592s
ok      github.com/influxdata/kapacitor/alert   0.165s
ok      github.com/influxdata/kapacitor/auth    0.159s
--- FAIL: Test_ReportsErrors (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

goroutine 20 [running]:
testing.tRunner.func1.2({0x1015c42e0, 0x1400011e900})
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/testing/testing.go:1545 +0x1c8
testing.tRunner.func1()
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/testing/testing.go:1548 +0x360
panic({0x1015c42e0?, 0x1400011e900?})
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/runtime/panic.go:914 +0x218
net/http/httptest.newLocalListener()
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/net/http/httptest/server.go:71 +0xdc
net/http/httptest.NewUnstartedServer(...)
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/net/http/httptest/server.go:119
net/http/httptest.NewServer({0x1016a93a8?, 0x1016a45e8})
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/net/http/httptest/server.go:106 +0x2c
github.com/influxdata/kapacitor/client/v1_test.newClientWithConfig({0x1016a93a8?, 0x1016a45e8?}, {{0x0, 0x0}, 0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, ...})
        /private/tmp/nix-build-kapacitor-1.7.0.drv-0/source/client/v1/client_test.go:24 +0x4c
github.com/influxdata/kapacitor/client/v1_test.newClient(...)
        /private/tmp/nix-build-kapacitor-1.7.0.drv-0/source/client/v1/client_test.go:20
github.com/influxdata/kapacitor/client/v1_test.Test_ReportsErrors(0x14000103520)
        /private/tmp/nix-build-kapacitor-1.7.0.drv-0/source/client/v1/client_test.go:367 +0x2f8
testing.tRunner(0x14000103520, 0x1016a4258)
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/testing/testing.go:1595 +0xe8
created by testing.(*T).Run in goroutine 1
        /nix/store/02cpvad60np366kmsqc3gnixbsw9jvg1-go-1.21.4/share/go/src/testing/testing.go:1648 +0x33c
FAIL    github.com/influxdata/kapacitor/client/v1       0.250s
FAIL
error: build of '/nix/store/v4lghw163jqjhd2549xii7qykbxzzdhd-kapacitor-1.7.0.drv' on 'ssh://[email protected]' failed: builder for '/nix/store/v4lghw163jqjhd2549xii7qykbxzzdhd-kapacitor-1.7.0.drv' failed with exit code 1;

But I was able to fix it by adding a

__darwinAllowLocalNetworking = true;

There's other packages also doing the same to get around such test failures, see NixOS/nix#1646 for more info (Unfortunately it seems completely undocumented)

I hope you don't mind me pushing the commit here directly!

@infinisil
Copy link
Member

@ofborg build kapacitor

@ofborg ofborg bot requested review from offlinehacker and totoroot November 27, 2023 00:32
@infinisil infinisil merged commit 538faba into NixOS:master Nov 27, 2023
15 of 17 checks passed
@infinisil infinisil added 0.kind: ZHF Fixes Fixes during the Zero Hydra Failures (ZHF) campaign backport release-23.11 labels Nov 27, 2023
Copy link
Contributor

Git push to origin failed for release-23.11 with exitcode 1

Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants