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

Can't replace Service when upgraded | spec.clusterIP: Invalid value: "": field is immutable. #1925

Closed
cedar715 opened this issue Jan 3, 2020 · 1 comment · Fixed by #1931

Comments

@cedar715
Copy link

cedar715 commented Jan 3, 2020

Following is the code snippet used to create Service resource. It is failing when I upgraded Fabric8 from 4.1.1 to 4.6.4.

ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> load =
                kubernetesClient.resourceList(resourceDescriptor)
 final List<HasMetadata> res = load.createOrReplace()

resourceDescriptor is a String holding the Service manifest file.

Failed to apply :
apiVersion: v1
kind: Service
metadata:
name: httpbin
labels:
app: httpbin
spec:
ports:
- name: http
port: 5511
targetPort: 8080
selector:
deploymentconfig: httpbin
: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: PUT at: https://xxx:8443/api/v1/namespaces/xxx/services/httpbin. Message: Service "httpbin" is invalid: spec.clusterIP: Invalid value: "": field is immutable. Received status: Status(apiVersion=v1, code=422, details=StatusDetails(causes=[StatusCause(field=spec.clusterIP, message=Invalid value: "": field is immutable, reason=FieldValueInvalid, additionalProperties={})], group=null, kind=Service, name=httpbin, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=Service "httpbin" is invalid: spec.clusterIP: Invalid value: "": field is immutable, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=Invalid, status=Failure, additionalProperties={}).

@rohanKanojia
Copy link
Member

rohanKanojia commented Jan 3, 2020

@cedar715 : Thanks for your bug report. I can confirm that I can reproduce this issue. It's strage I'm not able to reproduce if I create service like this:

     client.services().inNamespace("default").createOrReplace(svc);

But I can reproduce this error when I do it your way:

		String resourceList = "apiVersion: v1\n" +
					"kind: Service\n" +
					"metadata:\n" +
					"  name: httpbin\n" +
					"  labels:\n" +
					"    app: httpbin\n" +
					"spec:\n" +
					"  ports:\n" +
					"  - name: http\n" +
					"    port: 5511\n" +
					"    targetPort: 8080\n" +
					"  selector:\n" +
					"    deploymentconfig: httpbin";


			ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata, Boolean> load = client.resourceList(resourceList);
			final List<HasMetadata> res = load.inNamespace("default").createOrReplace();

rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jan 6, 2020
…erver while patching it.

While replace method, client was showing variable behaviors when done through different
ways in dsl. For example,

   client.services().inNamespace("test").createOrReplace(item);

Used to load Service from server since reloadingFromServer was set to true in this case but
if we use a generic handler reloadingFromServer was set to false. I think in case of replace
operations we should always load object from server since Kubernetes API doesn't accept
patching Service object wihout ClusterIP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants