Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-38709

Hypershift generated "kubernetes-default-proxy" causes "missing port in address" if hostedCluster CR proxy does not contain a port

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 4.15.z, 4.16.z
    • HyperShift
    • Important
    • None
    • Hypershift Sprint 258, Hypershift Sprint 259, Hypershift Sprint 260
    • 3
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      When a user is trying to deploy a Hosted Cluster using Hypershift, If in the hostedCluster CR under Spec.Configuration.Proxy.HTTPSProxy there is defined a proxy URL missing the port (because uses the default port) this is gonna be passed with this code] inside the "kube-apiserver-proxy" yaml manifest under the spec.containers.command like below:

      $ oc get pod n kube-system kube-apiserver-proxy-xxxxx -o yaml| yq '.spec.containers[].command' [ "control-plane-operator", "kubernetes-default-proxy", "listen-addr=172.20.0.1:6443", "proxy-addr=example.proxy.com", "-apiserver-addr=<apiserver-IP>:<port>" ]

      Then this code will parse these values. Here]

      This command have these flags that will be used for the container to do the API calls.
       
      The net.Dial function that is used from the golang net package expects a host/ip:port. Check the docs here: https://pkg.go.dev/net#Dial
       

      For TCP and UDP networks, the address has the form "host:port". The host must be a literal IP address, or a host name that can be resolved to IP addresses. The port must be a literal port number or a service name.

      So the pod will end up having this issue:

      2024-08-19T06:55:44.831593820Z {"level":"error","ts":"2024-08-19T06:55:44Z","logger":"kubernetes-default-proxy","msg":"failed diaing backend","proxyAddr":"example.proxy.com","error":"dial tcp: address example.proxy.com: missing port in address","stacktrace":"github.com/openshift/hypershift/kubernetes-default-proxy.(*server).run.func1\n\t/hypershift/kubernetes-default-proxy/kubernetes_default_proxy.go:89"}

      Some ideas on how to solve his are below:

      • Validate the hostedCluster CR
      • Add logic to append the default port if missing
      • Something else?

      How reproducible:

      Try to deploy a Hosted Cluster using Hypershift operator using a proxy URL without a port (e.g <example.proxy.com>:<port>) in the hostedCluster CR under "Spec.Configuration.Proxy.HTTPSProxy". This will result to the below error in the kube-apiserver-proxy container: "missing port in address"

      Actual results:

      The kube-apiserver-proxy container returns "missing port in address"

      Expected results:

      The kube-apiserver-proxy container to don't return "missing port in address"

      Additional info:

      This can be workarounded by adding a ":" and a port number after the proxy IP/URL in the hostedCluster."Spec.Configuration.Proxy.HTTPSProxy". 

              rh-ee-mraee Mulham Raee
              rhn-support-nstamate Nikolaos Stamatelopoulos
              Jie Zhao Jie Zhao
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: