Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes around attaching volumes with unusual resources #243

Merged
merged 3 commits into from
Jan 25, 2024
Merged
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Default access policy for resources without replication layer is now "local only".

### Fixed

- Do not try to create diskless resource if there is no compatible diskless layer (DRBD or NVMe) available.
- Do not allow attaching a volume that has no existing replica.

## [1.3.0] - 2023-11-15

### Added
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/pborman/uuid v1.2.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/sys v0.16.0
golang.org/x/time v0.5.0
google.golang.org/grpc v1.60.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand Down
10 changes: 9 additions & 1 deletion pkg/client/linstor.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,14 @@ func (s *Linstor) Attach(ctx context.Context, volId, node string, rwxBlock bool)
}).Info("attaching volume")

ress, err := s.client.Resources.GetAll(ctx, volId)
if nil404(err) != nil {
if err != nil {
return err
}

if len(ress) == 0 {
return fmt.Errorf("failed to attach resource with no deployed replica")
}

var existingRes *lapi.Resource

disklessFlag := ""
Expand Down Expand Up @@ -517,6 +521,10 @@ func (s *Linstor) Attach(ctx context.Context, volId, node string, rwxBlock bool)
// are already covered in the allowed topology bits.
s.log.WithError(err).Info("fall back to manual diskless creation after make-available refused")

if disklessFlag == "" {
return fmt.Errorf("resource does not support diskless attachment")
}

rCreate := lapi.ResourceCreate{Resource: lapi.Resource{
Name: volId,
NodeName: node,
Expand Down
22 changes: 15 additions & 7 deletions pkg/volume/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/LINBIT/golinstor/devicelayerkind"
"github.com/pborman/uuid"
log "github.com/sirupsen/logrus"
"golang.org/x/exp/slices"

"github.com/piraeusdatastore/linstor-csi/pkg/linstor"
"github.com/piraeusdatastore/linstor-csi/pkg/topology"
Expand Down Expand Up @@ -108,13 +109,12 @@ var DefaultRemoteAccessPolicy = RemoteAccessPolicyAnywhere
func NewParameters(params map[string]string, topologyPrefix string) (Parameters, error) {
// set zero values
p := Parameters{
LayerList: []devicelayerkind.DeviceLayerKind{devicelayerkind.Drbd, devicelayerkind.Storage},
PlacementCount: 1,
DisklessStoragePool: DefaultDisklessStoragePoolName,
Encryption: false,
PlacementPolicy: topology.AutoPlaceTopology,
AllowRemoteVolumeAccess: DefaultRemoteAccessPolicy,
Properties: make(map[string]string),
LayerList: []devicelayerkind.DeviceLayerKind{devicelayerkind.Drbd, devicelayerkind.Storage},
PlacementCount: 1,
DisklessStoragePool: DefaultDisklessStoragePoolName,
Encryption: false,
PlacementPolicy: topology.AutoPlaceTopology,
Properties: make(map[string]string),
}

for k, v := range params {
Expand Down Expand Up @@ -260,6 +260,14 @@ func NewParameters(params map[string]string, topologyPrefix string) (Parameters,
p.ResourceGroup = "sc-" + uuid.NewSHA1(namespace, encoded).String()
}

if p.AllowRemoteVolumeAccess == nil {
if slices.Contains(p.LayerList, devicelayerkind.Drbd) || slices.Contains(p.LayerList, devicelayerkind.Nvme) {
p.AllowRemoteVolumeAccess = DefaultRemoteAccessPolicy
} else {
p.AllowRemoteVolumeAccess = RemoteAccessPolicyLocalOnly
}
}

// User has manually configured deployments, ignore autoplacing options.
if len(p.NodeList)+len(p.ClientList) != 0 {
p.PlacementCount = 0
Expand Down
Loading