Repository: kubernetes
Issue: service cluster ip allocate failed should not return 422 code
Labels: kind/bug,sig/api-machinery,triage/accepted

### What happened?

Client create a service, due to etcd leader changed, cluster ip allocated failed, apiserver return a 422 code. According to http return code specification, client will not try again.

`rest response error, response={'audit-id': '9034adf1-8634-4d73-b338-0194580d7349', 'cache-control': 'no-cache, private', 'content-type': 'application/json', 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload', 'x-kubernetes-pf-flowschema-uid': 'da8d693d-c54c-4612-996a-dfb7610b4b9d', 'x-kubernetes-pf-prioritylevel-uid': '1269dbce-9b7b-4093-a073-ea029f2d074b', 'date': 'Wed, 10 May 2023 22:36:43 GMT', 'content-length': '508', 'status': '422'}, content=b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Service \\"kube-dns\\" is invalid: spec.clusterIPs: Invalid value: []string{\\"123.123.0.2\\"}: failed to allocate IP 123.123.0.2: etcdserver: leader changed","reason":"Invalid","details":{"name":"kube-dns","kind":"Service","causes":[{"reason":"FieldValueInvalid","message":"Invalid value: []string{\\"123.123.0.2\\"}: failed to allocate IP 123.123.0.2: etcdserver: leader changed","field":"spec.clusterIPs"}]},"code":422}`
> 




### What did you expect to happen?

apiserver change return code from 422 to 500, client can try again.

https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/core/service/storage/alloc.go#L437-L440
```
if err != nil {
    el := field.ErrorList{field.Invalid(field.NewPath("spec", "clusterIPs"), service.Spec.ClusterIPs, fmt.Sprintf("failed to allocate IP %v: %v", ip, err))}
    return allocated, errors.NewInvalid(api.Kind("Service"), service.Name, el)
}
```
code from here should be modified like this.
```
return allocated, errors.NewInternalError(fmt.Errorf("failed to allocate IP %v: %v", ip, err))
```



### How can we reproduce it (as minimally and precisely as possible)?

create a service with specified cluster ip  twice, you will see 422 retrun code.

### Anything else we need to know?

_No response_

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"archive", BuildDate:"2022-04-06T14:06:40Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.3", GitCommit:"c92036820499fedefec0f847e2054d824aea6cd1", GitTreeState:"archive", BuildDate:"2023-06-28T01:35:24Z", GoVersion:"go1.16.9", Compiler:"gc", Platform:"linux/amd64"}
```
</details>


### Cloud provider

<details>
.
</details>


### OS version

<details>

```console
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

</details>


### Install tools

<details>

</details>


### Container runtime (CRI) and version (if applicable)

<details>

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

<details>

</details>