From 1819ce2b252f049c24f365e61162129830eed8db Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sat, 12 Sep 2020 15:50:54 -0700 Subject: [PATCH] Update vendor --- go.mod | 2 +- go.sum | 2 ++ .../bundledeployment/controller.go | 29 ++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 114dfc99a6..353271dfdf 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/rancher/fleet/pkg/apis v0.0.0 github.com/rancher/gitjob v0.1.0 github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0 - github.com/rancher/wrangler v0.6.2-0.20200829053106-7e1dd4260224 + github.com/rancher/wrangler v0.6.2-0.20200912225020-2e02d61f54bc github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43 github.com/sirupsen/logrus v1.6.0 github.com/spf13/cobra v1.0.0 diff --git a/go.sum b/go.sum index f11d4728c8..283df9c1c9 100644 --- a/go.sum +++ b/go.sum @@ -767,6 +767,8 @@ github.com/rancher/wrangler v0.6.2-0.20200828043115-6943c5e1c9c7 h1:HXP9Rg3ijtwV github.com/rancher/wrangler v0.6.2-0.20200828043115-6943c5e1c9c7/go.mod h1:I7qe4DZNMOLKVa9ax7DJdBZ0XtKOppLF/dalhPX3vaE= github.com/rancher/wrangler v0.6.2-0.20200829053106-7e1dd4260224 h1:NWYSyS1YiWJOB84xq0FcGDY8xQQwrfKoip2BjMSlu1g= github.com/rancher/wrangler v0.6.2-0.20200829053106-7e1dd4260224/go.mod h1:I7qe4DZNMOLKVa9ax7DJdBZ0XtKOppLF/dalhPX3vaE= +github.com/rancher/wrangler v0.6.2-0.20200912225020-2e02d61f54bc h1:Td32Jny0tPOQFLxxZHxgfk9mlEYJopwB47EizTQuGjU= +github.com/rancher/wrangler v0.6.2-0.20200912225020-2e02d61f54bc/go.mod h1:I7qe4DZNMOLKVa9ax7DJdBZ0XtKOppLF/dalhPX3vaE= github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43 h1:+Bc9QnL9GuZiYxc3Mvm4n6EEjgI5TFQLDGjpRhQbkVk= github.com/rancher/wrangler-cli v0.0.0-20200815040857-81c48cf8ab43/go.mod h1:KxpGNhk/oVL6LCfyxESTD1sb8eXRlUxtkbNm06+7dZU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= diff --git a/modules/agent/pkg/controllers/bundledeployment/controller.go b/modules/agent/pkg/controllers/bundledeployment/controller.go index dea7b4ddb6..b453e13eca 100644 --- a/modules/agent/pkg/controllers/bundledeployment/controller.go +++ b/modules/agent/pkg/controllers/bundledeployment/controller.go @@ -105,6 +105,20 @@ func (h *handler) Trigger(key string, bd *fleet.BundleDeployment) (*fleet.Bundle return bd, nil } +func shouldRedeploy(bd *fleet.BundleDeployment) bool { + if bd.Spec.Options.ForceSyncBefore == nil { + return false + } + 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) +} + func (h *handler) MonitorBundle(bd *fleet.BundleDeployment, status fleet.BundleDeploymentStatus) (fleet.BundleDeploymentStatus, error) { if bd.Spec.DeploymentID != status.AppliedDeploymentID { return status, nil @@ -120,7 +134,20 @@ func (h *handler) MonitorBundle(bd *fleet.BundleDeployment, status fleet.BundleD status.Ready = deploymentStatus.Ready status.NonModified = deploymentStatus.NonModified - condition.Cond(fleet.BundleDeploymentConditionReady).SetError(&status, "", readyError(status)) + readyError := readyError(status) + condition.Cond(fleet.BundleDeploymentConditionReady).SetError(&status, "", readyError) + if len(status.ModifiedStatus) > 0 { + h.bdController.EnqueueAfter(bd.Namespace, bd.Name, 5*time.Minute) + if shouldRedeploy(bd) { + logrus.Infof("Redeploying %s", bd.Name) + status.AppliedDeploymentID = "" + } + } + + status.ForceSync = bd.Spec.Options.ForceSyncBefore + if readyError != nil { + logrus.Errorf("bundle %s: %v", bd.Name, readyError) + } return status, nil }