From 45f47e99e3ddc7f8f1cabcd8e836932762d44715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donatas=20Lu=C4=8Di=C5=ABnas?= <40665302+toughlex-donatas@users.noreply.github.com> Date: Fri, 31 Jul 2026 23:47:09 +0300 Subject: [PATCH] Update plugin.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Donatas Lučiūnas --- manager/csi/plugin.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/manager/csi/plugin.go b/manager/csi/plugin.go index 0aacdb33cd..3afa735d01 100644 --- a/manager/csi/plugin.go +++ b/manager/csi/plugin.go @@ -208,6 +208,11 @@ func (p *plugin) DeleteVolume(ctx context.Context, v *api.Volume) error { // the Node with the given swarmkit ID. It returns a map, which is the // PublishContext for this Volume on this Node. func (p *plugin) PublishVolume(ctx context.Context, v *api.Volume, nodeID string) (map[string]string, error) { + c, err := p.Client(ctx) + if err != nil { + return nil, err + } + if !p.publisher { return nil, nil } @@ -218,10 +223,6 @@ func (p *plugin) PublishVolume(ctx context.Context, v *api.Volume, nodeID string } req := p.makeControllerPublishVolumeRequest(v, nodeID) - c, err := p.Client(ctx) - if err != nil { - return nil, err - } resp, err := c.ControllerPublishVolume(ctx, req) if err != nil { @@ -234,15 +235,16 @@ func (p *plugin) PublishVolume(ctx context.Context, v *api.Volume, nodeID string // Volume from the Node with the given swarmkit ID. It returns an error if the // unpublish does not succeed func (p *plugin) UnpublishVolume(ctx context.Context, v *api.Volume, nodeID string) error { + c, err := p.Client(ctx) + if err != nil { + return err + } + if !p.publisher { return nil } req := p.makeControllerUnpublishVolumeRequest(v, nodeID) - c, err := p.Client(ctx) - if err != nil { - return err - } // response of the RPC intentionally left blank _, err = c.ControllerUnpublishVolume(ctx, req)