Commit Graph

785 Commits

Author SHA1 Message Date
Hidde Beydals f6f18030eb
Merge pull request #414 from darkowlzz/gitrepo-reconciler-artifact-tests
controllers: Add more tests for reconcileArtifact
2021-08-03 14:08:52 +02:00
Hidde Beydals 29442ba9bf Tweak logged messages
- Mention the current revision in the up-to-date log message.
- Ensure any error that is "swallowed" (not returned) is logged to
  ensure they are visible within the logs, and not just by inspecting
  the object.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-08-03 14:01:18 +02:00
Hidde Beydals a1ed1fc4b4 source: `GetRequeueAfter` in place of `GetInterval`
The problem with `GetInterval()` was that the returned type was of
`metav1.Duration`, while almost anywhere it was used, a type of
`time.Duration` was requested. The result of this was that we had to
call `GetInterval().Duration` all the time, which would become a bit
cumbersome after awhile.

To prevent this, we introduce a new `GetRequeueAfter() time.Duration`
method, which both results the right type, and bears a name that is
easier to remember where the value is used most; while setting the
`Result.RequeueAfter` during reconcile operations.

The introduced of this method deprecates `GetInterval()`, which should
be removed in a future MINOR release.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-08-03 13:36:12 +02:00
Hidde Beydals f1de98faf0 Replace %q in messages with '%s'
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-08-03 12:20:19 +02:00
Sunny be4e85b422
controllers: Add more tests for reconcileArtifact
Fixes error returned from target path validation check and adds more
test cases for TestGitRepositoryReconciler_reconcileArtifact.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-08-02 05:42:32 +05:30
Hidde Beydals e34f79203d storage: strip env specific data during archive
This ensures the checksum is predictable, and not influenced by e.g.
different runtime configuration settings, or FS specific data.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 19:37:02 +02:00
Hidde Beydals 2ca0b47fea Use same SemVer logic in both Git implementations
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 19:36:58 +02:00
Hidde Beydals f28f86a8ee Ensure rel path never traverses outside Storage
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 19:36:38 +02:00
Hidde Beydals 08ce0c95fc Rewrite `GitRepositoryReconciler` to new standards
This commit rewrites the `GitRepositoryReconciler` to new standards,
while implementing the newly introduced Condition types, and trying
to adhere better to Kubernetes API conventions.

More specifically it introduces:

- Implementation of more explicit Condition types to highlight
  abnormalities.
- Extensive usage of the `conditions` subpackage from `runtime`.
- Better and more conflict-resilient (status)patching of reconciled
  objects using the `patch` subpackage from runtime.
- Proper implementation of kstatus' `Reconciling` and `Stalled`
  conditions.
- First (integration) tests that solely rely on `testenv` and do not
  use Ginkgo.

There are a couple of TODOs marked in-code, these are suggestions for
the future and should be non-blocking.
In addition to the TODOs, more complex and/or edge-case test scenarios
may be added as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 19:36:32 +02:00
Hidde Beydals 912e59da1f Refactor `hasArtifactUpdated` into `artifactSet`
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 12:55:57 +02:00
Hidde Beydals 5e634fcdbb Introduce `fake` Git implementation
At present it only implements a fake commit, which for example can be
used to test commit verification logic.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 12:47:30 +02:00
Hidde Beydals 82583f2247 Implement new runtime interfaces, prepare testenv
This commit ensures all API objects implement the interfaces used by
the runtime package to work with conditions, etc., and prepares the
test suite to work with the `pkg/runtime/testenv` wrapper.

Changes are made in a backwards compatible way (that being: the
existing code can still be build and works as expected), but without
proper dependency boundaries. The result of this is that the API
package temporary depends on the runtime package, which is resolved
when all reconcilers have been refactored and the API package does
no longer contain condition modifying functions.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 12:33:18 +02:00
Hidde Beydals 48ebbcd64e Introduce more explicit Condition types
This commit introduces new Condition types to the v1beta1 API,
facilitating easier observation of (potentially) problematic state for
end-users.

- `ArtifactUnavailableCondition`: indicates there is no artifact
  available for the resource. This Condition should be set by the
  reconciler as soon as it observes the absence of an artifact for a
  source.
- `CheckoutFailedCondition`: indicates a transient or persistent
  checkout failure. This Condition should be set by the reconciler as
  soon as it observes a Git checkout failure, including any
  prerequisites like the unavailability of the referenced Secret used
  for authentication. It should be deleted as soon as a successful
  checkout has been observed again.
