Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UTC for timestamps #3137

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/testenv/githelper/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func author() *object.Signature {
return &object.Signature{
Name: "CI",
Email: "[email protected]",
When: time.Now(),
When: time.Now().UTC(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/agent/deployer/summary/summarizers.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func checkInitializing(obj data.Object, conditions []Condition, summary fleetv1.
if summary.State == "" && hasConditions && len(conditions) == 0 && strings.Contains(apiVersion, "cattle.io") {
val := obj.String("metadata", "created")
if i, err := convert.ToTimestamp(val); err == nil {
if time.Unix(i/1000, 0).Add(5 * time.Second).After(time.Now()) {
if time.Unix(i/1000, 0).Add(5 * time.Second).After(time.Now().UTC()) {
summary.State = "initializing"
summary.Transitioning = true
}
Expand Down Expand Up @@ -393,7 +393,7 @@ func checkRemoving(obj data.Object, conditions []Condition, summary fleetv1.Summ

summary.Message = append(summary.Message, "waiting on "+f)
if i, err := convert.ToTimestamp(removed); err == nil {
if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now()) {
if time.Unix(i/1000, 0).Add(5 * time.Minute).Before(time.Now().UTC()) {
summary.Error = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (h *handler) deleteExpired(token *fleet.ClusterRegistrationToken) (bool, er
return false, nil
}
expire := token.CreationTimestamp.Add(ttl.Duration)
if time.Now().After(expire) {
if time.Now().UTC().After(expire) {
return true, h.clusterRegistrationTokens.Delete(token.Namespace, token.Name, nil)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ type TimeGetter interface {

type RealClock struct{}

func (RealClock) Now() time.Time { return time.Now() }
func (RealClock) Now() time.Time { return time.Now().UTC() }
func (RealClock) Since(t time.Time) time.Duration { return time.Since(t) }

// CronJobReconciler reconciles a GitRepo resource to create a git cloning k8s job
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/controller/imagescan/gitcommit_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (j *GitCommitJob) cloneAndReplace(ctx context.Context) {
if interval == nil || interval.Seconds() == 0.0 {
interval = &DefaultInterval
}
gitrepo.Status.LastSyncedImageScanTime = metav1.NewTime(time.Now())
gitrepo.Status.LastSyncedImageScanTime = metav1.NewTime(time.Now().UTC())

// update gitrepo status
condition.Cond(fleet.ImageScanSyncCondition).SetError(&gitrepo.Status, "", nil)
Expand Down Expand Up @@ -365,7 +365,7 @@ func commitAllAndPush(ctx context.Context, repo *gogit.Repository, auth transpor
Author: &object.Signature{
Name: commit.AuthorName,
Email: commit.AuthorEmail,
When: time.Now(),
When: time.Now().UTC(),
},
}); err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/controller/imagescan/tagscan_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (j *TagScanJob) updateImageTags(ctx context.Context) {
return
}

image.Status.LastScanTime = metav1.NewTime(time.Now())
image.Status.LastScanTime = metav1.NewTime(time.Now().UTC())

latestTag, err := latestTag(image.Spec.Policy, tags)
if err != nil {
Expand Down