Skip to content

Commit d2b9d33

Browse files
committed
simplify volume dispense: compatible computing
1 parent ab7e2a8 commit d2b9d33

File tree

6 files changed

+105
-311
lines changed

6 files changed

+105
-311
lines changed

cluster/calcium/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (c *Calcium) doCreateWorkloads(ctx context.Context, opts *types.DeployOptio
101101
for nodename, rollbackIndices := range rollbackMap {
102102
if e := c.withNodeLocked(ctx, nodename, func(node *types.Node) error {
103103
for _, plan := range plans {
104-
plan.RollbackChangesOnNode(node, rollbackIndices...)
104+
plan.RollbackChangesOnNode(node, rollbackIndices...) // nolint:scopelint
105105
}
106106
return errors.WithStack(c.store.UpdateNodes(ctx, node))
107107
}); e != nil {

cluster/calcium/realloc.go

+14-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (c *Calcium) doReallocOnNode(ctx context.Context, nodename string, containe
4141
if err != nil {
4242
return errors.WithStack(err)
4343
}
44-
if total != 1 {
44+
if total < 1 {
4545
return errors.WithStack(types.ErrInsufficientRes)
4646
}
4747

@@ -80,12 +80,9 @@ func (c *Calcium) doReallocOnNode(ctx context.Context, nodename string, containe
8080
func (c *Calcium) doReallocContainersOnInstance(ctx context.Context, node *types.Node, plans []resourcetypes.ResourcePlans, container *types.Container) (err error) {
8181
r := &types.ResourceMeta{}
8282
for _, plan := range plans {
83-
// TODO@zc: single existing instance
84-
// TODO@zc: no HardVolumeBindings
8583
if r, err = plan.Dispense(resourcetypes.DispenseOptions{
86-
Node: node,
87-
Index: 1,
88-
ExistingInstances: []*types.Container{container},
84+
Node: node,
85+
ExistingInstance: container,
8986
}, r); err != nil {
9087
return
9188
}
@@ -131,7 +128,17 @@ func (c *Calcium) doReallocContainersOnInstance(ctx context.Context, node *types
131128
if failureByCond {
132129
return nil
133130
}
134-
return errors.WithStack(c.store.UpdateContainer(ctx, &originalContainer))
131+
r := &enginetypes.VirtualizationResource{
132+
CPU: originalContainer.CPU,
133+
Quota: originalContainer.CPUQuotaLimit,
134+
NUMANode: originalContainer.NUMANode,
135+
Memory: originalContainer.MemoryLimit,
136+
Volumes: originalContainer.VolumeLimit.ToStringSlice(false, false),
137+
VolumePlan: originalContainer.VolumePlanLimit.ToLiteral(),
138+
VolumeChanged: r.VolumeChanged,
139+
Storage: originalContainer.StorageLimit,
140+
}
141+
return errors.WithStack(node.Engine.VirtualizationUpdateResource(ctx, container.ID, r))
135142
},
136143

137144
c.config.GlobalTimeout,

0 commit comments

Comments
 (0)