Skip to content

Commit

Permalink
dial: grpc naming is not compatible with windows unix socket
Browse files Browse the repository at this point in the history
  • Loading branch information
tam7t committed Mar 25, 2021
1 parent 51ad99d commit 52926a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions pkg/secrets-store/provider_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"net"
"os"
"regexp"
"sync"
Expand Down Expand Up @@ -109,10 +110,12 @@ func (p *PluginClientBuilder) Get(ctx context.Context, provider string) (v1alpha
return nil, fmt.Errorf("%w: provider %q", ErrProviderNotFound, provider)
}

conn, err := grpc.DialContext(
ctx,
fmt.Sprintf("unix://%s/%s.sock", p.socketPath, provider),
conn, err := grpc.Dial(
fmt.Sprintf("%s/%s.sock", p.socketPath, provider),
grpc.WithInsecure(), // the interface is only secured through filesystem ACLs
grpc.WithContextDialer(func(ctx context.Context, target string) (net.Conn, error) {
return (&net.Dialer{}).DialContext(ctx, "unix", target)
}),
grpc.WithDefaultServiceConfig(ServiceConfig),
)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion test/bats/azure.bats
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ setup() {
}

@test "CSI inline volume test with pod portability - read azure kv secret from pod" {
wait_for_process $WAIT_TIME $SLEEP_TIME "kubectl exec nginx-secrets-store-inline-crd -- $EXEC_COMMAND /mnt/secrets-store/$SECRET_NAME | grep '${SECRET_VALUE}'"

result=$(kubectl exec nginx-secrets-store-inline-crd -- $EXEC_COMMAND /mnt/secrets-store/$SECRET_NAME)
[[ "${result//$'\r'}" == "${SECRET_VALUE}" ]]
}
Expand Down Expand Up @@ -127,7 +129,7 @@ setup() {
result=$(kubectl get secret foosecret -o jsonpath="{.data.username}" | base64 -d)
[[ "${result//$'\r'}" == "${SECRET_VALUE}" ]]

result=$(kubectl exec $POD printenv | grep SECRET_USERNAME) | awk -F"=" '{ print $2}'
result=$(kubectl exec $POD -- printenv | grep SECRET_USERNAME) | awk -F"=" '{ print $2}'
[[ "${result//$'\r'}" == "${SECRET_VALUE}" ]]

result=$(kubectl get secret foosecret -o jsonpath="{.metadata.labels.environment}")
Expand Down

0 comments on commit 52926a7

Please sign in to comment.