Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions agent/csi/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"

"github.com/container-storage-interface/spec/lib/go/csi"
Expand Down Expand Up @@ -108,9 +109,9 @@ func newNodePlugin(name string, p plugin.AddrPlugin, secrets SecretGetter) *node
// client from a grpc client. it exists separately so that testing code can
// substitute in fake clients without a grpc connection
func (np *nodePlugin) connect(ctx context.Context) error {
// even though this is a unix socket, we must set WithInsecure or the
// even though this is a unix socket, we must set insecure.NewCredential or the
// connection will not be allowed.
cc, err := grpc.DialContext(ctx, np.socket, grpc.WithInsecure())
cc, err := grpc.NewClient(np.socket, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions manager/csi/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/status"

"github.com/container-storage-interface/spec/lib/go/csi"
Expand Down Expand Up @@ -93,7 +94,7 @@ func NewPlugin(p mobyplugin.AddrPlugin, provider SecretProvider) Plugin {
// connect is a private method that initializes a gRPC ClientConn and creates
// the IdentityClient and ControllerClient.
func (p *plugin) connect(ctx context.Context) error {
cc, err := grpc.DialContext(ctx, p.socket, grpc.WithInsecure())
cc, err := grpc.NewClient(p.socket, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down Expand Up @@ -231,8 +232,8 @@ func (p *plugin) PublishVolume(ctx context.Context, v *api.Volume, nodeID string
}

// UnpublishVolume calls ControllerUnpublishVolume to unpublish the given
// Volume from the Node with the given swarmkit ID. It returns an error if the
// unpublish does not succeed
// Volume from the Node with the given swarmkit ID. It returns an error if
// unpublish does not succeed.
func (p *plugin) UnpublishVolume(ctx context.Context, v *api.Volume, nodeID string) error {
if !p.publisher {
return nil
Expand Down Expand Up @@ -319,16 +320,15 @@ func (p *plugin) makeControllerPublishVolumeRequest(v *api.Volume, nodeID string
return nil
}

secrets := p.makeSecrets(v)
capability := capability.MakeCapability(v.Spec.AccessMode)
capability.AccessType = &csi.VolumeCapability_Mount{
volumeCapability := capability.MakeCapability(v.Spec.AccessMode)
volumeCapability.AccessType = &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
}
return &csi.ControllerPublishVolumeRequest{
VolumeId: v.VolumeInfo.VolumeID,
NodeId: p.swarmToCSI[nodeID],
Secrets: secrets,
VolumeCapability: capability,
Secrets: p.makeSecrets(v),
VolumeCapability: volumeCapability,
VolumeContext: v.VolumeInfo.VolumeContext,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jobs
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"google.golang.org/grpc/credentials/insecure"

"context"
"net"
Expand Down Expand Up @@ -82,12 +83,13 @@ var _ = Describe("Integration between the controlapi and jobs orchestrator", fun
// cancel after dial has completed is a no-op, but if we don't cancel,
// linters will (probably) complain about a leaked context.
defer cancel()
conn, err = grpc.DialContext(
ctx, "unix:"+tempUnixSocket,
//nolint:staticcheck // NewClient does not support WithBlock.
conn, err = grpc.DialContext(ctx,
"unix:"+tempUnixSocket,
// block on making this connection, to avoid the tests failing for
// funny reasons related to this connection being established async
grpc.WithBlock(),
grpc.WithInsecure(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -101,12 +103,12 @@ var _ = Describe("Integration between the controlapi and jobs orchestrator", fun
})

AfterEach(func() {
conn.Close()
_ = conn.Close()
grpcServer.Stop()
// wait for the server to stop
<-serverDone
s.Close()
os.RemoveAll(tempUnixSocket)
_ = s.Close()
_ = os.RemoveAll(tempUnixSocket)

o.Stop()
<-orchestratorDone
Expand Down