Skip to content

Commit

Permalink
Fix handling of parseIP error
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean-Coakley committed Aug 10, 2020
1 parent 50a8c98 commit c3de6d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/minikube/driver/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package driver

import (
"fmt"
"net"

"k8s.io/minikube/pkg/drivers/kic/oci"
Expand All @@ -30,6 +31,9 @@ func ControlPlaneEndpoint(cc *config.ClusterConfig, cp *config.Node, driverName
port, err := oci.ForwardedPort(cc.Driver, cc.Name, cp.Port)
hostname := oci.DefaultBindIPV4
ip := net.ParseIP(hostname)
if ip == nil {
return hostname, ip, port, fmt.Errorf("failed to parse ip for %q", hostname)
}

// https://github.com/kubernetes/minikube/issues/3878
if cc.KubernetesConfig.APIServerName != constants.APIServerName {
Expand All @@ -43,5 +47,9 @@ func ControlPlaneEndpoint(cc *config.ClusterConfig, cp *config.Node, driverName
if cc.KubernetesConfig.APIServerName != constants.APIServerName {
hostname = cc.KubernetesConfig.APIServerName
}
return hostname, net.ParseIP(cp.IP), cp.Port, nil
ip := net.ParseIP(cp.IP)
if ip == nil {
return hostname, ip, cp.Port, fmt.Errorf("failed to parse ip for %q", cp.IP)
}
return hostname, ip, cp.Port, nil
}

0 comments on commit c3de6d6

Please sign in to comment.