- `SourceVerifiedCondition`: indicates the integrity of the source has
  been verified. The Condition should be set to True or False by the
  reconciler based on the result of the integrity check.
  If there is no verification mode and/or secret configured, the
  Condition should be removed.
- `IncludeUnavailableCondition`: indicates one of the referenced
  includes is not available. This Condition should for example be set
  by the reconciler when the include does not exist, or does not have
  an artifact. If the includes become available, it should be deleted.
- `ArtifactOutdatedCondition`: indicates the current artifact of the
  source is outdated. This Condition should for example be set by the
  reconciler when it notices there is a newer revision for an artifact,
  or the previously included artifacts differ from the current available
  ones. The Condition should be removed after writing a new artifact
  to the storage.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-30 12:20:26 +02:00
Hidde Beydals 273f8b155e
Merge pull request #409 from fluxcd/dep-ioutil 2021-07-29 11:36:46 +02:00
Hidde Beydals c4d7e46b90 Drop deprecated `io/ioutil`
The package has been deprecated since Go 1.16, see:
https://golang.org/doc/go1.16#ioutil

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-29 09:58:00 +02:00
Hidde Beydals be5d10eaac
Merge pull request #403 from fluxcd/bucket-revision-path
Take relative paths in account for Bucket revision
2021-07-26 14:01:44 +02:00
Hidde Beydals f5cb441a82 Take relative paths in account for Bucket revision
This commit changes the checksum method which is used to calculate the
revision of a Bucket source, so that the file paths are taken into
account and directory structure changes can be observed.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-26 10:54:39 +02:00
Hidde Beydals dbaf8bf458
Merge pull request #405 from darkowlzz/client-objectkeyfromobject
Use ObjectKeyFromObject instead of ObjectKey
2021-07-26 10:48:19 +02:00
Sunny 9825a60b74
Use ObjectKeyFromObject instead of ObjectKey
controller-runtime's client package provides ObjectKeyFromObject() to
extract NamespacedName from a given object. ObjectKey() in
internal/util package is a helper for the same. Replace the internal
helper with controller-runtime's helper for the same.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-07-26 04:35:08 +05:30
Hidde Beydals 40a47670aa
Merge pull request #400 from fluxcd/update-deps
Update Helm to v3.6.3
2021-07-15 11:10:29 +02:00
Hidde Beydals 5e8e0ab65c Update Helm to v3.6.3
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-07-14 23:24:26 +02:00
Stefan Prodan c6ae5e779a
Merge pull request #396 from fluxcd/debug-e2e
Print pods status on e2e failures
2021-06-29 17:04:00 +03:00
Stefan Prodan 25a2428b80
Print pods status on e2e failures
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 16:40:15 +03:00
Stefan Prodan 5c170bfdc3
Merge pull request #395 from fluxcd/release-v0.15.3
Release v0.15.3
2021-06-29 13:37:28 +03:00
Stefan Prodan be9f05baf1
Release v0.15.3
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-29 12:27:52 +03:00
Stefan Prodan 887d2c5e50
Merge pull request #394 from bburky/libgit2-tag-checkout
Fix tag checkout with libgit2
2021-06-29 11:54:03 +03:00
Blake Burkhart 0df2b0e0f0 Fix tag checkout with libgit2
SetHeadDetached (git_repository_set_head_detached) only changes HEAD,
and does not actually checkout the files on disk. Use CheckoutHead with
the CheckoutForce Strategy to actually check the files out on disk.

Additionally add a test that validates the hash of a checked out file's
contents.

Previously, the hash of the desired tag was being reported as the
checked out revision by the GitRepository. However the wrong files were
checked out and an incorrect revision would be deployed by Flux.

Signed-off-by: Blake Burkhart <blake.burkhart@us.af.mil>
2021-06-28 20:03:11 -05:00
Hidde Beydals 76aa40d290
Merge pull request #392 from fluxcd/release-v0.15.2
Release v0.15.2
2021-06-22 14:22:51 +02:00
Hidde Beydals bec2d83c2b Release v0.15.2
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-22 14:05:36 +02:00
Hidde Beydals 221d0992ff
Merge pull request #391 from fluxcd/libgit2-unstable 2021-06-22 14:04:02 +02:00
Hidde Beydals 2c63246ede Change large-repo-* ref.branch to main
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-22 13:01:36 +02:00
Hidde Beydals fdb0a0b8c1 Use Debian Slim image in GitHub action
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-22 13:01:31 +02:00
Hidde Beydals c7e7b61e34 Use libgit2 from "unstable" / "sid"
We received reports from users no longer being able to clone Git
repositories using libgit2 because of errors during the cloning
attempt: `error: Failed to authenticate SSH session: Unable to extract
public key from private key.`

