Skip to content

migrate to kubebuilder 2.3.1#655

Merged
metal3-io-bot merged 18 commits intometal3-io:masterfrom
dhellmann:kubebuilder-rewrite2
Sep 30, 2020
Merged

migrate to kubebuilder 2.3.1#655
metal3-io-bot merged 18 commits intometal3-io:masterfrom
dhellmann:kubebuilder-rewrite2

Conversation

@dhellmann
Copy link
Copy Markdown
Member

@dhellmann dhellmann commented Sep 27, 2020

This implements the work described in
https://github.com/metal3-io/metal3-docs/blob/master/design/baremetal-operator/kubebuilder-migration.md

It deviates a bit from the work list, because it turns out not to be
necessary to fork controller-tools now that they have added a flag to
support "unsafe" types like our float64 field.

Replaces #650
Fixes #651

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Replace build/Dockerfile with a symlink because we still have CI jobs
and quay.io configurations using the file from that location.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
@metal3-io-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhellmann

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 27, 2020
@dhellmann
Copy link
Copy Markdown
Member Author

@zaneb @maelk see if this version is easier to follow than #650

@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

@dhellmann dhellmann force-pushed the kubebuilder-rewrite2 branch 3 times, most recently from 8a3c783 to b993195 Compare September 27, 2020 23:15
@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

Copy link
Copy Markdown
Member

@maelk maelk left a comment

Choose a reason for hiding this comment

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

That's an amazing work! I have some details / nit picks but it overall looks good to me.

Comment thread main.go
Comment thread main.go
Comment thread main.go Outdated
Comment thread hack/generate.sh Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread controllers/metal3.io/action_result.go Outdated
Comment thread controllers/metal3.io/action_result.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems really similar idea to k8s.io/apimachinery/pkg/util/wait

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Interesting. @andfasano @zaneb I wonder if we would gain anything by using the apimachinery code?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good to know! I had a quick look at the apimachinery code, but most of the implementation is based on timer, whereas we rely on the RequeueAfter re-enqueueing period field. Very likely the only reusable piece could the Backoff type, not sure if it's worth given the simplicity of the current implementation

@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

@zaneb
Copy link
Copy Markdown
Member

zaneb commented Sep 28, 2020

It looks like we now have two copies of the CRD (in deploy/crds/metal3.io_baremetalhosts_crd.yaml and config/crd/bases/metal3.io_baremetalhosts.yaml). Presumably that's required for testing, but I think we should replace the old one with a symlink to ensure we're testing the right thing.

@dhellmann
Copy link
Copy Markdown
Member Author

It looks like we now have two copies of the CRD (in deploy/crds/metal3.io_baremetalhosts_crd.yaml and config/crd/bases/metal3.io_baremetalhosts.yaml). Presumably that's required for testing, but I think we should replace the old one with a symlink to ensure we're testing the right thing.

@maelk and I are going to look at cleaning up the kustomize files from the deploy and config directories as a separate PR after the repo is unblocked. We will eliminate the duplicate as part of that.

@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

1 similar comment
@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

Move the files into the kubebuilder locations, without modifying them,
to make tracking changes in the files easier.

Remove auto-generated code that we won't be using after the migration.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Add the BareMetalHost API and controller.

Move command line flags controlling which provisioner is used to
main.go and make ProvisionerFactory a public member of the reconciler.

Move logic for determining the concurrency level to the point at
runtime where the reconciler is added to the manager. This lets us
return an error instead of forcing an exit.

Remove the suite_test.go file generated by kubebuilder, since we don't
use that test framework.

Fix up unit tests so they work.

Minor changes:
- Replace r.client calls.
- Replace reconcile.Result with ctrl.Result.
- Fix package name in controller code
- Move controller test setup to one init() since it changes global state

$ kubebuilder create api --group metal3.io --version v1alpha1 --kind BareMetalHost
Create Resource [y/n]
y
Create Controller [y/n]
y
Writing scaffold for you to edit...
apis/metal3.io/v1alpha1/baremetalhost_types.go
controllers/metal3.io/baremetalhost_controller.go
$ rm controllers/metal3.io/suite_test.go

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Use the latest release and pass the arguments we need to allow us to
use the float64 field for clock speed and to generate output
consistent with what we had from the operator-sdk.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
- Bring version numbers back to what they were before the migration.
- Include a make target to tidy and verify them.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
generate.sh: files to watch have moved and expanded
gofmt.sh: list go packages to find directories to scan
gosec.sh: scan all local packages

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Since we don't have any webhooks, don't configure the server to listen.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Update the manager_auth_proxy_patch.yaml to set the metrics address to
the same value used by default in main.go.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
We no longer need to tell people to install the operator-sdk, or to
use it to run the tests.

Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
@dhellmann
Copy link
Copy Markdown
Member Author

/test-integration

Comment thread Makefile
Comment on lines +164 to +176
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This does not ensure that we are running with a specific version of controller-gen. If the user has an outdated controller-gen installed on his machine, it might result in confusing behaviour. Should the executable be placed in a dedicated location, and referred as such, like Kustomize ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We discussed this today in the community meeting and agreed that I will make this change as a follow-up PR.

@zaneb
Copy link
Copy Markdown
Member

zaneb commented Sep 30, 2020

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 30, 2020
@metal3-io-bot metal3-io-bot merged commit 6c0d397 into metal3-io:master Sep 30, 2020
@digambar15
Copy link
Copy Markdown

Looks good to me!

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unrecognized import path "vbom.ml/util"

7 participants