Skip to content

Commit a5c16c0

Browse files
committed
store create time in workload meta
1 parent 8d2cbf3 commit a5c16c0

12 files changed

+316
-301
lines changed

cluster/calcium/calcium_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func NewTestCluster() *Calcium {
3838
Git: types.GitConfig{
3939
CloneTimeout: 300 * time.Second,
4040
},
41+
Scheduler: types.SchedConfig{
42+
MaxShare: -1,
43+
ShareBase: 100,
44+
},
4145
}
4246
c.store = &storemocks.Store{}
4347
c.scheduler = &schedulermocks.Scheduler{}

cluster/calcium/create.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"sync"
7+
"time"
78

89
"github.com/pkg/errors"
910
"github.com/projecteru2/core/cluster"
@@ -229,6 +230,7 @@ func (c *Calcium) doDeployOneWorkload(
229230
Image: opts.Image,
230231
Env: opts.Env,
231232
User: opts.User,
233+
CreateTime: time.Now().Unix(),
232234
}
233235
return utils.Txn(
234236
ctx,

cluster/calcium/realloc_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ func TestRealloc(t *testing.T) {
269269

270270
func TestReallocBindCpu(t *testing.T) {
271271
c := NewTestCluster()
272-
c.config.Scheduler.ShareBase = 100
273272
ctx := context.Background()
274273
store := &storemocks.Store{}
275274
c.store = store
File renamed without changes.
File renamed without changes.

rpc/gen/core.pb.go

+306-298
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/gen/core.proto

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ message Workload {
183183
string image = 8;
184184
WorkloadStatus status = 9;
185185
Resource resource = 10;
186+
int64 create_time = 11;
186187
}
187188

188189
message WorkloadStatus {

rpc/transform.go

+1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ func toRPCWorkload(_ context.Context, c *types.Workload) (*pb.Workload, error) {
479479
Image: c.Image,
480480
Labels: c.Labels,
481481
Status: toRPCWorkloadStatus(c.StatusMeta),
482+
CreateTime: c.CreateTime,
482483
Resource: &pb.Resource{
483484
CpuQuotaLimit: c.CPUQuotaLimit,
484485
CpuQuotaRequest: c.CPUQuotaRequest,

store/etcdv3/container.go store/etcdv3/workload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (m *Mercury) ListNodeWorkloads(ctx context.Context, nodename string, labels
158158
for _, ev := range resp.Kvs {
159159
workload := &types.Workload{}
160160
if err := json.Unmarshal(ev.Value, workload); err != nil {
161-
return []*types.Workload{}, err
161+
return nil, err
162162
}
163163
if utils.FilterWorkload(workload.Labels, labels) {
164164
workloads = append(workloads, workload)
File renamed without changes.

types/container.go types/workload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ type Workload struct {
3434
Nodename string `json:"nodename"`
3535
Hook *Hook `json:"hook"`
3636
Privileged bool `json:"privileged"`
37-
SoftLimit bool `json:"softlimit"`
3837
User string `json:"user"`
3938
Env []string `json:"env"`
4039
Image string `json:"image"`
4140
Labels map[string]string `json:"labels"`
41+
CreateTime int64 `json:"create_time"`
4242
StatusMeta *StatusMeta `json:"-"`
4343
Engine engine.API `json:"-"`
4444
}
File renamed without changes.

0 commit comments

Comments
 (0)