From 7c28215c0564487da2b3787096fbd3cbb5462c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Wanzenb=C3=B6ck?= Date: Fri, 29 Mar 2024 11:27:49 +0100 Subject: [PATCH] delay deletion of volume definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We delete the volume definition in order to have resource definitions without resources. This is useful when we want to keep snapshots without having the associated resources around. During the volume deletion, we first delete the volume definition. This may be causing a bug in DRBD 9.2, so we delay the deletion until after all resources are gone, at which point DRBD has fully shut down the resource. Signed-off-by: Moritz Wanzenböck --- pkg/client/linstor.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/client/linstor.go b/pkg/client/linstor.go index 4653b98..dfb4862 100644 --- a/pkg/client/linstor.go +++ b/pkg/client/linstor.go @@ -372,13 +372,6 @@ func (s *Linstor) Delete(ctx context.Context, volId string) error { "volume": volId, }).Info("deleting volume") - // Delete the volume definition. This marks a resources as being in the process of deletion. - err := s.client.ResourceDefinitions.DeleteVolumeDefinition(ctx, volId, 0) - if nil404(err) != nil { - // We continue with the cleanup on 404, maybe the previous cleanup was interrupted - return err - } - resources, err := s.client.Resources.GetAll(ctx, volId) if err != nil { return nil404(err) @@ -398,6 +391,13 @@ func (s *Linstor) Delete(ctx context.Context, volId string) error { } } + // Delete the volume definition. This indicates the normal deletion is complete. + err = s.client.ResourceDefinitions.DeleteVolumeDefinition(ctx, volId, 0) + if nil404(err) != nil { + // We continue with the cleanup on 404, maybe the previous cleanup was interrupted + return err + } + err = s.deleteResourceDefinitionAndGroupIfUnused(ctx, volId) if err != nil { return err