Skip to content

Commit

Permalink
Remove reconciliation lock
Browse files Browse the repository at this point in the history
As the observed generation is now pushed before syncing the resource
(fluxcd/helm-operator#437), and the
controller runtime queue guarantuees there are no consistency
issues (see: https://openkruise.io/en-us/blog/blog2.html).
  • Loading branch information
hiddeco committed Sep 25, 2020
1 parent c02848c commit 9fca6a2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
16 changes: 0 additions & 16 deletions controllers/helmrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"io/ioutil"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 9fca6a2

Please sign in to comment.