Skip to content

Introduce common base for the unified standards #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from

Conversation

darkowlzz
Copy link
Contributor

These changes are cherry-picked from the controller refactor branch reconcilers-dev.
The reconcilers-dev branch is divided into multiple branches per reconciler:

  • reconcilers-dev-gitrepo
  • reconcilers-dev-bucket
  • reconcilers-dev-helmrepo
  • reconcilers-dev-helmchart

This branch contains the common base used by all the other branches.

  • It introduces more condition types used by the new reconciler implementations.
  • Usage of new conditions helpers.
  • Adds testenv, along size the existing envtest test suite.
  • Updates the common APIs required by the new reconcilers implementations.
  • Introduces events and metrics helpers in main.go.

Once this is merged, the other branches will be up to date with the main branch, making it easier to review and get them merged as well.

@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch from 37c314f to baaa083 Compare November 26, 2021 13:51
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch from baaa083 to a722ec7 Compare December 6, 2021 08:31
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch 4 times, most recently from db13413 to b65e9bf Compare December 20, 2021 20:31
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch 8 times, most recently from 9b9d50f to 691444a Compare January 20, 2022 00:10
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch from 691444a to 8908d80 Compare January 20, 2022 15:27
@hiddeco hiddeco force-pushed the reconcilers-dev-common branch from 425d315 to d55df89 Compare January 21, 2022 22:49
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>
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch from d55df89 to 55778f1 Compare January 24, 2022 15:29
hiddeco and others added 9 commits January 24, 2022 21:59
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>
NOTE: Remove `hasArtifactUpdated` in the future once it's no longer
used.

Signed-off-by: Hidde Beydals <hello@hidde.co>
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 introduction of this method deprecates `GetInterval()`, which
should be removed in a future MINOR release.

Signed-off-by: Sunny <darkowlzz@protonmail.com>

Co-authored-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Sunny <darkowlzz@protonmail.com>
Also, introduce FetchFailedCondition for generic fetch failures.

Signed-off-by: Sunny <darkowlzz@protonmail.com>

Co-authored-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Sunny <darkowlzz@protonmail.com>

Co-authored-by: Hidde Beydals <hello@hidde.co>
Embedding runtime.Object in Source interface makes the Source type more
useful to interact with k8s API machinery.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
- internal/error - Contains internal error type used across the
  source-controller reconcilers.
- internal/reconcile - Contains helper abstractions for the
  controller-runtime reconcile Result type and functions to
  interact with the abstractions.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
In most of the reconcilers we have a repetative pattern of using part of
the object metadata to construct a temporary file path.

This commit introduces helpers as an abstraction, for both the creation
of a temporary directory based on `client.Object` type and object
metadata, and the generation of an arbitrary random temporary path
string.

Signed-off-by: Hidde Beydals <hello@hidde.co>
@darkowlzz darkowlzz force-pushed the reconcilers-dev-common branch from 55778f1 to d396592 Compare January 24, 2022 16:37
@hiddeco
Copy link
Member

hiddeco commented Feb 23, 2022

Superseded by #586

@hiddeco hiddeco closed this Feb 23, 2022
@hiddeco hiddeco deleted the reconcilers-dev-common branch February 23, 2022 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants