"Duplicate value: http" error when it is declared in service.yml file
See original GitHub issueDescription
Declared a deployment.yml file with the following structure:
spec:
template:
spec:
containers:
- ports:
- containerPort: 8181
name: http
protocol: TCP
Throws the following exception when the application is deployed:
[ERROR] oc: Failed to update DeploymentConfig from openshift.yml. io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: PUT at: https://api.crc.testing:6443/apis/apps.openshift.io/v1/namespaces/amq-streams-demo/deploymentconfigs/kafka-clients-quarkus-sample-green. Message: DeploymentConfig.apps.openshift.io "kafka-clients-quarkus-sample-green" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: "http". Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.containers[0].ports[1].name, message=Duplicate value: "http", reason=FieldValueDuplicate, additionalProperties={})], group=apps.openshift.io, kind=DeploymentConfig, name=kafka-clients-quarkus-sample-green, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=DeploymentConfig.apps.openshift.io "kafka-clients-quarkus-sample-green" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: "http", metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).. DeploymentConfig(apiVersion=apps.openshift.io/v1, kind=DeploymentConfig, metadata=ObjectMeta(annotations={app.openshift.io/vcs-ref=feature/b-g-deployment-strategy, jkube.io/git-url=https://github.com/rmarting/kafka-clients-quarkus-sample.git, app.openshift.io/vcs-uri=https://github.com/rmarting/kafka-clients-quarkus-sample.git, jkube.io/git-commit=c2c0cb82670db43882c8b3b36e431173a0501927, jkube.io/git-branch=feature/b-g-deployment-strategy}, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels={group=com.rmarting.kafka, project=kafka-clients-quarkus-sample, version=1.0.0-SNAPSHOT, app=kafka-clients-quarkus-sample-green, provider=jkube}, managedFields=[], name=kafka-clients-quarkus-sample-green, namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=DeploymentConfigSpec(minReadySeconds=null, paused=null, replicas=1, revisionHistoryLimit=2, selector={app=kafka-clients-quarkus-sample, provider=jkube, group=com.rmarting.kafka}, strategy=DeploymentStrategy(activeDeadlineSeconds=null, annotations=null, customParams=null, labels=null, recreateParams=null, resources=null, rollingParams=RollingDeploymentStrategyParams(intervalSeconds=null, maxSurge=null, maxUnavailable=null, post=null, pre=null, timeoutSeconds=3600, updatePeriodSeconds=null, additionalProperties={}), type=Rolling, additionalProperties={}), template=PodTemplateSpec(metadata=ObjectMeta(annotations={app.openshift.io/vcs-ref=feature/b-g-deployment-strategy, jkube.io/git-url=https://github.com/rmarting/kafka-clients-quarkus-sample.git, app.openshift.io/vcs-uri=https://github.com/rmarting/kafka-clients-quarkus-sample.git, jkube.io/git-commit=c2c0cb82670db43882c8b3b36e431173a0501927, jkube.io/git-branch=feature/b-g-deployment-strategy}, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels={app=kafka-clients-quarkus-sample, provider=jkube, version=1.0.0-SNAPSHOT, group=com.rmarting.kafka}, managedFields=[], name=null, namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=PodSpec(activeDeadlineSeconds=null, affinity=null, automountServiceAccountToken=null, containers=[Container(args=[], command=[], env=[EnvVar(name=KAFKA_USER_PASSWORD, value=null, valueFrom=EnvVarSource(configMapKeyRef=null, fieldRef=null, resourceFieldRef=null, secretKeyRef=SecretKeySelector(key=password, name=application, optional=null, additionalProperties={}), additionalProperties={}), additionalProperties={}), EnvVar(name=APP_BG_VERSION, value=green, valueFrom=null, additionalProperties={}), EnvVar(name=APP_BG_MODE, value=offline, valueFrom=null, additionalProperties={}), EnvVar(name=KUBERNETES_NAMESPACE, value=null, valueFrom=EnvVarSource(configMapKeyRef=null, fieldRef=ObjectFieldSelector(apiVersion=null, fieldPath=metadata.namespace, additionalProperties={}), resourceFieldRef=null, secretKeyRef=null, additionalProperties={}), additionalProperties={})], envFrom=[], image=kafka-clients-quarkus-sample-green:1.0.0-SNAPSHOT, imagePullPolicy=IfNotPresent, lifecycle=null, livenessProbe=Probe(exec=null, failureThreshold=3, httpGet=HTTPGetAction(host=null, httpHeaders=[], path=/health/live, port=IntOrString(IntVal=8181, Kind=0, StrVal=null, additionalProperties={}), scheme=HTTP, additionalProperties={}), initialDelaySeconds=5, periodSeconds=10, successThreshold=1, tcpSocket=null, timeoutSeconds=1, additionalProperties={}), name=quarkus, ports=[ContainerPort(containerPort=8181, hostIP=null, hostPort=null, name=http, protocol=TCP, additionalProperties={}), ContainerPort(containerPort=8080, hostIP=null, hostPort=null, name=http, protocol=TCP, additionalProperties={})], readinessProbe=Probe(exec=null, failureThreshold=3, httpGet=HTTPGetAction(host=null, httpHeaders=[], path=/health/ready, port=IntOrString(IntVal=8181, Kind=0, StrVal=null, additionalProperties={}), scheme=HTTP, additionalProperties={}), initialDelaySeconds=5, periodSeconds=10, successThreshold=1, tcpSocket=null, timeoutSeconds=1, additionalProperties={}), resources=null, securityContext=SecurityContext(allowPrivilegeEscalation=null, capabilities=null, privileged=false, procMount=null, readOnlyRootFilesystem=null, runAsGroup=null, runAsNonRoot=null, runAsUser=null, seLinuxOptions=null, windowsOptions=null, additionalProperties={}), startupProbe=null, stdin=null, stdinOnce=null, terminationMessagePath=null, terminationMessagePolicy=null, tty=null, volumeDevices=[], volumeMounts=[], workingDir=null, additionalProperties={})], dnsConfig=null, dnsPolicy=null, enableServiceLinks=null, ephemeralContainers=[], hostAliases=[], hostIPC=null, hostNetwork=null, hostPID=null, hostname=null, imagePullSecrets=[], initContainers=[], nodeName=null, nodeSelector=null, overhead=null, preemptionPolicy=null, priority=null, priorityClassName=null, readinessGates=[], restartPolicy=null, runtimeClassName=null, schedulerName=null, securityContext=null, serviceAccount=null, serviceAccountName=null, shareProcessNamespace=null, subdomain=null, terminationGracePeriodSeconds=null, tolerations=[], topologySpreadConstraints=[], volumes=[], additionalProperties={}), additionalProperties={}), test=null, triggers=[DeploymentTriggerPolicy(imageChangeParams=null, type=ConfigChange, additionalProperties={}), DeploymentTriggerPolicy(imageChangeParams=DeploymentTriggerImageChangeParams(automatic=true, containerNames=[quarkus], from=ObjectReference(apiVersion=null, fieldPath=null, kind=ImageStreamTag, name=kafka-clients-quarkus-sample-green:1.0.0-SNAPSHOT, namespace=null, resourceVersion=null, uid=null, additionalProperties={}), lastTriggeredImage=null, additionalProperties={}), type=ImageChange, additionalProperties={})], additionalProperties={}), status=null, additionalProperties={}): io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: PUT at: https://api.crc.testing:6443/apis/apps.openshift.io/v1/namespaces/amq-streams-demo/deploymentconfigs/kafka-clients-quarkus-sample-green. Message: DeploymentConfig.apps.openshift.io "kafka-clients-quarkus-sample-green" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: "http". Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.template.spec.containers[0].ports[1].name, message=Duplicate value: "http", reason=FieldValueDuplicate, additionalProperties={})], group=apps.openshift.io, kind=DeploymentConfig, name=kafka-clients-quarkus-sample-green, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=DeploymentConfig.apps.openshift.io "kafka-clients-quarkus-sample-green" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: "http", metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).
The next definition works successfully:
spec:
template:
spec:
containers:
- ports:
- containerPort: 8181
name: http-web
protocol: TCP
However the deployment declares finally two ports (http:8080) and (http-web:8181), but my applications has not declared that port as needed.
spec:
template:
spec:
containers:
- ports:
- name: http-web
containerPort: 8181
protocol: TCP
- name: http
containerPort: 8080
protocol: TCP
IMHO my deployment definition should be used to define the service ports.
Info
- Eclipse JKube version : openshift-maven-plugin:1.0.1
- Maven version (
mvn -v) :
❯ mvn -v
Maven home: /home/rmarting/Software/apache-maven-3.6.3
Java version: 11.0.8, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.8.10-2.fc32.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.8.15-201.fc32.x86_64", arch: "amd64", family: "unix"
- Kubernetes / Red Hat OpenShift setup and version :
❯ crc version
CodeReady Containers version: 1.17.0+99f5c87
OpenShift version: 4.5.14 (embedded in binary)
- If it’s a bug, how to reproduce :
1.- Create a deployment.yml file with a http port definition 2.- Deploy application
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Which status code should I use for failed validations or invalid ...
Trying to add a duplicate: 409 Conflict ("The request could not be completed due to a conflict with the current state of the...
Read more >HTTP status code for duplicate record - Metamug
When a new record is created 201 Created is sent in the status code. When the response is 202 Accepted , even in...
Read more >HTTP Status Codes List | HTTP Error Codes Explained
When a client asks for resources, it can be possible that a response includes duplicate resources, which would mean the same resources would...
Read more >HTTP Status Codes - REST API Tutorial
HTTP status codes and how to use them in RESTful API or Web Services.
Read more >HttpStatusCode Enum (System.Net) - Microsoft Learn
Equivalent to HTTP status 226. IMUsed indicates that the server has fulfilled a request for the resource, and the response is a representation...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re right. We definitely need to improve the Quarkus Generator. Thx for taking the time to look into this.
fixed by #623