Quickstart for go fails on create custom resource step
What is the URL of the document?
https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/
Which section(s) is the issue in?
Create a sample Memcached custom resource: $ kubectl apply -f config/samples/cache_v1alpha1_memcached.yaml memcached.cache.example.com/memcached-sample created
What needs fixing?
When I run the create custom resource command as shown in the quick start guide: $ kubectl apply -f config/samples/cache_v1alpha1_memcached.yaml I do not get the following output as shown in the guide:
memcached.cache.example.com/memcached-sample created
Instead I get:
The Memcached "memcached-sample" is invalid: spec: Invalid value: "null": spec in body must be of type object: "null"
I suspect it is no longer permissible for the spec to be empty. My guess is the quickstart needs to be updated with some minimal update to spec for this to work.
Any suggestions on what would be the minimal amount to add to the quickstart to make it work? I am happy to make the suggested change
Additional context
I checked this time and am on an up to date version of the tool! :-) operator-sdk version operator-sdk version: "v1.17.0-1-g836a088e", commit: "836a088eee1195515657fb223cf9274cf6e963ed", kubernetes version: "v1.21", go version: "go1.17.6", GOOS: "darwin", GOARCH: "amd64"
@bradtopol can you check if the spec in config/samples/cache_v1alpha1_memcached.yaml is null, or is filled with the value which you have defined in memcached_types.go? If not, can you run make generate to ensure that the key which you have specified in _types.go is reflected in cache_v1alpha1_memcached.yaml and then you can specify the required value for the spec.
Ex:
size is defined in https://github.com/operator-framework/operator-sdk/blob/bf5f3b796d9596bf91315666f797c9e4779ccbbe/testdata/go/v3/memcached-operator/api/v1alpha1/memcached_types.go#L32 and it should appear in spec of cache_v1alpha1_memcached.yaml here (https://github.com/operator-framework/operator-sdk/blob/bf5f3b796d9596bf91315666f797c9e4779ccbbe/testdata/go/v3/memcached-operator/config/samples/cache_v1alpha1_memcached.yaml#L6)
Hi @varshaprasad96! You are correct the value in cache_v1alpha1_memcached.yaml is empty. I could follow your instructions to fix it. But my point was if you are new to operator SDK and just blindly follow the steps listed in https://sdk.operatorframework.io/docs/building-operators/golang/quickstart/ you never do the steps you describe and end up in the state I encountered.
For those willing to help, I suggest you run through the quickstart guide making note of any discrepancies and update the quickstart guide as needed.
@bradtopol I went through the Quickstart guide and didn't have any issues with the config/samples/cache_v1alpha1_memcached.yaml file that is generated.
Is this still an issue that you are encountering?
Here is the output I get when running operator-sdk version:
operator-sdk version: "v1.18.1", commit: "707240f006ecfc0bc86e5c21f6874d302992d598", kubernetes version: "1.21", go version: "go1.17.7", GOOS: "linux", GOARCH: "amd64"
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.
/close
@openshift-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen. Mark the issue as fresh by commenting/remove-lifecycle rotten. Exclude this issue from closing again by commenting/lifecycle frozen./close
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.