Commit Graph

344 Commits

Author SHA1 Message Date
Michael Bridgen e45b446b86 Correct directory diffing test and algorithm
Two steps:

1. TestDiffDirectories did not check if the expected only return value
was correct; the intention was there to do so (judging by the
comment "change in order"), but my eye for detail failed me.

2. Reversing the directory comparison in the test revealed bugs in the
comparison code -- in general, it should skip any directory that is
not a directory in the comparator.

To make this easier, the code now keeps track of the expected files it
saw. That means the check for whether an actual file has an expected
counterpart only has two cases, yes or no (rather that trying to
account for whether it's a directory and so on). If a directory was
skipped while scanning the expected files, it won't be in the actual
files anyway.

Signed-off-by: Michael Bridgen <mikeb@weave.works>
2021-10-18 14:49:48 +01:00
Sunny 413e1e2f46 Update tests to be compatible with CR > v0.10.0
In controller-runtime v0.10.0, the client is updated to clean any stale
data in the target object when performing any operation. This results in
test failure for the code that constructs an object with both spec and
status, and creates the object and updates status it with the same
object. The fix is to set the status separately on the object before
updating it.

Refer: https://github.com/kubernetes-sigs/controller-runtime/pull/1640

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-10-01 21:57:29 +05:30
Sunny a76397de0b Remove legacy_suite_test.go
All the tests use testenv. Remove legacy envtest suite_test.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-28 18:28:41 +05:30
Sunny f79a72ac74 update pkg/test and pkg/update with testenv
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-28 18:28:41 +05:30
Sunny e3be50e586 controllers/update_test.go: Update to use testenv
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-28 18:28:36 +05:30
Sunny 2eb00a6107 Add testenv TestMain and move ginkgo to legacy
Add new testenv based TestMain in suite_test.go and move the ginkgo test
setup to legacy_suite_test.go. This helps to run both the ginkgo tests
and testenv based tests.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-23 02:10:47 +05:30
Michael Bridgen 486c6cfc6d
Merge pull request #218 from fluxcd/port-pkg-runtime
Port to new pkg/runtime helpers
2021-09-20 11:12:49 +01:00
Michael Bridgen 57d40437df Use events and metrics helpers
This commit replaces the explicit use of event recorder and metrics
with the helpers from github.com/fluxcd/pkg/runtime.

Doing so necessitated a few consts to represent the event "reasons",
so it is not a mechanical translation. Without thinking overly long
about it, I came up with a handful of reasons that I think will be
useful for filtering.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-15 10:44:30 +01:00
Michael Bridgen 1bce6eeb34 Use patch.Helper to update the object
A pretty straight-forward change. NB the location of the `defer ...`
_after_ the exit if the object is suspended; this maintains the
invariant that the object will not be touched at all when suspended.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-09 15:57:14 +01:00
Michael Bridgen 5d62547abc Port to conditions helpers
This commit rewrites the controller code so it uses the conditions
helpers from fluxcd/pkg/runtime/conditions.

It needs the fluxcd/source-controller/api module from the
reconcilers-dev branch, otherwise they will disagree on the methods in
fluxcd/pkg/apis/meta. Hence, variations on

    go get github.com/fluxcd/source-controller{,api}@reconcilers-dev

until I got both ./go.mod and ./api/go.mod to use modules from the
branch.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-09 12:19:02 +01:00
Michael Bridgen c829c590c9 Bump pkg/apis/meta and pkg/runtime to RCs
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-09-08 16:45:40 +01:00
Stefan Prodan 55b55c66de
Merge pull request #212 from fluxcd/release-v0.14.1
Release 0.14.1
2021-08-05 18:14:39 +03:00
Stefan Prodan aadf60fa1e
Release 0.14.1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-05 17:55:18 +03:00
Stefan Prodan 4e8ffa1c2c
Merge pull request #211 from fluxcd/update-deps
Update dependencies
2021-08-05 17:51:33 +03:00
Stefan Prodan 5cf4c4a5a6
Update dependencies
- k8s.io/* v0.21.3
- controller-runtime v0.9.5
- source-controller/api v0.15.4
- image-reflector-controller/api v0.11.1

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-08-05 17:27:25 +03:00
Michael Bridgen bd7af24306
Merge pull request #198 from aaron-trout/policy-typo
Fix Typo: policiy -> policy
2021-07-19 15:05:56 +01:00
Aaron Trout c99bc07ac7
Fix Typo: policiy -> policy
Signed-off-by: Aaron Trout <atrout@confluent.io>
2021-07-14 12:54:13 +01:00
Michael Bridgen 70eb6c4a62
Merge pull request #195 from fluxcd/rejected-branch-push
Fail push if a ref update is rejected
2021-07-14 10:50:46 +01:00
Michael Bridgen 3476ecb950 Fail push if a ref update is rejected
libgit2's Push method will succeed even when ref updates are rejected,
meaning it can silently fail if you e.g., use branch protection in
GitHub.

To make these errors visible, a callback is supplied to Push, which
checks for a non-empty status (on the advice of
https://libgit2.org/libgit2/#HEAD/group/callback/git_push_update_reference_cb).

For whatever reason, gogit seems overly sensitive to hook errors (in a
way that `git` and libgit2 aren't), and reports "invalid pkg-len
found" when it sees a rejected ref message. This doesn't affect the
runtime code, since that uses libgit2 -- but it does affect the test
code, which initialises the git repo used in many tests, so more care
is needed to push only the main branch, so as not to trigger a
rejection.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-07-13 16:06:17 +01:00
Michael Bridgen 3102d487ff
Merge pull request #193 from fluxcd/release-v0.14.0
Release v0.14.0
2021-06-28 14:57:55 +01:00
Michael Bridgen a46981f660 Bump version used in controller config
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 14:45:21 +01:00
Michael Bridgen 7ae502fee4 Write changelog entry for v0.14.0
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 14:44:39 +01:00
Michael Bridgen 4a34480a8d Bump version of image (automation) API to v0.14.0
Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 14:35:31 +01:00
Michael Bridgen 5711c59e5b
Merge pull request #191 from fluxcd/api-v1beta1
Graduate to v1beta1
2021-06-28 14:32:10 +01:00
Michael Bridgen fd52463ac5 Use v1beta1 of the API from image reflector
This bumps the version of the image reflector types to v1beta1. This
doesn't technically make a difference for the minute, since the
Kubernetes API server would convert between versions, but is tidier.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 13:59:34 +01:00
Michael Bridgen 3629cc7d25 Download image reflector v1beta1 API
This bumps the image reflector CRDs, used in tests, to the release
including v1beta1.

It also removes a long-standing, occasional annoyance, which is that
the downloaded CRDs would conflict with each other unless you
remembered to do `make clean-test-deps`. Though you will have to do
that once more.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 13:56:51 +01:00
Michael Bridgen f64d6cd4c8 Port API guide from v1alpha2 to v1beta1
The guides are kept in versioned directories, but only one version
appears to make it to the documentation website. For that reason,
rather than trying to refer to the previous version's migration guide,
I've just copied it and adapted it minimally to the new version.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 11:26:59 +01:00
Michael Bridgen 5b9631327f Graduate v1alpha2 API to v1beta1
This does the following:

 - copies the type definitions from v1alpha2 to v1beta1
 - changes the "stored" version to v1beta1
 - gives the CRD a conversion strategy of None, meaning just rewrite the version
 - switches the controller to use v1beta1
 - moves the generated documentation to v1beta1

This effectively rebadges the v1alpha2 version of this part of the
image API to v1beta1. The v1alpha2 version is left in place; there are
no conversion issues, as with v1alpha1->v1alpha2. The CRD specifies
that converting between v1alpha2 and v1beta1 just means changing the
version (i.e., the schema and semantics are the same).

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 11:26:59 +01:00
Stefan Prodan c1533ea757
Merge pull request #192 from makkes/makkes/concurrent-reconciles
feat: add controller concurrency
2021-06-25 10:18:34 +03:00
Max Jonas Werner 93782755ef
feat: add controller concurrency
The controller is now working with 4 concurrent workers by default.
This value is configurable through the `--concurrent` flag.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-06-24 20:15:00 +02:00
Michael Bridgen aabdcc92bb
Merge pull request #190 from fluxcd/more-debug-output
More debug output
2021-06-24 09:46:09 +01:00
Michael Bridgen 0a9c9a7437 Fill in tracking gaps
- trace different code paths, e.g., how the push branch is chosen
 - move debug output so it records things not already covered by e.g.,
   errors, events

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-23 12:23:36 +01:00
Michael Bridgen f011f2334e Thread debug/tracing through controller and pkg/
This commit finesses the use of the debug log a little, and introduces
a trace log. The trace log gets threaded through calls to utility
procedures -- it's a little awkward putting loggers into func
parameters and structs, but it always is.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-23 10:57:04 +01:00
Michael Bridgen c798f559fe Let log level be supplied for make run
It's useful to be able to run with debug logging, which you can do now
with:

    make run LOG_LEVEL=debug

As a companion change, logging from `make run` is now explicitly set
to console format, since the expectation is it will be run from a
console.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-22 15:47:50 +01:00
Stefan Prodan a13bbb69ca
Merge pull request #189 from fluxcd/release-v0.13.0
Release v0.13.0
2021-06-22 16:20:03 +03:00
Stefan Prodan 773d2bcb71
Release v0.13.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 16:01:06 +03:00
Stefan Prodan 8c455cea39
Merge pull request #188 from fluxcd/source-controller-v0.15.2
Update source-controller to v0.15.2
2021-06-22 15:59:20 +03:00
Stefan Prodan 8b3c4420bb
Update source-controller to v0.15.2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 15:49:10 +03:00
Stefan Prodan 5ba9ef9efb
Merge pull request #187 from fluxcd/debian
Use Debian as base image
2021-06-22 15:04:01 +03:00
Stefan Prodan c309c9515e
Use Debian Slim for the controller base image
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 13:58:40 +03:00
Stefan Prodan 1142f776ff
Use Debian for running unit tests
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-22 11:50:28 +03:00
Hidde Beydals b28f23ac94
Merge pull request #185 from fluxcd/release-v0.12.0
Release v0.12.0
2021-06-10 18:36:13 +02:00
Hidde Beydals 8fbdc4334a Release v0.12.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-10 18:02:13 +02:00
Hidde Beydals b0da308c4a
Merge pull request #183 from fluxcd/update-deps 2021-06-10 15:45:31 +02:00
Hidde Beydals 1dd6eabac2 Remove duplicate declaration
To not confuse the documentation generator.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-10 15:04:40 +02:00
Hidde Beydals f0b9d2e890 Update image-reflector-controller to v0.10.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-10 15:04:34 +02:00
Hidde Beydals c0bcae4f8c Update dependencies
- Go 1.16
- `sigs.k8s.io/controller-runtime` to `v0.9.0`
- `fluxcd/source-controller` to `v0.14.0`
- `fluxcd/pkg/*` to packages compatible with Go 1.16 and
   controller-runtime v0.9.0

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-10 10:40:28 +02:00
Hidde Beydals 7c0bc1c85a
Merge pull request #184 from fluxcd/nightly-builds 2021-06-09 18:56:40 +02:00
Hidde Beydals 9c223fa73c Allow RC releases
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 18:41:20 +02:00
Hidde Beydals 373e4dca4d Add nightly builds workflow
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 18:40:20 +02:00