From 9541e91dc2237c90b282bd8414927526aa8ba499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Wanzenb=C3=B6ck?= Date: Wed, 24 Jan 2024 15:49:39 +0100 Subject: [PATCH] do not attach volume with no replicas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Moritz Wanzenböck --- CHANGELOG.md | 3 ++- pkg/client/linstor.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b465d7..89d2241 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Do not try to create diskless resource if there is no compatible diskless layer (DRBD or NVMe) available +- 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 diff --git a/pkg/client/linstor.go b/pkg/client/linstor.go index 1d7daf0..a91929c 100644 --- a/pkg/client/linstor.go +++ b/pkg/client/linstor.go @@ -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 := ""