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

[BUG] magellan build fails in bmclib dependency #45

Closed
bcfriesen opened this issue Jul 19, 2024 · 17 comments · Fixed by #46
Closed

[BUG] magellan build fails in bmclib dependency #45

bcfriesen opened this issue Jul 19, 2024 · 17 comments · Fixed by #46
Labels
bug Something isn't working

Comments

@bcfriesen
Copy link

Greetings,

while trying to build magellan for the first time on an x86 VM, I find that the build fails here:

Executing target: build
goreleaser build --clean --single-target --snapshot
  • starting build...
  • loading config file                              file=.goreleaser.yaml
  • building only for linux/amd64                    reason=single target is enabled
  • loading environment variables
  • getting and validating git state
    • ignoring errors because this is a snapshot     error=couldn't get tag content body: fatal: Out of memory, malloc failed (tried to allocate 18446744073709551323 bytes)

    • building...                                    commit=none latest tag=v0.0.0
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
      • DEPRECATED: `archives.rlcp` will be the default soon, check https://goreleaser.com/deprecations#archivesrlcp for more info
  • running before hooks
    • running                                        hook=go mod download
    • took: 1s
  • snapshotting
    • building snapshot...                           version=0.0.1-next
  • checking distribution directory
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/magellan_linux_amd64_v1/magellan
    • took: 47s
  ⨯ build failed after 47s                   error=failed to build for linux_amd64_v1: exit status 1: warning: GOPATH set to GOROOT (/home/friesen/go) has no effect
# github.com/bmc-toolbox/bmclib/v2/internal/redfishwrapper
../../go/pkg/mod/github.com/bmc-toolbox/bmclib/[email protected]/internal/redfishwrapper/firmware.go:121:71: updateService.StartUpdateTarget undefined (type *redfish.UpdateService has no field or method StartUpdateTarget)

This uses commit 10eabf2 of megellan, Go version 1.22.5, and goreleaser version 1.18.2.

@bcfriesen bcfriesen added the bug Something isn't working label Jul 19, 2024
@davidallendj
Copy link
Collaborator

davidallendj commented Jul 19, 2024

Does building with go build work? Just want to make sure this is just related only to building with goreleaser.
cc @alexlovelltroy

@alexlovelltroy
Copy link
Member

Our latest release uses go 1.21 and goreleaser 2.1.0 through our github build automation. Have you tried that configuration?

Release: https://github.com/OpenCHAMI/magellan/releases/tag/v0.0.18
Workflow: https://github.com/OpenCHAMI/magellan/blob/main/.github/workflows/main.yml

@bcfriesen
Copy link
Author

Does building with go build work? Just want to make sure this is just related to building with goreleaser. cc @alexlovelltroy

Ah, yes I forgot to mention that the above snippet came from running make, which relies on goreleaser as you said.

Building with go build results in the same error:

go build
<...>
# github.com/bmc-toolbox/bmclib/v2/internal/redfishwrapper
../../go/pkg/mod/github.com/bmc-toolbox/bmclib/[email protected]/internal/redfishwrapper/firmware.go:121:71: updateService.StartUpdateTarget undefined (type *redfish.UpdateService has no field or method StartUpdateTarget)

@bcfriesen
Copy link
Author

Our latest release uses go 1.21 and goreleaser 2.1.0 through our github build automation. Have you tried that configuration?

Release: https://github.com/OpenCHAMI/magellan/releases/tag/v0.0.18 Workflow: https://github.com/OpenCHAMI/magellan/blob/main/.github/workflows/main.yml

Thanks - I will try that.

@davidallendj
Copy link
Collaborator

Does building with go build work? Just want to make sure this is just related to building with goreleaser. cc @alexlovelltroy

Ah, yes I forgot to mention that the above snippet came from running make, which relies on goreleaser as you said.

Building with go build results in the same error:

go build
<...>
# github.com/bmc-toolbox/bmclib/v2/internal/redfishwrapper
../../go/pkg/mod/github.com/bmc-toolbox/bmclib/[email protected]/internal/redfishwrapper/firmware.go:121:71: updateService.StartUpdateTarget undefined (type *redfish.UpdateService has no field or method StartUpdateTarget)

Strange. I'm not getting that on my working tree, but I did run into the issue when cloning the repo and trying to build with go build. Running go mod tidy didn't fix the issue either. The thing is, I was actually going to remove the bmclib stuff in the refactor that I'm working on so we don't run into issues like this.

@bcfriesen
Copy link
Author

I rebuilt with goreleaser 2.1.0 and that did not change the error (no surprise there). Rebuilding with Go 1.21.5 also failed at the same point. I did blow away everything in ~/go/pkg/mod which maybe forces a rebuild of all dependencies? (I have no idea if that is true, being new to Go.) But that didn't help.

@alexlovelltroy
Copy link
Member

I don't have a linux vm available to test with. Can you use the binary from the release in the meantime?

@bcfriesen
Copy link
Author

I don't have a linux vm available to test with. Can you use the binary from the release in the meantime?

Gah!

