operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

Make install target is broken because try to install the kustomize when it is installed already

Open camilamacedo86 opened this issue 2 years ago • 6 comments

Bug Report

What did you do?

call make install twice

What did you expect to see?

Not fail and just install the kustomize if that is not installed already

What did you see instead? Under which circumstances?

The following error in the second time because the bin is in the dir already

$ make install
/Users/camilamacedo86/go/src/guestbook/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- 3.8.7 /Users/camilamacedo86/go/src/guestbook/bin
/Users/camilamacedo86/go/src/guestbook/bin/kustomize exists. Remove it first.
make: *** [Makefile:123: /Users/camilamacedo86/go/src/guestbook/bin/kustomize] Error 1

Environment

Operator type:

/language go /language ansible /language helm

$ operator-sdk version

master

camilamacedo86 avatar Jun 14 '22 09:06 camilamacedo86

@camilamacedo86: The label(s) language/--> cannot be applied, because the repository doesn't have them.

In response to this:

Bug Report

What did you do?

call make install twice

What did you expect to see?

Not fail and just install the kustomize if that is not installed already

What did you see instead? Under which circumstances?

The following error in the second time because the bin is in the dir already

$ make install
/Users/camilamacedo86/go/src/guestbook/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- 3.8.7 /Users/camilamacedo86/go/src/guestbook/bin
/Users/camilamacedo86/go/src/guestbook/bin/kustomize exists. Remove it first.
make: *** [Makefile:123: /Users/camilamacedo86/go/src/guestbook/bin/kustomize] Error 1

Environment

Operator type:

/language go --> /language ansible --> /language helm

$ operator-sdk version

master

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci[bot] avatar Jun 14 '22 09:06 openshift-ci[bot]

c/c @ryantking

camilamacedo86 avatar Jun 14 '22 09:06 camilamacedo86

This seems like the make target for installing kustomize just needs to be changed to this simple bash expression:

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
	test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

In case it helps see before/after:

--- a/Makefile
+++ b/Makefile
@@ -168,7 +168,7 @@ KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/k
 .PHONY: kustomize
 kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
 $(KUSTOMIZE): $(LOCALBIN)
-       curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN)
+       test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

jchunkins avatar Jun 21 '22 21:06 jchunkins

TODO: do we need to bump kubebuilder to get this?

jberkhahn avatar Jun 27 '22 18:06 jberkhahn

Still need to bump kubebuilder it seems, we updated to 3.5.0, which i assume doesnt have this change @camilamacedo86 ?

asmacdo avatar Jul 20 '22 18:07 asmacdo

@asmacdo we can check that the change was made in the PR linked: https://github.com/kubernetes-sigs/kubebuilder/pull/2774

Therefore, we can see that it is only in master and that we do have not an update here on the SDK side, see the SDK testdata samples:

https://github.com/operator-framework/operator-sdk/blob/87cdc50247832a53e26b713a2ecab6e2215bdb52/testdata/go/v3/memcached-operator/Makefile#L169-L173

We can do that now by updating the master commit OR we can wait for the next KB release. Indeed we do many times bump using the commits. Would you like to do this one? If yes, please feel free to do the bump and I can help with the reviews.

camilamacedo86 avatar Jul 21 '22 09:07 camilamacedo86

Sorted out.

camilamacedo86 avatar Aug 15 '22 21:08 camilamacedo86