From 44549c00fda1b7d6b414ea7841729b3bb91ced98 Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Mon, 23 Jun 2025 22:05:05 +0200 Subject: [PATCH] feat: Label new volumes as managed by uncloud (#79) --- internal/machine/docker/server.go | 6 ++++++ test/e2e/compose_deploy_test.go | 3 +++ 2 files changed, 9 insertions(+) diff --git a/internal/machine/docker/server.go b/internal/machine/docker/server.go index 10d2fbba..a0b55f5b 100644 --- a/internal/machine/docker/server.go +++ b/internal/machine/docker/server.go @@ -345,6 +345,12 @@ func (s *Server) CreateVolume(ctx context.Context, req *pb.CreateVolumeRequest) return nil, status.Errorf(codes.InvalidArgument, "unmarshal options: %v", err) } + // Always add the managed label to the volume to indicate that it is managed by Uncloud. + if opts.Labels == nil { + opts.Labels = make(map[string]string) + } + opts.Labels[api.LabelManaged] = "" + vol, err := s.client.VolumeCreate(ctx, opts) if err != nil { return nil, status.Error(codes.Internal, err.Error()) diff --git a/test/e2e/compose_deploy_test.go b/test/e2e/compose_deploy_test.go index ac203c83..07812dd2 100644 --- a/test/e2e/compose_deploy_test.go +++ b/test/e2e/compose_deploy_test.go @@ -121,6 +121,9 @@ func TestComposeDeployment(t *testing.T) { }) require.NoError(t, err) assert.Len(t, volumes, 2, "Expected 2 volumes to be created") + // Check that the volumes have the correct labels + assert.Equal(t, map[string]string{"uncloud.managed": ""}, volumes[0].Volume.Labels) + assert.Equal(t, map[string]string{"uncloud.managed": ""}, volumes[1].Volume.Labels) data1Volume, data2Volume := volumes[0], volumes[1] if volumes[0].Volume.Name == "test-compose-volumes-data2" {