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

Invalid CRD with when no string default value is used #6654

Closed
mfvitale opened this issue Nov 25, 2024 · 3 comments · Fixed by #6666
Closed

Invalid CRD with when no string default value is used #6654

mfvitale opened this issue Nov 25, 2024 · 3 comments · Fixed by #6666
Assignees
Labels
Milestone

Comments

@mfvitale
Copy link

mfvitale commented Nov 25, 2024

Describe the bug

With the generator v2 the default are not working as expected. If you define for example

@Default(defaultValue = "60000")
private long flushMs = 60000L;

the generated crd will put the default value as a string causing the crd to not be valid.

Error from server (Invalid): error when creating "k8/debeziumservers.debezium.io-v1.yml": CustomResourceDefinition.apiextensions.k8s.io "debeziumservers.debezium.io" is invalid: [spec.validation.openAPIV3Schema.properties[spec].properties[source].properties[offset].properties[flushMs].default: Invalid value: "string":  in body must be of type integer: 

Fabric8 Kubernetes Client version

6.13.4

Steps to reproduce

Maybe adding a test in

will be a good starting point to easily reproduce it.

Expected behavior

The correct default value should be used.

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.25.3@latest

Environment

Linux

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

@mfvitale
Copy link
Author

@andreaTP

@manusa
Copy link
Member

manusa commented Nov 25, 2024

Additional context:

The issue is applicable for both the @Default annotation and the @JsonProperty defaultValue:

defaultValue = beanProperty.getMetadata().getDefaultValue();

defaultValue = ofNullable(beanProperty.getAnnotation(Default.class)).map(Default::value).orElse(defaultValue);

For CRD v1 this is only applicable to the @Default annotation, the @JsonProperty defaultValue config is not taken into account:

case ANNOTATION_DEFAULT:
defaultValue = (String) a.getParameters().get(VALUE);
break;

The issue is now visible because the Quarkus Operator SDK switched to use CRD v2 in quarkiverse/quarkus-operator-sdk#927

🙌🙌🙌 @metacosm has added a fix in Quarkus Operator SDK to be able to use CRD v1: quarkiverse/quarkus-operator-sdk#1007

quarkiverse/quarkus-operator-sdk#1009

A release with the fix will be available in: https://github.com/quarkiverse/quarkus-operator-sdk/releases/tag/6.9.1

@manusa manusa added the bug label Nov 25, 2024
@manusa manusa added this to the 7.0.0 milestone Nov 25, 2024
@manusa manusa moved this to Planned in Eclipse JKube Nov 25, 2024
@metacosm
Copy link
Collaborator

I have also backported the change to 6.8.5, which should also be released today.

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

Successfully merging a pull request may close this issue.

3 participants