kudobuilder / kudo

Kubernetes Universal Declarative Operator (KUDO)
https://kudo.dev
Apache License 2.0
1.18k stars 101 forks source link

`make all` fails in `hack/update_codegen.sh` #1051

Closed porridge closed 4 years ago

porridge commented 5 years ago

What happened:

I ran make all as instructed. It failed after a few minutes:

./hack/update_codegen.sh
go: finding github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78
[...]
go: finding sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4
Cloning into 'hack/code-gen/8e001e5d1894'...
remote: Enumerating objects: 279, done.
remote: Counting objects: 100% (279/279), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 7519 (delta 141), reused 199 (delta 85), pack-reused 7240
Receiving objects: 100% (7519/7519), 4.43 MiB | 391.00 KiB/s, done.
Resolving deltas: 100% (3670/3670), done.
HEAD is now at 8e001e5 Merge pull request #83433 from liggitt/automated-cherry-pick-of-#83261-upstream-release-1.16
go mod init: go.mod already exists
./hack/update_codegen.sh: linia 22: hack/code-gen/8e001e5d1894/generate-groups.sh: Nie ma takiego pliku ani katalogu
Makefile:84: polecenia dla obiektu 'generate' nie powiodły się
make: *** [generate] Błąd 127

What you expected to happen:

Success.

How to reproduce it (as minimally and precisely as possible):

Follow the documented build instructions.

porridge commented 5 years ago

The bug is here:

    cd "${CODE_GEN_DIR}" && git reset --hard "${VERSION}" && go mod init && cd -
fi

"${CODE_GEN_DIR}"/generate-groups.sh \

If go.mod already exists in $CODE_GEN_DIR, then go mod init exits 1:

porridge@beczulka:~/Desktop/work/mesosphere/code/kudo/hack/code-gen/8e001e5d1894$ go mod init
go mod init: go.mod already exists
porridge@beczulka:~/Desktop/work/mesosphere/code/kudo/hack/code-gen/8e001e5d1894$ echo $?
1
porridge@beczulka:~/Desktop/work/mesosphere/code/kudo/hack/code-gen/8e001e5d1894$ 

and therefore cd - does not executed, and the subsequent command fails since $CODE_GEN_DIR is relative.

porridge commented 5 years ago

I'm guessing the author (cc @hypnoglow ) was not aware that && is tricky:

porridge@beczulka:~/tmp$ cat a.sh 
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail

false && true
echo still running
porridge@beczulka:~/tmp$ ./a.sh 
still running
porridge@beczulka:~/tmp$ 
porridge commented 5 years ago

After fixing that, the next failure is:

./hack/update_codegen.sh
Using cached code generator version: 8e001e5d1894
Generating deepcopy funcs
hack/code-gen/8e001e5d1894/generate-groups.sh: line 71: GOPATH: unbound variable
Makefile:84: recipe for target 'generate' failed
make: *** [generate] Error 1

This is https://github.com/kubernetes/code-generator/issues/87 and thus unlikely something we can fix here...