muller:ncn-m001:~/friesen # ./magellan 
./magellan: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by ./magellan)
./magellan: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./magellan)
./magellan: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./magellan)
muller:ncn-m001:~/friesen # zypper if glibc|grep Version
Version        : 2.31-150300.58.1

This is not a magellan problem, I'll try to find another environment with newer glibc.

@davidallendj
Copy link
Collaborator

Can we close this issue?

@bcfriesen
Copy link
Author

Can we close this issue?

Maybe you can tell me. make build does now work, which is great!:

Executing target: build
goreleaser build --clean --single-target --snapshot
  • starting build...
  • loading config file                              file=.goreleaser.yaml
  • building only for darwin/arm64                   reason=single target is enabled
  • loading environment variables
  • getting and validating git state
    • building...                                    commit=777aa3c11817cca8de9472df67060b8e66349101 latest tag=v0.0.19
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
      • DEPRECATED: `archives.rlcp` will be the default soon, check https://goreleaser.com/deprecations#archivesrlcp for more info
  • running before hooks
    • running                                        hook=go mod download
  • snapshotting
    • building snapshot...                           version=0.0.20-next
  • checking distribution directory
    • cleaning dist
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/magellan_darwin_arm64/magellan
    • took: 1s
  • storing release metadata
    • writing                                        file=dist/artifacts.json
    • writing                                        file=dist/metadata.json
  • you are using deprecated options, check the output above for details
  • build succeeded after 1s
  • thanks for using goreleaser!

However, make lint (which is implied by just make) fails:

Executing target: lint
golangci-lint run --fix
tests/api_test.go:1: : # github.com/OpenCHAMI/magellan/tests [github.com/OpenCHAMI/magellan/tests.test]
tests/api_test.go:22:3: l declared and not used
tests/api_test.go:36:22: not enough arguments in call to magellan.CollectAll
	have ([]magellan.ScannedResult)
	want (*[]magellan.ScannedResult, *"github.com/OpenCHAMI/magellan/internal/log".Logger, *magellan.QueryParams) (typecheck)
