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

https://book.kubebuilder.io/cronjob-tutorial/cronjob-tutorial #4074

Closed
remotejob opened this issue Aug 13, 2024 · 3 comments · Fixed by #4075
Closed

https://book.kubebuilder.io/cronjob-tutorial/cronjob-tutorial #4074

remotejob opened this issue Aug 13, 2024 · 3 comments · Fixed by #4075

Comments

@remotejob
Copy link

remotejob commented Aug 13, 2024

make run

go run ./cmd/main.go

vet: api/v1/zz_generated.deepcopy.go:126:10: cannot use c (variable of type *CronJobSpec) as "k8s.io/apimachinery/pkg/runtime".Object value in return statement: *CronJobSpec does not implement "k8s.io/apimachinery/pkg/runtime".Object (missing method GetObjectKind)

@sbueringer
Copy link
Member

/transfer kubebuilder

@k8s-ci-robot k8s-ci-robot transferred this issue from kubernetes-sigs/controller-tools Aug 13, 2024
@camilamacedo86
Copy link
Member

Hi @remotejob

The only issue that I found was Too long: must have at most 262144 bytes

$ make install
/Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
Downloading sigs.k8s.io/kustomize/kustomize/[email protected]
/Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/bin/kustomize build config/crd | kubectl apply -f -
The CustomResourceDefinition "cronjobs.batch.tutorial.kubebuilder.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
make: *** [install] Error 1

To address this one we should be scaffolding the Makefile with crd:maxDescLen=0
We need change the hack/docs to add this replace (it seems a regression), as:

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
	# Note that the option maxDescLen=0 was added in the default scaffold in order to sort out the issue
	# Too long: must have at most 262144 bytes. By using kubectl apply to create / update resources an annotation
	# is created by K8s API to store the latest version of the resource ( kubectl.kubernetes.io/last-applied-configuration).
	# However, it has a size limit and if the CRD is too big with so many long descriptions as this one it will cause the failure.
	$(CONTROLLER_GEN) rbac:roleName=manager-role crd:maxDescLen=0 webhook paths="./..." output:crd:artifacts:config=config/crd/bases

However, after change the make manifest target the make run worked fine:

$ export ENABLE_WEBHOOKS=false
$ make run
# Note that the option maxDescLen=0 was added in the default scaffold in order to sort out the issue
# Too long: must have at most 262144 bytes. By using kubectl apply to create / update resources an annotation
# is created by K8s API to store the latest version of the resource ( kubectl.kubernetes.io/last-applied-configuration).
# However, it has a size limit and if the CRD is too big with so many long descriptions as this one it will cause the failure.
/Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/bin/controller-gen rbac:roleName=manager-role crd:maxDescLen=0 webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/Users/camiladeomacedo/go/src/sigs.k8s.io/kubebuilder/docs/book/src/cronjob-tutorial/testdata/project/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go run ./cmd/main.go
2024-08-13T05:49:31+01:00	INFO	setup	starting manager
2024-08-13T05:49:31+01:00	INFO	starting server	{"name": "health probe", "addr": "[::]:8081"}
2024-08-13T05:49:32+01:00	INFO	Starting EventSource	{"controller": "cronjob", "controllerGroup": "batch.tutorial.kubebuilder.io", "controllerKind": "CronJob", "source": "kind source: *v1.CronJob"}
2024-08-13T05:49:32+01:00	INFO	Starting EventSource	{"controller": "cronjob", "controllerGroup": "batch.tutorial.kubebuilder.io", "controllerKind": "CronJob", "source": "kind source: *v1.Job"}
2024-08-13T05:49:32+01:00	INFO	Starting Controller	{"controller": "cronjob", "controllerGroup": "batch.tutorial.kubebuilder.io", "controllerKind": "CronJob"}
2024-08-13T05:49:32+01:00	INFO	Starting workers	{"controller": "cronjob", "controllerGroup": "batch.tutorial.kubebuilder.io", "controllerKind": "CronJob", "worker count": 1}

You might be using an unsupported golang version.
Could you please validate your env and if you still facing issues can you please provide the steps performed so that we try to reproduce it as what is your SO and go version.

thank you

@camilamacedo86
Copy link
Member

camilamacedo86 commented Aug 13, 2024

Hi @remotejob

I am closing this one with the fix/change: #4075
However, if you:

  • Ensure that you are using go version 1.22
  • Ensure that you are running make install and make run

And still facing issues please feel free to open a new issue describing your local env setup , so and steps performed for we try to reproduce this one.

Thank you for your comprehension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants