From 9fca6a245c67b325602b4c878a740fd8d2dd01ab Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Fri, 25 Sep 2020 09:59:05 +0200 Subject: [PATCH] Remove reconciliation lock As the observed generation is now pushed before syncing the resource (https://github.com/fluxcd/helm-operator/issues/437), and the controller runtime queue guarantuees there are no consistency issues (see: https://openkruise.io/en-us/blog/blog2.html). --- controllers/helmrelease_controller.go | 16 ---------------- go.mod | 1 - go.sum | 2 -- 3 files changed, 19 deletions(-) diff --git a/controllers/helmrelease_controller.go b/controllers/helmrelease_controller.go index 75523e77c..da1d0d13a 100644 --- a/controllers/helmrelease_controller.go +++ b/controllers/helmrelease_controller.go @@ -24,7 +24,6 @@ import ( "io/ioutil" "net/http" "os" - "path" "path/filepath" "strings" "time" @@ -47,7 +46,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" - "github.com/fluxcd/pkg/lockedfile" "github.com/fluxcd/pkg/recorder" consts "github.com/fluxcd/pkg/runtime" "github.com/fluxcd/pkg/runtime/predicates" @@ -267,14 +265,6 @@ func (r *HelmReleaseReconciler) reconcileChart(ctx context.Context, hr *v2.HelmR } func (r *HelmReleaseReconciler) release(ctx context.Context, log logr.Logger, hr v2.HelmRelease, source sourcev1.Source, values chartutil.Values) (v2.HelmRelease, error) { - // Acquire lock - unlock, err := lock(fmt.Sprintf("%s-%s", hr.GetName(), hr.GetNamespace())) - if err != nil { - err = fmt.Errorf("lockfile error: %w", err) - return v2.HelmReleaseNotReady(hr, sourcev1.StorageOperationFailedReason, err.Error()), err - } - defer unlock() - // Create temp working dir tmpDir, err := ioutil.TempDir("", hr.GetReleaseName()) if err != nil { @@ -660,12 +650,6 @@ func getReleaseRevision(rel *release.Release) int { return rel.Version } -func lock(name string) (unlock func(), err error) { - lockFile := path.Join(os.TempDir(), name+".lock") - mutex := lockedfile.MutexAt(lockFile) - return mutex.Lock() -} - func download(url, tmpDir string) (string, error) { fp := filepath.Join(tmpDir, "artifact.tar.gz") out, err := os.Create(fp) diff --git a/go.mod b/go.mod index c73360edc..7db3d1723 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ replace github.com/fluxcd/helm-controller/api => ./api require ( github.com/fluxcd/helm-controller/api v0.0.10 - github.com/fluxcd/pkg/lockedfile v0.0.5 github.com/fluxcd/pkg/recorder v0.0.5 github.com/fluxcd/pkg/runtime v0.0.3 github.com/fluxcd/source-controller/api v0.0.18 diff --git a/go.sum b/go.sum index 640daef90..18aec707e 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,6 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZM github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fluxcd/pkg/lockedfile v0.0.5 h1:C3T8wfdff1UY1bvplmCkGOLrdMWJHO8Q8+tdlEXJYzQ= -github.com/fluxcd/pkg/lockedfile v0.0.5/go.mod h1:uAtPUBId6a2RqO84MTH5HKGX0SbM1kNW3Wr/FhYyDVA= github.com/fluxcd/pkg/recorder v0.0.5 h1:D8qfupahIvh6ncCMn2yTHsrzG91S05sp4zdpsbKWeaU= github.com/fluxcd/pkg/recorder v0.0.5/go.mod h1:2UG6EroZ6ZbqmqoL8k/cQMe09e6A36WyH4t4UDUGyuU= github.com/fluxcd/pkg/runtime v0.0.3 h1:x9rOThl1qh5srIUpW0YHEj1I84swMj5m76UqrR1QknY=