// This file contains generic tests used to confirm expected behaviors of the
internal/api/dora/dora.go:70:12: Error return value of `rows.Scan` is not checked (errcheck)
		rows.Scan(
		         ^
internal/collect.go:252:28: Error return value of `system.EthernetInterfaces` is not checked (errcheck)
		system.EthernetInterfaces()
		                         ^
cmd/collect.go:99:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.driver", collectCmd.Flags().Lookup("driver"))
	               ^
cmd/collect.go:100:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.host", collectCmd.Flags().Lookup("host"))
	               ^
cmd/collect.go:101:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.port", collectCmd.Flags().Lookup("port"))
	               ^
cmd/collect.go:108:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(collectCmd.Flags())
	                ^
cmd/root.go:55:12: Error return value of `cmd.Help` is not checked (errcheck)
			cmd.Help()
			        ^
cmd/root.go:113:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(rootCmd.Flags())
	                ^
cmd/root.go:122:22: Error return value of `magellan.LoadConfig` is not checked (errcheck)
		magellan.LoadConfig(configPath)
		                   ^
cmd/scan.go:103:28: Error return value of `sqlite.InsertProbeResults` is not checked (errcheck)
		sqlite.InsertProbeResults(cachePath, &probeStates)
		                         ^
internal/collect.go:621:6: func `makeJson` is unused (unused)
func makeJson(object any) ([]byte, error) {
     ^
cmd/scan.go:21:2: var `begin` is unused (unused)
	begin          uint8
	^
cmd/scan.go:22:2: var `end` is unused (unused)
	end            uint8
	^
internal/util/util.go:141:3: ineffectual assignment to i (ineffassign)
		i += 1
		^
internal/api/smd/smd.go:125:39: SA5011: possible nil pointer dereference (staticcheck)
	fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
	                                     ^
internal/api/smd/smd.go:126:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
	if res != nil {
	   ^
make: *** [lint] Error 1

@davidallendj
Copy link
Collaborator

Looks like the system.EthernetInterfaces() line should be down one line where the redfish.ListReferencedEthernetInterfaces() function is called. I'm about to push an update to fix that, and hopefully it fixes all the other stuff as well. The only one I'm seeing with make lint is the one related to the api_test.go after the fix, but I'm already working on those on another branch.

@davidallendj
Copy link
Collaborator

@bcfriesen Can you try building with the refactor branch and see what happens? I have a PR opened for this branch and will merge it soon after it's been tested by others.

@bcfriesen
Copy link
Author

@bcfriesen Can you try building with the refactor branch and see what happens? I have a PR opened for this branch and will merge it soon after it's been tested by others.

Thanks! make build works on that branch, but make lint fails with a different error than before:

Executing target: lint
golangci-lint run --fix
tests/api_test.go:1: : # github.com/OpenCHAMI/magellan/tests [github.com/OpenCHAMI/magellan/tests.test]
tests/api_test.go:22:43: too many arguments in call to magellan.ScanForAssets
	have ([]string, []int, number, number, bool, bool)
	want (*magellan.ScanParams)
tests/api_test.go:27:42: too many arguments in call to magellan.ScanForAssets
	have ([]string, []int, number, number, bool, bool)
	want (*magellan.ScanParams) (typecheck)
// This file contains generic tests used to confirm expected behaviors of the
cmd/collect.go:88:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.driver", collectCmd.Flags().Lookup("driver"))
	               ^
cmd/collect.go:89:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.host", collectCmd.Flags().Lookup("host"))
	               ^
cmd/collect.go:90:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.port", collectCmd.Flags().Lookup("port"))
	               ^
cmd/collect.go:97:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(collectCmd.Flags())
	                ^
cmd/root.go:56:12: Error return value of `cmd.Help` is not checked (errcheck)
			cmd.Help()
			        ^
cmd/root.go:86:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(rootCmd.Flags())
	                ^
cmd/update.go:15:2: var `port` is unused (unused)
	port             int
	^
internal/util/error.go:15:3: ineffectual assignment to i (ineffassign)
		i += 1
		^
pkg/client/smd.go:59:39: SA5011: possible nil pointer dereference (staticcheck)
	fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
	                                     ^
pkg/client/smd.go:60:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
	if res != nil {
	   ^
make: *** [lint] Error 1

@davidallendj
Copy link
Collaborator

Looks pretty straight-forward to fix. I guess I can't ignore checking those viper.BingPFlag errors anymore. 🤷

@davidallendj
Copy link
Collaborator

@bcfriesen Can you try building with the refactor branch and see what happens? I have a PR opened for this branch and will merge it soon after it's been tested by others.

Thanks! make build works on that branch, but make lint fails with a different error than before:

Executing target: lint
golangci-lint run --fix
tests/api_test.go:1: : # github.com/OpenCHAMI/magellan/tests [github.com/OpenCHAMI/magellan/tests.test]
tests/api_test.go:22:43: too many arguments in call to magellan.ScanForAssets
	have ([]string, []int, number, number, bool, bool)
	want (*magellan.ScanParams)
tests/api_test.go:27:42: too many arguments in call to magellan.ScanForAssets
	have ([]string, []int, number, number, bool, bool)
	want (*magellan.ScanParams) (typecheck)
// This file contains generic tests used to confirm expected behaviors of the
cmd/collect.go:88:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.driver", collectCmd.Flags().Lookup("driver"))
	               ^
cmd/collect.go:89:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.host", collectCmd.Flags().Lookup("host"))
	               ^
cmd/collect.go:90:17: Error return value of `viper.BindPFlag` is not checked (errcheck)
	viper.BindPFlag("collect.port", collectCmd.Flags().Lookup("port"))
	               ^
cmd/collect.go:97:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(collectCmd.Flags())
	                ^
cmd/root.go:56:12: Error return value of `cmd.Help` is not checked (errcheck)
			cmd.Help()
			        ^
cmd/root.go:86:18: Error return value of `viper.BindPFlags` is not checked (errcheck)
	viper.BindPFlags(rootCmd.Flags())
	                ^
cmd/update.go:15:2: var `port` is unused (unused)
	port             int
	^
internal/util/error.go:15:3: ineffectual assignment to i (ineffassign)
		i += 1
		^
pkg/client/smd.go:59:39: SA5011: possible nil pointer dereference (staticcheck)
	fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
	                                     ^
pkg/client/smd.go:60:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
	if res != nil {
	   ^
make: *** [lint] Error 1

FYI, this is fixed on the refactor branch, along with some other stuff. Should be able to build and run now, but the output isn't compatible with the current version of OpenCHAMI's smd. I'm working on that currently.

@bcfriesen
Copy link
Author

Yes! It works now. make test now fails with this:

--- FAIL: TestScanAndCollect (0.00s)
    api_test.go:38: expected to find at least one BMC node, but found none
--- FAIL: TestRedfishV1Availability (0.00s)
    compatibility_test.go:36: failed to make request to BMC: failed to make request: Get "localhost/redfish/v1": unsupported protocol scheme ""
{"level":"error","error":"failed to make request: Get \"localhost/redfish/v1\": unsupported protocol scheme \"\"","time":"2024-08-14T10:21:17-07:00","message":"failed to make request"}
{"level":"error","error":"endpoint must starts with http or https","time":"2024-08-14T10:21:17-07:00","message":"failed to connect to BMC"}
--- FAIL: TestExpectedProperties (0.00s)
    compatibility_test.go:91: failed to crawl BMC: endpoint must starts with http or https
FAIL
coverage: 12.1% of statements in ./...
FAIL	github.com/OpenCHAMI/magellan/tests	0.508s
FAIL
make: *** [test] Error 1

but those look like spurious(?) failures since I am doing this from a laptop with no access to a BMC.

Thanks very much for your help!

@davidallendj
Copy link
Collaborator

You're welcome! I guess I'll need to take that into account for the other PR I'm working on regarding the tests. They're not complete yet, so I'd pretty much expect them to fail under most circumstances.

@davidallendj davidallendj linked a pull request Aug 14, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants