Skip to content

Commit

Permalink
Merge pull request #393 from fluxcd/fix-conn-leak
Browse files Browse the repository at this point in the history
Update source-controller to v0.25.7
  • Loading branch information
darkowlzz authored Jun 22, 2022
2 parents adae8fb + ec89ad4 commit cb5f15b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.17

require (
github.com/fluxcd/pkg/apis/meta v0.14.2
github.com/fluxcd/source-controller/api v0.25.5
github.com/fluxcd/source-controller/api v0.25.7
k8s.io/apimachinery v0.24.1
sigs.k8s.io/controller-runtime v0.11.2
)
Expand Down
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/fluxcd/pkg/apis/acl v0.0.3 h1:Lw0ZHdpnO4G7Zy9KjrzwwBmDZQuy4qEjaU/RvA6
github.com/fluxcd/pkg/apis/acl v0.0.3/go.mod h1:XPts6lRJ9C9fIF9xVWofmQwftvhY25n1ps7W9xw0XLU=
github.com/fluxcd/pkg/apis/meta v0.14.2 h1:/Hf7I/Vz01vv3m7Qx7DtQvrzAL1oVt0MJcLb/I1Y1HE=
github.com/fluxcd/pkg/apis/meta v0.14.2/go.mod h1:ijZ61VG/8T3U17gj0aFL3fdtZL+mulD6V8VrLLUCAgM=
github.com/fluxcd/source-controller/api v0.25.5 h1:64rLb5cuHhZ3LcRIxkp+/oAVCyVtjOhQ9kbphdFfR/s=
github.com/fluxcd/source-controller/api v0.25.5/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
github.com/fluxcd/source-controller/api v0.25.7 h1:vXGKBTGT9bcx9sRI7MbmaebEeKoq17vQoPI8IOObpXk=
github.com/fluxcd/source-controller/api v0.25.7/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
Expand Down
3 changes: 1 addition & 2 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"testing"
"time"

"github.com/go-logr/logr"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -63,7 +62,7 @@ func TestMain(m *testing.M) {
filepath.Join("testdata", "crds"),
))

managed.InitManagedTransport(logr.Discard())
managed.InitManagedTransport()

