javascript icon indicating copy to clipboard operation
javascript copied to clipboard

V1ServicePort.targetPort type changed from any to object in 0.10.3

Open zen0wu opened this issue 5 years ago • 11 comments

An issue I noticed while upgrading.

It used to be any, which works fine. Now it's object, where giving a number would cause a type error.

https://github.com/kubernetes-client/javascript/blob/master/src/gen/model/v1ServicePort.ts#L37

zen0wu avatar Sep 27 '19 04:09 zen0wu

Thanks for pointing this out. I'm not sure where that came from... I will dig in and see what we need to do to fix it.

Note that you can always pass the number as a string (e.g. "123") the code will do the right thing.

brendandburns avatar Sep 27 '19 17:09 brendandburns

Thanks for responding. Passing as string doesn't pass the type check too, string doesn't conform to object. Probably need to use any.

zen0wu avatar Oct 03 '19 05:10 zen0wu

I found a similar issue with ExtensionsV1beta1IngressBackend. In that type definition, servicePort is listed as object but it should really be number | string. You can see where the confusion may be coming from if you look at the swagger.json code found here:

...
    "io.k8s.api.networking.v1beta1.IngressBackend": {
      "description": "IngressBackend describes all endpoints for a given service and port.",
      "properties": {
        "serviceName": {
          "description": "Specifies the name of the referenced service.",
          "type": "string"
        },
        "servicePort": {
          "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString",
          "description": "Specifies the port of the referenced service."
        }
      },
      "required": [
        "serviceName",
        "servicePort"
      ],
      "type": "object"
    },
...

Specifically, note the "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString",. I suspect that what ever automatic process is used to generate the TypeScript definitions, it gets confused by the $ref here and doesn't translate it into the correct type.

xogeny avatar Oct 25 '19 00:10 xogeny

This is preventing me from being able to upgrade to 0.11.0 as well. Are there any updates as to when this will be resolved?

cwardcode avatar Nov 20 '19 20:11 cwardcode

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Feb 18 '20 20:02 fejta-bot

/lifecycle frozen

brendandburns avatar Feb 24 '20 02:02 brendandburns

This issue is essentially making the node client unusable, cannot set an ingress because servicePort is incorrectly typed as object, cannot use a clusterIP because targetPort is incorrectly typed as object. Is there any update on this?🙏

FreakyTurtle avatar Apr 30 '20 15:04 FreakyTurtle

I am seeing the same problem with V1RollingUpdateDaemonSet.maxUnavailable Neither string nor number are assignable to object.

https://github.com/kubernetes-client/javascript/blob/932c2fbc34db954c6ed397b3cd9ead08b2ff1d10/src/gen/model/v1RollingUpdateDaemonSet.ts#L22

nicholascapo avatar Jul 14 '20 22:07 nicholascapo

For any others reading this, this is how I hacked my way around this issue:

port.targetPort = (8000 as unknown) as object;

ccravens avatar Aug 27 '20 19:08 ccravens

For any others reading this, this is how I hacked my way around this issue:

port.targetPort = (8000 as unknown) as object;

You are a real herooo 👍

polaroi8d avatar Jan 27 '21 20:01 polaroi8d

@brendandburns I noticed this issue linked in my teams code. I think it should be resolved now that https://github.com/kubernetes-client/javascript/issues/666 is merged

alex-bezek avatar Nov 20 '21 01:11 alex-bezek