-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add conditions
and patch
helpers, and docs to runtime
#101
Conversation
65412ea
to
849f4a7
Compare
This commit loosely implements the events and metrics helpers that have been newly introduced to `fluxcd/pkg/runtime`, and heavily reduces code duplication. It is in preparation of a much bigger overhaul to implement the work pending in fluxcd/pkg#101. While implementing, I ran into little annoyances that likely should be addressed before the "official" `runtime` MINOR release: - Passing `nil` every time there isn't any metadata for an event quickly becomes cumbersome; we should look into an `EventWithMetadata` and/or `EventfWithMetadata`, or some other way to _optionally_ provide metadata without annoying the consumer. - There is an inconsistency in the method names of the metric helper, i.e. `RecordReadinessMetric` vs `RecordSuspend`. We either need to append or remove the `Metric` suffix on all recording methods. Signed-off-by: Hidde Beydals <hello@hidde.co>
f16559c
to
959de5c
Compare
959de5c
to
7ab6d82
Compare
This commit loosely implements the events and metrics helpers that have been newly introduced to `fluxcd/pkg/runtime`, and heavily reduces code duplication. It is in preparation of a much bigger overhaul to implement the work pending in fluxcd/pkg#101. While implementing, I ran into little annoyances that likely should be addressed before the "official" `runtime` MINOR release: - Passing `nil` every time there isn't any metadata for an event quickly becomes cumbersome; we should look into an `EventWithMetadata` and/or `EventfWithMetadata`, or some other way to _optionally_ provide metadata without annoying the consumer. - There is an inconsistency in the method names of the metric helper, i.e. `RecordReadinessMetric` vs `RecordSuspend`. We either need to append or remove the `Metric` suffix on all recording methods. Signed-off-by: Hidde Beydals <hello@hidde.co>
88061f2
to
a8405cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @hiddeco 🥇
2ac95df
to
18c56eb
Compare
9301197
to
57a37ad
Compare
@@ -21,19 +21,19 @@ const ( | |||
// outside of the defined schedule. Despite the name, the value is not | |||
// interpreted as a timestamp, and any change in value shall trigger a | |||
// reconciliation. | |||
// DEPRECATED: has been replaced by ReconcileRequestAnnotation. | |||
// DEPRECATED: has been replaced by ReconcileRequestAnnotation. For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's time to remove this, we've switched all controllers to ReconcileRequestAnnotation
in 2020.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably do this in a separate PR to not incorporate more "hidden" breaking changes in this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of goodies here 🎉, representing much valuable work. In particular, I want to applaud the explanations for why someone should use these things, and the examples of how to use them. The explanations are great because they describe the benefit to the user of the library, rather than just what will happen.
NB I only skimmed the stuff adapted from Kubernetes' libraries, noting that it has plenty of tests.
@@ -0,0 +1,302 @@ | |||
/* | |||
Copyright 2020 The Kubernetes Authors. | |||
Copyright 2021 The Flux authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think to comply with the license (https://www.apache.org/licenses/LICENSE-2.0, section 4):
- "You must cause any modified files to carry prominent notices stating that You changed the files"
- "You may add Your own copyright statement to Your modifications"
I'm not sure exactly what these entail, but I think it would work to use the format:
Copyright 2020 The Kubernetes Authors.
This file is modified from the source at <url> to
- adapt the Foo interface to better suit this project
- ...
Modifications copyright 2021 the Flux authors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given keeping a list with modifications is not realistic, I opted for the following format:
This file is modified from the source at
<url>,
and initially adapted to <reason for copying and making modifications>.
// deal with more complex logic in which for example a finite error state can be observed, it is RECOMMENDED to | ||
// implement the StalledCondition and ReconcilingCondition. | ||
// | ||
// By doing this, observers making use of kstatus to determine the current state of the resource will have a better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3 this explanation
This commit adds a helper to work with the conditions of GitOps Toolkit object kinds, including but not limited to aggregration, summarization and mirroring of condition types. The work has been derived from https://github.com/kubernetes-sigs/cluster-api/tree/7478817225e0a75acb6e14fc7b438231578073d2/util/conditions but adapted to work with the `metav1.Condition` and `metav1.ConditionStatus` types. More concretely, this includes the removal of "condition severity" related functionalities, as this is not supported by the `metav1.Condition` type. The following work is still required before it can be considered ready for consumption: * Support for "negative polarity" or "normal-false" conditions; this is required to properly support the `Stalled` and `Reconciling` conditions of `meta` (and `kstatus`). * Summarization to other target conditions than `Ready`; results in a more generic API. * Support setting the `ObservedGeneration` in the status condition. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit adds support for negative polarity conditions, also known as "normal-false" or "abnormal-true" types[1], during merge and set operations. The polarity is taken into account during sort operations, and results in the following order: - P0 - Status=True, NegativePolarity=True - P1 - Status=False, NegativePolarity=False - P2 - Condition=True, NegativePolarity=False - P3 - Status=False, NegativePolarity=True - P4 - Status=Unknown This order ensures that condifitions of most importance to the user are listed first. [1]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit ensures `Stalled`, `Ready` and `Reconciling` conditions are always ordered first while setting and merging conditions. This eases usage for end-users that are observing a resource via e.g. `kubectl`, and provides better integration with `kstatus`: https://github.com/kubernetes-sigs/cli-utils/blob/master/pkg/kstatus/README.md#conditions Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
This includes the renaming and introduction of a set of interfaces around working with objects that follow GitOps Toolkit conventions. Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit makes the runtime dependency package use the API structs and interface from our own meta package, and aligns the way we make assumptions about objects being being controller-runtime compatible options with that of the other helper packages like `controller` and `conditions`. Signed-off-by: Hidde Beydals <hello@hidde.co>
Quite a lot of the errors in the package had close to the same meaning, or could be used together with a context defining wrapping error. They also assumed knowledge of component implementation details at times. This commit de-duplicates the and removes the errors in these category, and also properly documents them. Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Extension includes the default configuration of mutex profiling, and inclusion of additional endpoints. Signed-off-by: Hidde Beydals <hello@hidde.co>
Including some `go <vet|fmt>` changes. Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
57a37ad
to
b7eec63
Compare
conditions
and patch
helper to runtime
conditions
and patch
helper and docs to runtime
conditions
and patch
helper and docs to runtime
conditions
and patch
helpers, and docs to runtime
This commit loosely implements the events and metrics helpers that have been newly introduced to `fluxcd/pkg/runtime`, and heavily reduces code duplication. It is in preparation of a much bigger overhaul to implement the work pending in fluxcd/pkg#101. While implementing, I ran into little annoyances that likely should be addressed before the "official" `runtime` MINOR release: - Passing `nil` every time there isn't any metadata for an event quickly becomes cumbersome; we should look into an `EventWithMetadata` and/or `EventfWithMetadata`, or some other way to _optionally_ provide metadata without annoying the consumer. - There is an inconsistency in the method names of the metric helper, i.e. `RecordReadinessMetric` vs `RecordSuspend`. We either need to append or remove the `Metric` suffix on all recording methods. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit loosely implements the events and metrics helpers that have been newly introduced to `fluxcd/pkg/runtime`, and heavily reduces code duplication. It is in preparation of a much bigger overhaul to implement the work pending in fluxcd/pkg#101. While implementing, I ran into little annoyances that likely should be addressed before the "official" `runtime` MINOR release: - Passing `nil` every time there isn't any metadata for an event quickly becomes cumbersome; we should look into an `EventWithMetadata` and/or `EventfWithMetadata`, or some other way to _optionally_ provide metadata without annoying the consumer. - There is an inconsistency in the method names of the metric helper, i.e. `RecordReadinessMetric` vs `RecordSuspend`. We either need to append or remove the `Metric` suffix on all recording methods. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit loosely implements the events and metrics helpers that have been newly introduced to `fluxcd/pkg/runtime`, and heavily reduces code duplication. It is in preparation of a much bigger overhaul to implement the work pending in fluxcd/pkg#101. While implementing, I ran into little annoyances that likely should be addressed before the "official" `runtime` MINOR release: - Passing `nil` every time there isn't any metadata for an event quickly becomes cumbersome; we should look into an `EventWithMetadata` and/or `EventfWithMetadata`, or some other way to _optionally_ provide metadata without annoying the consumer. - There is an inconsistency in the method names of the metric helper, i.e. `RecordReadinessMetric` vs `RecordSuspend`. We either need to append or remove the `Metric` suffix on all recording methods. Signed-off-by: Hidde Beydals <hello@hidde.co>
This pull request introduces
conditions
andpatch
helper packages toruntime
, and documents allruntime
code and related API packages to a bare minimum in a hope to drive implementation efforts.Fixes #117