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

run complains of having no name, when it is provided #4633

Closed
DavidPerezIngeniero opened this issue Dec 2, 2022 · 2 comments · Fixed by #4640
Closed

run complains of having no name, when it is provided #4633

DavidPerezIngeniero opened this issue Dec 2, 2022 · 2 comments · Fixed by #4640
Assignees
Milestone

Comments

@DavidPerezIngeniero
Copy link

Describe the bug

In the same machine (a pod inside MiniKube), kubectl run does work, whereas fabric8 fails.

Fabric8 Kubernetes Client version

6.2.0

Steps to reproduce

cli = (new KubernetesClientBuilder).build();
pod = cli.run()
  .withName("pru3")
  .withImage("alpine")
  .withRunConfig(new RunConfigBuilder().addToArgs("-c", "echo", "cucu").build())
  .done();

Expected behavior

Not to fail and start the pod.
It complains the pod doesn't have a name, and I provide one with withName().

Runtime

minikube

Kubernetes API Server version

1.24

Environment

Linux

Fabric8 Kubernetes Client Logs

io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://10.96.0.1/api/v1/namespaces/default/pods. Message: Pod "" is invalid: [metadata.name: Required value: name or generateName is required, spec.containers[0].name: Required value, spec.containers[0].image: Required value]. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=metadata.name, message=Required value: name or generateName is required, reason=FieldValueRequired, additionalProperties={}), StatusCause(field=spec.containers[0].name, message=Required value, reason=FieldValueRequired, additionalProperties={}), StatusCause(field=spec.containers[0].image, message=Required value, reason=FieldValueRequired, additionalProperties={})], group=null, kind=Pod, name=null, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Pod "" is invalid: [metadata.name: Required value: name or generateName is required, spec.containers[0].name: Required value, spec.containers[0].image: Required value], metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
  io.fabric8.kubernetes.client.KubernetesClientException.copyAsCause(KubernetesClientException.java:238)
  io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:517)
  io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:551)
  io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:535)
  io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleCreate(OperationSupport.java:328)


### Additional context

I've tried to follow this example.  Only testing passing arguments.

https://github.com/fabric8io/kubernetes-client/blob/master/kubernetes-examples/src/main/java/io/fabric8/kubernetes/examples/kubectl/equivalents/PodRunEquivalent.java
@DavidPerezIngeniero DavidPerezIngeniero changed the title run run complains of having no name, when it is provided Dec 2, 2022
@DavidPerezIngeniero
Copy link
Author

DavidPerezIngeniero commented Dec 2, 2022

cli.run().withName("pru3").withImage("alpine").done()

succeeds, doesn't like RunConfig

It does work:

pod = cli.run().withRunConfig(new RunConfigBuilder().addToArgs("-c", "echo", "cucu").withName("pru3").withImage("alpine").build()).done() 

It is confusing to have methods like withName() in RunOperations that do nothing.

@shawkins
Copy link
Contributor

shawkins commented Dec 2, 2022

It is confusing to have methods like withName() in RunOperations that do nothing.

The problem, which is not clarified by the javadocs, is that withRunConfig supersedes any of the previous context values.

shawkins added a commit to shawkins/kubernetes-client that referenced this issue Dec 2, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Dec 2, 2022
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Dec 7, 2022
manusa pushed a commit to shawkins/kubernetes-client that referenced this issue Dec 20, 2022
@manusa manusa added this to the 6.4.0 milestone Dec 20, 2022
manusa pushed a commit to shawkins/kubernetes-client that referenced this issue Dec 20, 2022
manusa pushed a commit that referenced this issue Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants