Skip to content

Commit

Permalink
simplify volume dispense: compatible computing
Browse files Browse the repository at this point in the history
  • Loading branch information
jschwinger233 committed Nov 10, 2020
1 parent ab7e2a8 commit d2b9d33
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 311 deletions.
2 changes: 1 addition & 1 deletion cluster/calcium/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Calcium) doCreateWorkloads(ctx context.Context, opts *types.DeployOptio
for nodename, rollbackIndices := range rollbackMap {
if e := c.withNodeLocked(ctx, nodename, func(node *types.Node) error {
for _, plan := range plans {
plan.RollbackChangesOnNode(node, rollbackIndices...)
plan.RollbackChangesOnNode(node, rollbackIndices...) // nolint:scopelint
}
return errors.WithStack(c.store.UpdateNodes(ctx, node))
}); e != nil {
Expand Down
21 changes: 14 additions & 7 deletions cluster/calcium/realloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *Calcium) doReallocOnNode(ctx context.Context, nodename string, containe
if err != nil {
return errors.WithStack(err)
}
if total != 1 {
if total < 1 {
return errors.WithStack(types.ErrInsufficientRes)
}

Expand Down Expand Up @@ -80,12 +80,9 @@ func (c *Calcium) doReallocOnNode(ctx context.Context, nodename string, containe
func (c *Calcium) doReallocContainersOnInstance(ctx context.Context, node *types.Node, plans []resourcetypes.ResourcePlans, container *types.Container) (err error) {
r := &types.ResourceMeta{}
for _, plan := range plans {
// TODO@zc: single existing instance
// TODO@zc: no HardVolumeBindings
if r, err = plan.Dispense(resourcetypes.DispenseOptions{
Node: node,
Index: 1,
ExistingInstances: []*types.Container{container},
Node: node,
ExistingInstance: container,
}, r); err != nil {
return
}
Expand Down Expand Up @@ -131,7 +128,17 @@ func (c *Calcium) doReallocContainersOnInstance(ctx context.Context, node *types
if failureByCond {
return nil
}
return errors.WithStack(c.store.UpdateContainer(ctx, &originalContainer))
r := &enginetypes.VirtualizationResource{
CPU: originalContainer.CPU,
Quota: originalContainer.CPUQuotaLimit,
NUMANode: originalContainer.NUMANode,
Memory: originalContainer.MemoryLimit,
Volumes: originalContainer.VolumeLimit.ToStringSlice(false, false),
VolumePlan: originalContainer.VolumePlanLimit.ToLiteral(),
VolumeChanged: r.VolumeChanged,
Storage: originalContainer.StorageLimit,
}
return errors.WithStack(node.Engine.VirtualizationUpdateResource(ctx, container.ID, r))
},

c.config.GlobalTimeout,
Expand Down
Loading

0 comments on commit d2b9d33

Please sign in to comment.