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

Quickstart for go fails on create custom resource step

Open bradtopol opened this issue 3 years ago • 6 comments

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 avatar Feb 16 '22 22:02 bradtopol

@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)

varshaprasad96 avatar Feb 21 '22 18:02 varshaprasad96

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.

bradtopol avatar Feb 23 '22 19:02 bradtopol

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.

jmrodri avatar Mar 07 '22 19:03 jmrodri

@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"

everettraven avatar Apr 07 '22 16:04 everettraven

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

openshift-bot avatar Jul 06 '22 19:07 openshift-bot

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

openshift-bot avatar Aug 05 '22 19:08 openshift-bot

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 avatar Sep 05 '22 00:09 openshift-bot

@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.

openshift-ci[bot] avatar Sep 05 '22 00:09 openshift-ci[bot]