kubernetes-client icon indicating copy to clipboard operation
kubernetes-client copied to clipboard

deserialize value of type `int` from String

Open ho-yasla opened this issue 3 years ago • 4 comments
trafficstars

template = client.templates().inNamespace(NamespaceName).withName(templateName).get();

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `int` from String "${{NUMBER_OF_INSTANCES}}": not a valid `int` value
 at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: io.fabric8.openshift.api.model.Template["objects"]->java.util.ArrayList[3]->io.fabric8.kubernetes.api.model.apps.StatefulSet["spec"]->io.fabric8.kubernetes.api.model.apps.StatefulSetSpec["replicas"])
<dependency>
            <groupId>io.fabric8</groupId>
            <artifactId>openshift-client</artifactId>
            <version>5.12.2</version>
</dependency>

ho-yasla avatar Apr 29 '22 11:04 ho-yasla

This is a known issue with retrieving templates in their object form - it could be addressed by #4034

The workaround for now is that you either need to use withParameters to supply the template values, or retrieve as a generic kubernetes resource.

shawkins avatar Apr 29 '22 11:04 shawkins

This is a known issue with retrieving templates in their object form - it could be addressed by #4034

The workaround for now is that you either need to use withParameters to supply the template values, or retrieve as a generic kubernetes resource.

Can you provide an example source for a workaround?

ho-yasla avatar Apr 29 '22 12:04 ho-yasla

To replace the parameter values:

client.templates().inNamespace(NamespaceName).withName(templateName).process(map)

To read the template as a generic

client.genericKubernetesResources("template.openshift.io/v1", "Template").inNamespace(NamespaceName).withName(templateName).get()

or

client.genericKubernetesResources(ResourceDefinitionContext.fromResourceType(Template.class)).withName(templateName).get()

shawkins avatar May 02 '22 20:05 shawkins

@ho-yasla : polite ping, Did the suggestion from Steven worked for your use case?

rohanKanojia avatar May 16 '22 12:05 rohanKanojia

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

stale[bot] avatar Aug 14 '22 13:08 stale[bot]

Fixed by #4292

manusa avatar Aug 23 '22 12:08 manusa