diff --git a/client/go.mod b/client/go.mod index 9d5b3037..11bfa122 100644 --- a/client/go.mod +++ b/client/go.mod @@ -13,7 +13,8 @@ replace ( require ( github.com/adrg/xdg v0.5.0 github.com/blang/semver v3.5.1+incompatible - github.com/cosi-project/runtime v0.6.2 + github.com/cosi-project/runtime v0.6.3 + github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.17.0 github.com/gertd/go-pluralize v0.2.1 github.com/google/uuid v1.6.0 @@ -54,7 +55,6 @@ require ( github.com/containernetworking/cni v1.2.3 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 //indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/dustin/go-humanize v1.0.1 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect diff --git a/client/go.sum b/client/go.sum index a0cb5ec2..02affb80 100644 --- a/client/go.sum +++ b/client/go.sum @@ -25,8 +25,8 @@ github.com/containerd/go-cni v1.1.10 h1:c2U73nld7spSWfiJwSh/8W9DK+/qQwYM2rngIhCy github.com/containerd/go-cni v1.1.10/go.mod h1:/Y/sL8yqYQn1ZG1om1OncJB1W4zN3YmjfP/ShCzG/OY= github.com/containernetworking/cni v1.2.3 h1:hhOcjNVUQTnzdRJ6alC5XF+wd9mfGIUaj8FuJbEslXM= github.com/containernetworking/cni v1.2.3/go.mod h1:DuLgF+aPd3DzcTQTtp/Nvl1Kim23oFKdm2okJzBQA5M= -github.com/cosi-project/runtime v0.6.2 h1:GHp/GoJlqAfmVXq69r7CeSIXj31glMNz8z2RM3ugpRU= -github.com/cosi-project/runtime v0.6.2/go.mod h1:2iQ2Wu57UNm89ZksFLoMLGEZnPzUkk5g64+AlWHopo4= +github.com/cosi-project/runtime v0.6.3 h1:nCmEIY1jypCoraRaNsFvaLHkBI/ALYk/X1CGea7Ie1E= +github.com/cosi-project/runtime v0.6.3/go.mod h1:2iQ2Wu57UNm89ZksFLoMLGEZnPzUkk5g64+AlWHopo4= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/go.mod b/go.mod index 9ba33e23..9d37d1a8 100644 --- a/go.mod +++ b/go.mod @@ -26,8 +26,8 @@ require ( github.com/blang/semver v3.5.1+incompatible github.com/blang/semver/v4 v4.0.0 github.com/containers/image/v5 v5.32.2 - github.com/cosi-project/runtime v0.6.2 - github.com/cosi-project/state-etcd v0.3.1 + github.com/cosi-project/runtime v0.6.3 + github.com/cosi-project/state-etcd v0.3.2 github.com/crewjam/saml v0.4.14 github.com/dustin/go-humanize v1.0.1 github.com/emicklei/dot v1.6.2 diff --git a/go.sum b/go.sum index 7c70b0f0..17b24577 100644 --- a/go.sum +++ b/go.sum @@ -107,10 +107,10 @@ github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cosi-project/runtime v0.6.2 h1:GHp/GoJlqAfmVXq69r7CeSIXj31glMNz8z2RM3ugpRU= -github.com/cosi-project/runtime v0.6.2/go.mod h1:2iQ2Wu57UNm89ZksFLoMLGEZnPzUkk5g64+AlWHopo4= -github.com/cosi-project/state-etcd v0.3.1 h1:Xeg2YW8k4/tHhJao/SenC+eZiJaIkeavXVB8tHEgaIc= -github.com/cosi-project/state-etcd v0.3.1/go.mod h1:DTYhrWuBJHkkl1ke7Q/L1tQEd2N8p6XfZ+8haev3Tco= +github.com/cosi-project/runtime v0.6.3 h1:nCmEIY1jypCoraRaNsFvaLHkBI/ALYk/X1CGea7Ie1E= +github.com/cosi-project/runtime v0.6.3/go.mod h1:2iQ2Wu57UNm89ZksFLoMLGEZnPzUkk5g64+AlWHopo4= +github.com/cosi-project/state-etcd v0.3.2 h1:8Lnj5dPIUzkv5DYFpKvkP+vX5O9M9sWthXQfoKJrF78= +github.com/cosi-project/state-etcd v0.3.2/go.mod h1:wHp8V3OvGRILYvbJEmhMt0AFuByaGNkxXLDc61/+yFM= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/internal/backend/runtime/omni/controllers/omni/machine_set_status_test.go b/internal/backend/runtime/omni/controllers/omni/machine_set_status_test.go index 33a70a3d..742a1709 100644 --- a/internal/backend/runtime/omni/controllers/omni/machine_set_status_test.go +++ b/internal/backend/runtime/omni/controllers/omni/machine_set_status_test.go @@ -939,6 +939,52 @@ func (suite *MachineSetStatusSuite) TestMachineLocks() { }) } +func (suite *MachineSetStatusSuite) TestMachineIsAddedToAnotherMachineSet() { + ctx, cancel := context.WithTimeout(suite.ctx, time.Second*20) + defer cancel() + + clusterName := "cluster-locks" + + machines := []string{ + "node01", + } + + suite.createMachineSet(clusterName, "machine-set-1", machines) + + rtestutils.AssertResources(ctx, suite.T(), suite.state, machines, func(*omni.ClusterMachine, *assert.Assertions) {}) + + _, err := safe.StateUpdateWithConflicts(ctx, suite.state, omni.NewClusterMachine(resources.DefaultNamespace, "node01").Metadata(), func( + res *omni.ClusterMachine, + ) error { + res.Metadata().Finalizers().Add("locked") + + return nil + }, state.WithUpdateOwner(machineset.ControllerName)) + + suite.Require().NoError(err) + + rtestutils.DestroyAll[*omni.MachineSetNode](ctx, suite.T(), suite.state) + + suite.createMachineSet(clusterName, "machine-set-2", machines) + + _, err = safe.StateUpdateWithConflicts(ctx, suite.state, omni.NewClusterMachine(resources.DefaultNamespace, "node01").Metadata(), func( + res *omni.ClusterMachine, + ) error { + res.Metadata().Finalizers().Remove("locked") + + return nil + }, state.WithUpdateOwner(machineset.ControllerName), state.WithExpectedPhaseAny()) + + suite.Require().NoError(err) + + rtestutils.AssertResources(ctx, suite.T(), suite.state, machines, func(cm *omni.ClusterMachine, assert *assert.Assertions) { + machineSetName, ok := cm.Metadata().Labels().Get(omni.LabelMachineSet) + + assert.True(ok) + assert.Equal("machine-set-2", machineSetName) + }) +} + func (suite *MachineSetStatusSuite) assertLabels(res resource.Resource, labels ...string) error { if len(labels)%2 != 0 { return errors.New("the number of label params must be even")