Skip to content

Commit f566558

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

File tree

10 files changed

+312
-300
lines changed

10 files changed

+312
-300
lines changed

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,
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)