Skip to content

Commit

Permalink
also remove node status when removing node (#643)
Browse files Browse the repository at this point in the history
* also remove node status when removing node

* fix UT issue
  • Loading branch information
yuyang0 committed Aug 20, 2024
1 parent c76e663 commit baae21a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cluster/calcium/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ func (c *Calcium) RemoveNode(ctx context.Context, nodename string) error {
return utils.Txn(ctx,
// if: remove node metadata
func(ctx context.Context) error {
return c.store.RemoveNode(ctx, node)
if err := c.store.RemoveNode(ctx, node); err != nil {
return err
}
// remove node status, we don't care the result
_ = c.store.SetNodeStatus(ctx, node, -1)
return nil
},
// then: remove node resource metadata
func(ctx context.Context) error {
Expand Down
1 change: 1 addition & 0 deletions cluster/calcium/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func TestRemoveNode(t *testing.T) {

// success
store.On("RemoveNode", mock.Anything, mock.Anything).Return(nil)
store.On("SetNodeStatus", mock.Anything, mock.Anything, int64(-1)).Return(nil)
rmgr := c.rmgr.(*resourcemocks.Manager)
rmgr.On("RemoveNode", mock.Anything, mock.Anything).Return(nil)
assert.NoError(t, c.RemoveNode(ctx, name))
Expand Down

0 comments on commit baae21a

Please sign in to comment.