Skip to content

Commit

Permalink
Fix timestamp logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Sep 24, 2020
1 parent 0d40969 commit 5084b40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 0 additions & 4 deletions modules/agent/pkg/controllers/bundledeployment/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ func shouldRedeploy(bd *fleet.BundleDeployment) bool {
if bd.Status.ForceSync == nil {
return true
}
if bd.Spec.Options.ForceSyncBefore.Time.After(time.Now().Add(-15 * time.Minute)) {
return false
}

return bd.Status.ForceSync.Before(bd.Spec.Options.ForceSyncBefore)
}

Expand Down
15 changes: 10 additions & 5 deletions pkg/controllers/cluster/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func agentDeployed(cluster *fleet.Cluster) bool {
if cluster.Status.AgentLastDeployed == nil {
return false
}
return cluster.Spec.ForceUpdateAgent == nil ||
cluster.Spec.ForceUpdateAgent.Time.After(time.Now().Add(-15*time.Minute)) ||
cluster.Spec.ForceUpdateAgent.Before(cluster.Status.AgentLastDeployed)
if cluster.Spec.ForceUpdateAgent == nil {
return true
}
return !cluster.Status.AgentLastDeployed.Before(cluster.Spec.ForceUpdateAgent)
}

func (i *importHandler) OnChange(key string, cluster *fleet.Cluster) (_ *fleet.Cluster, err error) {
Expand Down Expand Up @@ -173,7 +174,11 @@ func (i *importHandler) importCluster(cluster *fleet.Cluster, status fleet.Clust
return status, err
}

now := metav1.Now()
status.AgentLastDeployed = &now
if cluster.Spec.ForceUpdateAgent != nil {
status.AgentLastDeployed = cluster.Spec.ForceUpdateAgent
} else {
now := metav1.Now()
status.AgentLastDeployed = &now
}
return status, nil
}

0 comments on commit 5084b40

Please sign in to comment.