Skip to content

Commit 44549c0

Browse files
authored
feat: Label new volumes as managed by uncloud (#79)
1 parent 26f34df commit 44549c0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

internal/machine/docker/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ func (s *Server) CreateVolume(ctx context.Context, req *pb.CreateVolumeRequest)
345345
return nil, status.Errorf(codes.InvalidArgument, "unmarshal options: %v", err)
346346
}
347347

348+
// Always add the managed label to the volume to indicate that it is managed by Uncloud.
349+
if opts.Labels == nil {
350+
opts.Labels = make(map[string]string)
351+
}
352+
opts.Labels[api.LabelManaged] = ""
353+
348354
vol, err := s.client.VolumeCreate(ctx, opts)
349355
if err != nil {
350356
return nil, status.Error(codes.Internal, err.Error())

test/e2e/compose_deploy_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ func TestComposeDeployment(t *testing.T) {
121121
})
122122
require.NoError(t, err)
123123
assert.Len(t, volumes, 2, "Expected 2 volumes to be created")
124+
// Check that the volumes have the correct labels
125+
assert.Equal(t, map[string]string{"uncloud.managed": ""}, volumes[0].Volume.Labels)
126+
assert.Equal(t, map[string]string{"uncloud.managed": ""}, volumes[1].Volume.Labels)
124127

125128
data1Volume, data2Volume := volumes[0], volumes[1]
126129
if volumes[0].Volume.Name == "test-compose-volumes-data2" {

0 commit comments

Comments
 (0)