controllerName := "image-automation-controller"
if err := (&ImageUpdateAutomationReconciler{
Expand Down
22 changes: 17 additions & 5 deletions controllers/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,10 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
// test cases and cleanup at the end.

t.Run("PushSpec", func(t *testing.T) {
g := NewWithT(t)

// Clone the repo locally.
cloneCtx, cancel := context.WithTimeout(ctx, time.Second*10)
cloneCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
localRepo, err := clone(cloneCtx, cloneLocalRepoURL, branch)
g.Expect(err).ToNot(HaveOccurred(), "failed to clone git repo")
Expand All @@ -499,6 +501,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
pushBranch := "pr-" + randStringRunes(5)

t.Run("update with PushSpec", func(t *testing.T) {
g := NewWithT(t)

preChangeCommitId := commitIdFromBranch(localRepo, branch)
commitInRepo(g, cloneLocalRepoURL, branch, "Install setter marker", func(tmp string) {
g.Expect(replaceMarker(tmp, policyKey)).To(Succeed())
Expand Down Expand Up @@ -536,6 +540,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
})

t.Run("push branch gets updated", func(t *testing.T) {
g := NewWithT(t)

initialHead, err := headFromBranch(localRepo, branch)
g.Expect(err).ToNot(HaveOccurred())
defer initialHead.Free()
Expand Down Expand Up @@ -566,6 +572,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
})

t.Run("still pushes to the push branch after it's merged", func(t *testing.T) {
g := NewWithT(t)

initialHead, err := headFromBranch(localRepo, branch)
g.Expect(err).ToNot(HaveOccurred())
defer initialHead.Free()
Expand Down Expand Up @@ -610,13 +618,15 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
})

t.Run("with update strategy setters", func(t *testing.T) {
g := NewWithT(t)

// Clone the repo locally.
// NOTE: A new localRepo is created here instead of reusing the one
// in the previous case due to a bug in some of the git operations
// test helper. When switching branches, the localRepo seems to get
// stuck in one particular branch. As a workaround, create a
// separate localRepo.
cloneCtx, cancel := context.WithTimeout(ctx, time.Second*10)
cloneCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
localRepo, err := clone(cloneCtx, cloneLocalRepoURL, branch)
g.Expect(err).ToNot(HaveOccurred(), "failed to clone git repo")
Expand Down Expand Up @@ -677,6 +687,8 @@ func TestImageAutomationReconciler_e2e(t *testing.T) {
})

t.Run("no reconciliation when object is suspended", func(t *testing.T) {
g := NewWithT(t)

err = createImagePolicyWithLatestImage(testEnv, imagePolicyName, namespace, "not-expected-to-exist", "1.x", latestImage)
g.Expect(err).ToNot(HaveOccurred(), "failed to create ImagePolicy resource")

Expand Down Expand Up @@ -863,7 +875,7 @@ func compareRepoWithExpected(g *WithT, repoURL, branch, fixture string, changeFi

copy.Copy(fixture, expected)
changeFixture(expected)
cloneCtx, cancel := context.WithTimeout(ctx, time.Second*10)
cloneCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
repo, err := clone(cloneCtx, repoURL, branch)
g.Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -909,7 +921,7 @@ func configureTransportOptsForRepo(repo *libgit2.Repository) (func(), error) {
}

func commitInRepo(g *WithT, repoURL, branch, msg string, changeFiles func(path string)) *libgit2.Oid {
cloneCtx, cancel := context.WithTimeout(ctx, time.Second*10)
cloneCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
repo, err := clone(cloneCtx, repoURL, branch)
g.Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -1443,7 +1455,7 @@ func testWithCustomRepoAndImagePolicy(

// Clone the repo.
repoURL := gitServer.HTTPAddressWithCredentials() + repositoryPath
cloneCtx, cancel := context.WithTimeout(ctx, time.Second*10)
cloneCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
localRepo, err := clone(cloneCtx, repoURL, args.branch)
g.Expect(err).ToNot(HaveOccurred(), "failed to clone git repo")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/fluxcd/pkg/gittestserver v0.5.4
github.com/fluxcd/pkg/runtime v0.16.2
github.com/fluxcd/pkg/ssh v0.5.0
github.com/fluxcd/source-controller v0.25.5
github.com/fluxcd/source-controller/api v0.25.5
github.com/fluxcd/source-controller v0.25.7
github.com/fluxcd/source-controller/api v0.25.7
github.com/go-logr/logr v1.2.3
github.com/google/go-containerregistry v0.9.0
github.com/libgit2/git2go/v33 v33.0.9
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ github.com/fluxcd/pkg/ssh v0.5.0 h1:jE9F2XvUXC2mgseeXMATvO014fLqdB30/VzlPLKsk20=
github.com/fluxcd/pkg/ssh v0.5.0/go.mod h1:KGgOUOy1uI6RC6+qxIBLvP1AeOOs/nLB25Ca6TZMIXE=
github.com/fluxcd/pkg/version v0.1.0 h1:v+SmCanmCB5Tj2Cx9TXlj+kNRfPGbAvirkeqsp7ZEAQ=
github.com/fluxcd/pkg/version v0.1.0/go.mod h1:V7Z/w8dxLQzv0FHqa5ox5TeyOd2zOd49EeuWFgnwyj4=
github.com/fluxcd/source-controller v0.25.5 h1:a96qa3/PQPXZ7OcfLTaDmMKee/Qhxr9G8C21+/MnqhM=
github.com/fluxcd/source-controller v0.25.5/go.mod h1:401D+j+jFZcy9iuH7RrOMbkXJazsQK4Ce5q8pgKaXBI=
github.com/fluxcd/source-controller/api v0.25.5 h1:64rLb5cuHhZ3LcRIxkp+/oAVCyVtjOhQ9kbphdFfR/s=
github.com/fluxcd/source-controller/api v0.25.5/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
github.com/fluxcd/source-controller v0.25.7 h1:gksopk/IVPnL+bkBRwpFnvQUr+72tJvxzJ+D+UZohD4=
github.com/fluxcd/source-controller v0.25.7/go.mod h1:ZUZGoDPpDE8PDamRLbaXcjFfpVGhgu9bAx9sfohLs2k=
github.com/fluxcd/source-controller/api v0.25.7 h1:vXGKBTGT9bcx9sRI7MbmaebEeKoq17vQoPI8IOObpXk=
github.com/fluxcd/source-controller/api v0.25.7/go.mod h1:/e7YRDOqb8z8I3N8ifbDF1mknf8zFsoADtS/Q93iWPs=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func main() {
// +kubebuilder:scaffold:builder

if enabled, _ := features.Enabled(features.GitManagedTransport); enabled {
managed.InitManagedTransport(ctrl.Log.WithName("managed-transport"))
managed.InitManagedTransport()
}

setupLog.Info("starting manager")
Expand Down

0 comments on commit cb5f15b

Please sign in to comment.