After an extensive scavenger hunt I was able to pinpoint the issue to
`libssh2` being linked against `libgcrypt` instead of `openssl`. The
problem with this is that the libgcrypt backend in libssh2 contains
a hand written slimmed down ASN.1 parser to read out keys, while the
OpenSSL backend in libssh2 uses OpenSSL, which supports a lot more
formats (and more specifically, most PKCS* formats).

As Debian's bullseye/testing repository has been frozen, and a
backport has not been made available yet, fetching the dependency from
"unstable" seems to be the best option for now, as this has `libssh2`
available including OpenSSL.

Ref: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668271

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-22 13:00:16 +02:00
Hidde Beydals 850157cc7a
Merge pull request #390 from fluxcd/release-v0.15.1
Release v0.15.1
2021-06-18 13:11:06 +02:00
Hidde Beydals 7013af77c5 Release v0.15.1
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-18 12:54:34 +02:00
Hidde Beydals 4a0ce41038
Merge pull request #388 from fluxcd/update-deps
Update Helm to v3.6.1
2021-06-18 12:48:49 +02:00
Hidde Beydals 1f27410b34 Update Helm to v3.6.1
v3.6.1 is a a security update from Helm, ensuring that credentials are
always only passed to the defined repository host.

Based on Helm user reports, disabling this behavior may be required for
some Helm repository solutions like Artifactory, and may be done by
setting `PassCredentials` in the `HelmRepositorySpec`.

For more information, see:
https://github.com/helm/helm/security/advisories/GHSA-56hp-xqp3-w2jf

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-18 12:31:23 +02:00
Stefan Prodan 1a75415103
Merge pull request #389 from fluxcd/release-v0.15.0
Release v0.15.0
2021-06-17 19:09:05 +03:00
Stefan Prodan 50c15b81b3
Release v0.15.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-17 18:51:09 +03:00
Hidde Beydals a1581ec185
Merge pull request #386 from fluxcd/armv7-goldlink-patch
Use Debian instead of Alpine for multi-arch builds
2021-06-17 16:28:39 +02:00
Hidde Beydals 44dd9d7e28
Merge pull request #387 from fluxcd/panic-non-nil-err
Panic on non-nil AddToScheme errors in main init
2021-06-17 16:14:41 +02:00
Hidde Beydals 7e6b88e91c Use Debian instead of Alpine in container image
This commit changes the base image for the build and controller
container images to Debian slim.

Reason for this is that it has proven to be hard to produce working
executables for AMD64, ARM64 and ARMv7 at all times using Alpine,
due to them being dynamically linked and compiled using CGO, and
Alpine having constraints like musl that create an extra barrier,
especially in combination with our exotic set of dependency
constraints.

There are a number of trade-offs we have to live with by doing this,
not limited to:

* An increased build time, the full release pipeline used to take 25-35
  minutes, based on the images we have build for testing purposes this
  seems to have become 35-40 minutes.
* An increased image size of roughly two times the (compressed) size of
  the Alpine based image.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-17 16:12:33 +02:00
Hidde Beydals 896489680e Panic on non-nil AddToScheme errors in main init
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-17 15:38:24 +02:00
Hidde Beydals 3af8962fd8
Merge pull request #382 from fluxcd/unpin-docker-dep
Unpin docker Go Module dependency
2021-06-10 17:57:36 +02:00
Hidde Beydals 2d8a540f0c Unpin docker Go Module dependency
No longer required as we do now depend on Helm v3.6.0, which no longer
pins the version.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-10 16:48:00 +02:00
Hidde Beydals 53ea50f1ba
Merge pull request #380 from fluxcd/patch-changelog
Patchup: add missing bit of text
2021-06-09 16:04:22 +02:00
Hidde Beydals 2e46791d2b Patchup: add missing bit of text
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 15:46:19 +02:00
Hidde Beydals d0d2c0e215
Merge pull request #379 from fluxcd/release-v0.14.0
Release v0.14.0
2021-06-09 15:25:23 +02:00
Hidde Beydals ffd018187d Release v0.14.0
This includes the `binutils-gold` patches required to make the Docker
images build properly.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-06-09 15:03:04 +02:00
Hidde Beydals 7f67fb7b86
Merge pull request #377 from fluxcd/armv7-gold-patch
Use `binutils-gold` in builder image
2021-06-09 14:58:43 +02:00