baremetal-operator: pkg/hardwareutils module is not imported properly

When uplifting BMO apis modules in CAPM3, I am facing an issue where it tries to import BMO api but fails to read pkg/hardwareutils as follows:

go mod tidy
go: downloading github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0
github.com/metal3-io/cluster-api-provider-metal3 imports
        github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1 imports
        github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc: reading github.com/metal3-io/baremetal-operator/pkg/hardwareutils/pkg/hardwareutils/go.mod at revision pkg/hardwareutils/v0.0.0: unknown revision pkg/hardwareutils/v0.0.0

Looks like when fetching BMO apis from root go.mod of BMO, it tries to access github.com/metal3-io/baremetal-operator/pkg/hardwareutils and is not able to find it, because the path to the module is structured incorrectly for some reason, specifically see

reading github.com/metal3-io/baremetal-operator/pkg/hardwareutils/pkg/hardwareutils/go.mod at revision pkg/hardwareutils/v0.0.0

where pkg/hardwareutils is duplicated in the path.

Considering last uplift of BMO in CAPM3 went smooth and that was before https://github.com/metal3-io/baremetal-operator/commit/0197893937b01624850af453c56864622081dc82 landed where it reorganized the module a bit, it can be a culprit.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 33 (27 by maintainers)

Most upvoted comments

This can be closed as solved, after tagging submodules properly, we can import BMO from the CAPM3 without workarounds. Thanks everyone.

/close

@fmuyassarov is this above a reference to CAPM3 ?

yes, that’s the output of BMO uplift in CAPM3

@furkatgofurov7 I think we should not face that issue anymore if we try with v0.1.0

diff --git a/go.mod b/go.mod
index 595f1f9d..1fc6bc0f 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
        github.com/go-logr/logr v1.2.2
        github.com/golang/mock v1.6.0
        github.com/jinzhu/copier v0.3.2
-       github.com/metal3-io/baremetal-operator/apis v0.0.0-20220617103906-946dc6d709de
+       github.com/metal3-io/baremetal-operator/apis v0.1.0
        github.com/metal3-io/cluster-api-provider-metal3/api v0.0.0
        github.com/metal3-io/ip-address-manager/api v0.0.0-20220617070006-b1bd226927ae
        github.com/onsi/ginkgo v1.16.5
@@ -32,7 +32,7 @@ replace github.com/metal3-io/cluster-api-provider-metal3/api => ./api
 
 replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.1.5
 
-replace github.com/metal3-io/baremetal-operator/pkg/hardwareutils => github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0-20220209171559-d3bcdd79e511
+replace github.com/metal3-io/baremetal-operator/pkg/hardwareutils => github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.1.0
 
 replace github.com/docker/distribution => github.com/docker/distribution v2.8.1+incompatible
 
@@ -87,7 +87,7 @@ require (
        github.com/mailru/easyjson v0.7.6 // indirect
        github.com/mattn/go-isatty v0.0.14 // indirect
        github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
-       github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0 // indirect
+       github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.1.0 // indirect
        github.com/mitchellh/copystructure v1.2.0 // indirect
        github.com/mitchellh/mapstructure v1.4.2 // indirect
        github.com/mitchellh/reflectwalk v1.0.2 // indirect
diff --git a/go.sum b/go.sum
index 9811ba4f..c8ac6298 100644
--- a/go.sum
+++ b/go.sum
@@ -461,10 +461,10 @@ github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
-github.com/metal3-io/baremetal-operator/apis v0.0.0-20220617103906-946dc6d709de h1:b5bGtOSql1WoM21nPEWTeBK+JpN8trg2rlawj8zihRE=
-github.com/metal3-io/baremetal-operator/apis v0.0.0-20220617103906-946dc6d709de/go.mod h1:IFJXZUVXhVZC4prZ9PpemddmhnnNuKwYwnztyGNoSSk=
-github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0-20220209171559-d3bcdd79e511 h1:+DOZI8DuQEH1wtwsqIcdX/vcZhExpUY5xH/+nBqAwps=
-github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.0.0-20220209171559-d3bcdd79e511/go.mod h1:/PSTQInIZmfuOmAp/pSgZAs4txs6T49woC0MYIa4QzE=
+github.com/metal3-io/baremetal-operator/apis v0.1.0 h1:eFwByBRJSS8Tu9dR52dgxN5JPzOYKAIZwZpD28sfEzc=
+github.com/metal3-io/baremetal-operator/apis v0.1.0/go.mod h1:IFJXZUVXhVZC4prZ9PpemddmhnnNuKwYwnztyGNoSSk=
+github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.1.0 h1:JRVtsXWLYP5L+pZkokzAaLHK88Xe2nEFkvJQOc81B/g=
+github.com/metal3-io/baremetal-operator/pkg/hardwareutils v0.1.0/go.mod h1:/PSTQInIZmfuOmAp/pSgZAs4txs6T49woC0MYIa4QzE=
 github.com/metal3-io/ip-address-manager/api v0.0.0-20220617070006-b1bd226927ae h1:aSwVQLVhLm6gEA6p8dTJksHUZAV8pvF7j2vKr2VJYsU=
 github.com/metal3-io/ip-address-manager/api v0.0.0-20220617070006-b1bd226927ae/go.mod h1:IgZuGEbWca+Jh3QwdkhAM5ZEKuN+c55xOTwxwwaUSUM=
 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=


@furkatgofurov7 that is strange. I’ll investigate.

/assign

I’ve created a PR #1165 to update the submodules. If we could merge this and cut a release

Hi, Thanks for the PR. If we will be able to get 1165 merged by tomorrow, sure thing. I was planning to cut a new patch release tomorrow as I notified already the community over the slack recently (xref https://kubernetes.slack.com/archives/CHD49TLE7/p1662582014489209) due to other reasons as well.

@fmuyassarov I see you just cut a new release, would you please add tags for the api and hardwareutils submodules?

api/v0.1.0
pkg/hardwareutils/v0.1.0

I do not see anything wrong with using hash commit, it will work, lots of golang modules out in the wild do not set proper tags, it is life, this is not convenient, I agree, but work fine.

it doesn’t work that way.

Actually it does, you just need to set multiple tags on same commit, one for root go.mod, containing tagged release version and other tags must be prefixed with subfolder path of go.mod.

So I was referring that in this way project would want to set all tags for all go.mod files below the root and also for actual root and it should be same version.

Something like

  • v0.1.42
  • api/v0.1.42
  • pkg/hardwareutils/v.0.1.42

And it is obviously a job for CI automation, the only thing that needs to be decided here by human is actual base version.

So general (proper) solution would still be linked to https://github.com/metal3-io/baremetal-operator/issues/746

Sadly 2+ years have passed and still no decision on making tagged release was made.

Unfortunately, nowadays I’m working on different projects and most probably I’ll not be able to find time to fix that.

/unassign