Skip to content

Commit

Permalink
realloc: Send success back when update resource finish. (#187)
Browse files Browse the repository at this point in the history
* realloc: Send success back when update resource finish.

* realloc: Fix test that had useless store mocks.

* VERSION: 20.03.03 -> 20.03.04
  • Loading branch information
atlas-comstock authored and CMGS committed Mar 25, 2020
1 parent 9de65e9 commit a9c305f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.03.03
20.03.04
10 changes: 4 additions & 6 deletions cluster/calcium/realloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ func (c *Calcium) doReallocContainer(
}
return nil
}); err != nil {
log.Errorf("[doReallocContainer] Realloc container %v failed: %v", containers, err)
for _, container := range containers {
log.Errorf("[doReallocContainer] Realloc container %v failed: %v", container.ID, err)
ch <- &types.ReallocResourceMessage{
ContainerID: container.ID,
Error: err,
Expand Down Expand Up @@ -243,11 +243,9 @@ func (c *Calcium) updateContainersResources(ctx context.Context, ch chan *types.
newResource.SoftLimit = container.SoftLimit
newResource.Volumes = hardVbsForContainer[container.ID].ToStringSlice(false, false)

if err := c.updateResource(ctx, node, container, newResource); err != nil {
ch <- &types.ReallocResourceMessage{
ContainerID: container.ID,
Error: err,
}
ch <- &types.ReallocResourceMessage{
ContainerID: container.ID,
Error: c.updateResource(ctx, node, container, newResource),
}
}
return nil
Expand Down
5 changes: 1 addition & 4 deletions cluster/calcium/realloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ func TestRealloc(t *testing.T) {
engine.On("VirtualizationUpdateResource", mock.Anything, mock.Anything, mock.Anything).Return(types.ErrBadContainerID).Twice()
// update node failed
store.On("UpdateNode", mock.Anything, mock.Anything).Return(types.ErrNoETCD).Once()
// update container success
store.On("UpdateContainer", mock.Anything, mock.Anything).Return(nil).Once()
// reset node
node1 = &types.Node{
Name: "node1",
Expand All @@ -163,7 +161,6 @@ func TestRealloc(t *testing.T) {
for r := range ch {
assert.Error(t, r.Error)
}
store.On("UpdateContainer", mock.Anything, mock.Anything).Return(nil)
// failed by volume binding incompatible
nodeVolumePlans = map[string][]types.VolumePlan{
node1.Name: {
Expand Down Expand Up @@ -251,10 +248,10 @@ func TestRealloc(t *testing.T) {
simpleMockScheduler.On("SelectVolumeNodes", mock.Anything, types.MustToVolumeBindings([]string{"AUTO:/data0:rw:50", "AUTO:/data1:rw:200"})).Return(nil, nodeVolumePlans, 2, nil)
store.On("GetNode", mock.Anything, "node2").Return(node2, nil)
store.On("GetContainers", mock.Anything, []string{"c3", "c4"}).Return([]*types.Container{c3, c4}, nil)
store.On("UpdateContainer", mock.Anything, mock.Anything).Return(types.ErrBadContainerID).Twice()
ch, err = c.ReallocResource(ctx, []string{"c3", "c4"}, 0.1, 2*int64(units.MiB), types.MustToVolumeBindings([]string{"AUTO:/data0:rw:-50"}))
assert.NoError(t, err)
for r := range ch {
// TODO: Handle Received unexpected error: container ID must be length of 64 in test
assert.Error(t, r.Error)
}
assert.Equal(t, node2.CPU["3"], int64(0))
Expand Down
2 changes: 1 addition & 1 deletion make-release
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cp eru-core.service $SERVICE

echo $VERSION rpm build begin

fpm -f -s dir -t rpm -n eru-core --epoch 0 -v $VERSION --iteration ${ITRATION_NUMBER}.el7 -C $RPMROOT -p $PWD --verbose --no-rpm-auto-add-directories --category 'Development/App' --description 'eru core' --after-install $after_install_script --url 'https://github.com/projecteru2/core' --license 'MIT' --no-rpm-sign usr etc
fpm -f -s dir -t rpm -n eru-core --epoch 0 -v $VERSION --iteration ${ITRATION_NUMBER}.el7 -C $RPMROOT -p $PWD --verbose --no-rpm-auto-add-directories --category 'Development/App' --description 'eru core' --after-install $after_install_script --url 'https://github.com/projecteru2/core' --license 'MIT' -a all --no-rpm-sign usr etc

BIN="$DEBROOT/usr/bin"
CONF="$DEBROOT/etc/eru"
Expand Down

0 comments on commit a9c305f

Please sign in to comment.