Skip to content

Commit

Permalink
Merge pull request kubeedge#5817 from WillardHu/time-utc
Browse files Browse the repository at this point in the history
Make the timestamps of kubeedge resources support international time
  • Loading branch information
kubeedge-bot authored Aug 27, 2024
2 parents fcd75de + 14d27ba commit aa7494f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
v1alpha12 "github.com/kubeedge/api/apis/fsm/v1alpha1"
"github.com/kubeedge/api/apis/operations/v1alpha1"
"github.com/kubeedge/kubeedge/cloud/pkg/common/client"
"github.com/kubeedge/kubeedge/cloud/pkg/taskmanager/util"
"github.com/kubeedge/kubeedge/pkg/util/fsm"
)

Expand Down Expand Up @@ -71,7 +70,7 @@ func updatePrePullNodeState(id, nodeName string, state v1alpha12.State, event fs
State: state,
Event: event.Type,
Action: event.Action,
Time: time.Now().Format(util.ISO8601UTC),
Time: time.Now().UTC().Format(time.RFC3339),
Reason: event.Msg,
},
ImageStatus: imagesStatus,
Expand Down Expand Up @@ -122,7 +121,7 @@ func updateUpgradeTaskState(id, _ string, state v1alpha12.State, event fsm.Event
status.Action = event.Action
status.Reason = event.Msg
status.State = state
status.Time = time.Now().Format(util.ISO8601UTC)
status.Time = time.Now().UTC().Format(time.RFC3339)

err := patchStatus(newTask, *status, client.GetCRDClient())

Expand Down
5 changes: 2 additions & 3 deletions cloud/pkg/taskmanager/nodeupgradecontroller/upgrade_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
v1alpha12 "github.com/kubeedge/api/apis/fsm/v1alpha1"
"github.com/kubeedge/api/apis/operations/v1alpha1"
"github.com/kubeedge/kubeedge/cloud/pkg/common/client"
"github.com/kubeedge/kubeedge/cloud/pkg/taskmanager/util"
"github.com/kubeedge/kubeedge/pkg/util/fsm"
)

Expand Down Expand Up @@ -62,7 +61,7 @@ func updateUpgradeNodeState(id, nodeName string, state v1alpha12.State, event fs
State: state,
Event: event.Type,
Action: event.Action,
Time: time.Now().Format(util.ISO8601UTC),
Time: time.Now().UTC().Format(time.RFC3339),
Reason: event.Msg,
}
break
Expand Down Expand Up @@ -111,7 +110,7 @@ func updateUpgradeTaskState(id, _ string, state v1alpha12.State, event fsm.Event
status.Action = event.Action
status.Reason = event.Msg
status.State = state
status.Time = time.Now().Format(util.ISO8601UTC)
status.Time = time.Now().UTC().Format(time.RFC3339)

err := patchStatus(newTask, *status, client.GetCRDClient())

Expand Down
4 changes: 1 addition & 3 deletions cloud/pkg/taskmanager/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/distribution/distribution/v3/reference"
metav1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
versionutil "k8s.io/apimachinery/pkg/util/version"
"k8s.io/klog/v2"

Expand All @@ -41,8 +41,6 @@ const (
TaskRollback = "rollback"
TaskBackup = "backup"
TaskPrePull = "prepull"

ISO8601UTC = "2006-01-02T15:04:05Z"
)

type TaskMessage struct {
Expand Down
2 changes: 0 additions & 2 deletions common/constants/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,3 @@ const (
// DeviceTwin
DefaultDMISockPath = "/etc/kubeedge/dmi.sock"
)

const ISO8601UTC = "2006-01-02T15:04:05Z"
3 changes: 1 addition & 2 deletions edge/pkg/devicetwin/dtmanager/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"k8s.io/klog/v2"

"github.com/kubeedge/beehive/pkg/core/model"
common "github.com/kubeedge/kubeedge/common/constants"
messagepkg "github.com/kubeedge/kubeedge/edge/pkg/common/message"
"github.com/kubeedge/kubeedge/edge/pkg/common/modules"
"github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtclient"
Expand Down Expand Up @@ -99,7 +98,7 @@ func dealDeviceStateUpdate(context *dtcontext.DTContext, resource string, msg in
}
var lastOnline string
if state == dtcommon.DeviceStatusOnline || state == dtcommon.DeviceStatusOK {
lastOnline = time.Now().Format(common.ISO8601UTC)
lastOnline = time.Now().UTC().Format(time.RFC3339)
}
for i := 1; i <= dtcommon.RetryTimes; i++ {
err = dtclient.UpdateDeviceFields(
Expand Down
2 changes: 1 addition & 1 deletion keadm/cmd/keadm/app/cmd/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ func ReportTaskResult(config *v1alpha2.EdgeCoreConfig, taskType, taskID string,
NodeName: config.Modules.Edged.HostnameOverride,
Event: event.Type,
Action: event.Action,
Time: time.Now().Format(constants.ISO8601UTC),
Time: time.Now().UTC().Format(time.RFC3339),
Reason: event.Msg,
}
edgeHub := config.Modules.EdgeHub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,3 @@ const (
// DeviceTwin
DefaultDMISockPath = "/etc/kubeedge/dmi.sock"
)

const ISO8601UTC = "2006-01-02T15:04:05Z"

0 comments on commit aa7494f

Please sign in to comment.