Skip to content

Commit f1a5b8e

Browse files
committed
fix: persist pv on reboot
CSI don't detach pv on node reboot. csiattachement still exists even if pv have been removed. Persist on reboot permit to have same behavior as all other clouds.
1 parent b4710c9 commit f1a5b8e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

internal/driver/controllerserver_helper.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/linode/linodego"
1313
"google.golang.org/grpc/codes"
1414
"google.golang.org/grpc/status"
15+
"k8s.io/utils/ptr"
1516

1617
linodevolumes "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-volumes"
1718
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
@@ -783,12 +784,11 @@ func (cs *ControllerServer) attachVolume(ctx context.Context, volumeID, linodeID
783784
defer span.End()
784785
}
785786

786-
persist := false
787-
_, err := cs.client.AttachVolume(ctx, volumeID, &linodego.VolumeAttachOptions{
787+
// Attempt to attach the volume to the Linode instance.
788+
if _, err := cs.client.AttachVolume(ctx, volumeID, &linodego.VolumeAttachOptions{
788789
LinodeID: linodeID,
789-
PersistAcrossBoots: &persist,
790-
})
791-
if err != nil {
790+
PersistAcrossBoots: ptr.To(true),
791+
}); err != nil {
792792
code := codes.Internal // Default error code is Internal.
793793
// Check if the error indicates that the volume is already attached.
794794
var apiErr *linodego.Error

0 commit comments

Comments
 (0)