Skip to content

Commit

Permalink
PWX-32899_pt4: K8s DNS fix (#2412)
Browse files Browse the repository at this point in the history
Signed-off-by: Zoran Rajic <zrajic@purestorage.com>
  • Loading branch information
zoxpx committed Apr 16, 2024
1 parent ea7b5ba commit 1e07b43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion volume/drivers/pwx/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (cpb *ConnectionParamsBuilder) BuildClientsEndpoints() (string, string, err
return "", "", fmt.Errorf("failed to get k8s service specification: %v", err)
}

endpoint = fmt.Sprintf("%s.%s.svc.cluster.local", svc.Name, svc.Namespace)
endpoint = fmt.Sprintf("%s.%s", svc.Name, svc.Namespace)

var restPort int
var restPortSecured int
Expand Down
24 changes: 12 additions & 12 deletions volume/drivers/pwx/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndService_TLS(t *testin
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err, "should build endpoints when service and ns is not defined in env variables: %+v", err)

require.Equal(t, "https://portworx-service.kube-system.svc.cluster.local:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "https://portworx-service.kube-system:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system:9999", sdkEndpoint)
}

func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndService_NO_TLS(t *testing.T) {
Expand All @@ -217,8 +217,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndService_NO_TLS(t *tes
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err)

require.Equal(t, "http://portworx-service.kube-system.svc.cluster.local:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "http://portworx-service.kube-system:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system:9999", sdkEndpoint)
}

func TestPortworx_buildClientsEndpoints_OK_WithNonDefaultNsAndService_NO_TLS(t *testing.T) {
Expand All @@ -233,8 +233,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithNonDefaultNsAndService_NO_TLS(t *
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err, "should build endpoints when service and ns is not defined in env variables: %+v", err)

require.Equal(t, "http://portworx-service.non-default-ns.svc.cluster.local:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.non-default-ns.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "http://portworx-service.non-default-ns:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.non-default-ns:9999", sdkEndpoint)
}

func TestPortworx_buildClientsEndpoints_OK_WithNonDefaultNsAndService_TLS(t *testing.T) {
Expand All @@ -249,8 +249,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithNonDefaultNsAndService_TLS(t *tes
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err, "should build endpoints when service and ns is not defined in env varaibles: %+v", err)

require.Equal(t, "https://portworx-service.non-default-ns.svc.cluster.local:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.non-default-ns.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "https://portworx-service.non-default-ns:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.non-default-ns:9999", sdkEndpoint)
}

func TestPortworx_buildClientsEndpoints_OK_WithStaticEndpointAndPorts_NO_TLS(t *testing.T) {
Expand Down Expand Up @@ -361,8 +361,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndServiceWithEmptyStati
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err, "should build endpoints when service and ns is not defined in env variables: %+v", err)

require.Equal(t, "http://portworx-service.kube-system.svc.cluster.local:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "http://portworx-service.kube-system:9901", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system:9999", sdkEndpoint)
}

func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndServiceWithEmptyStaticRestPort_TLS(t *testing.T) {
Expand All @@ -376,8 +376,8 @@ func TestPortworx_buildClientsEndpoints_OK_WithDefaultNsAndServiceWithEmptyStati
pxMgmtEndpoint, sdkEndpoint, err := paramsBuilder.BuildClientsEndpoints()
require.NoError(t, err, "should build endpoints when service and ns is not defined in env varaibles: %+v", err)

require.Equal(t, "https://portworx-service.kube-system.svc.cluster.local:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system.svc.cluster.local:9999", sdkEndpoint)
require.Equal(t, "https://portworx-service.kube-system:9902", pxMgmtEndpoint)
require.Equal(t, "portworx-service.kube-system:9999", sdkEndpoint)
}

func TestPortworx_dialOptions_Error_WhenSecretDoesNotExist(t *testing.T) {
Expand Down

0 comments on commit 1e07b43

Please sign in to comment.