Skip to content

Commit 2830501

Browse files
interface: progress drift/diff detection APIs to v1 (#298)
* Progressed drift/diff APIs to v1 Signed-off-by: michaelawyu <[email protected]> * Added API progression tests Signed-off-by: michaelawyu <[email protected]> --------- Signed-off-by: michaelawyu <[email protected]> Co-authored-by: Ryan Zhang <[email protected]>
1 parent db87d46 commit 2830501

11 files changed

+2663
-32
lines changed

apis/placement/v1/binding_types.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ type ResourceBindingStatus struct {
105105
// +optional
106106
FailedPlacements []FailedResourcePlacement `json:"failedPlacements,omitempty"`
107107

108+
// DriftedPlacements is a list of resources that have drifted from their desired states
109+
// kept in the hub cluster, as found by Fleet using the drift detection mechanism.
110+
//
111+
// To control the object size, only the first 100 drifted resources will be included.
112+
// This field is only meaningful if the `ClusterName` is not empty.
113+
// +kubebuilder:validation:Optional
114+
// +kubebuilder:validation:MaxItems=100
115+
DriftedPlacements []DriftedResourcePlacement `json:"driftedPlacements,omitempty"`
116+
117+
// DiffedPlacements is a list of resources that have configuration differences from their
118+
// corresponding hub cluster manifests. Fleet will report such differences when:
119+
//
120+
// * The CRP uses the ReportDiff apply strategy, which instructs Fleet to compare the hub
121+
// cluster manifests against the live resources without actually performing any apply op; or
122+
// * Fleet finds a pre-existing resource on the member cluster side that does not match its
123+
// hub cluster counterpart, and the CRP has been configured to only take over a resource if
124+
// no configuration differences are found.
125+
//
126+
// To control the object size, only the first 100 diffed resources will be included.
127+
// This field is only meaningful if the `ClusterName` is not empty.
128+
// +kubebuilder:validation:Optional
129+
// +kubebuilder:validation:MaxItems=100
130+
DiffedPlacements []DiffedResourcePlacement `json:"diffedPlacements,omitempty"`
131+
108132
// +patchMergeKey=type
109133
// +patchStrategy=merge
110134
// +listType=map
@@ -156,6 +180,18 @@ const (
156180
// - "False" means not all the resources are available in the target cluster yet.
157181
// - "Unknown" means we haven't finished the apply yet so that we cannot check the resource availability.
158182
ResourceBindingAvailable ResourceBindingConditionType = "Available"
183+
184+
// ResourceBindingDiffReported indicates that Fleet has successfully reported configuration
185+
// differences between the hub cluster and a specific member cluster for the given resources.
186+
//
187+
// This condition is added only when the ReportDiff apply strategy is used.
188+
//
189+
// It can have the following condition statuses:
190+
// * True: Fleet has successfully reported configuration differences for all resources.
191+
// * False: Fleet has not yet reported configuration differences for some resources, or an
192+
// error has occurred.
193+
// * Unknown: Fleet has not finished processing the diff reporting yet.
194+
ResourceBindingDiffReported ResourceBindingConditionType = "DiffReported"
159195
)
160196

161197
// ClusterResourceBindingList is a collection of ClusterResourceBinding.

apis/placement/v1/clusterresourceplacement_types.go

Lines changed: 411 additions & 11 deletions
Large diffs are not rendered by default.

apis/placement/v1/work_types.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,74 @@ type WorkResourceIdentifier struct {
110110
Name string `json:"name,omitempty"`
111111
}
112112

113+
// DriftDetails describes the observed configuration drifts.
114+
type DriftDetails struct {
115+
// ObservationTime is the timestamp when the drift was last detected.
116+
//
117+
// +kubebuilder:validation:Required
118+
// +kubebuilder:validation:Type=string
119+
// +kubebuilder:validation:Format=date-time
120+
ObservationTime metav1.Time `json:"observationTime"`
121+
122+
// ObservedInMemberClusterGeneration is the generation of the applied manifest on the member
123+
// cluster side.
124+
// +kubebuilder:validation:Required
125+
ObservedInMemberClusterGeneration int64 `json:"observedInMemberClusterGeneration"`
126+
127+
// FirstDriftedObservedTime is the timestamp when the drift was first detected.
128+
//
129+
// +kubebuilder:validation:Required
130+
// +kubebuilder:validation:Type=string
131+
// +kubebuilder:validation:Format=date-time
132+
FirstDriftedObservedTime metav1.Time `json:"firstDriftedObservedTime"`
133+
134+
// ObservedDrifts describes each drifted field found from the applied manifest.
135+
// Fleet might truncate the details as appropriate to control object size.
136+
//
137+
// Each entry specifies how the live state (the state on the member cluster side) compares
138+
// against the desired state (the state kept in the hub cluster manifest).
139+
//
140+
// +kubebuilder:validation:Optional
141+
ObservedDrifts []PatchDetail `json:"observedDrifts,omitempty"`
142+
}
143+
144+
// DiffDetails describes the observed configuration differences.
145+
type DiffDetails struct {
146+
// ObservationTime is the timestamp when the configuration difference was last detected.
147+
//
148+
// +kubebuilder:validation:Required
149+
// +kubebuilder:validation:Type=string
150+
// +kubebuilder:validation:Format=date-time
151+
ObservationTime metav1.Time `json:"observationTime"`
152+
153+
// ObservedInMemberClusterGeneration is the generation of the applied manifest on the member
154+
// cluster side.
155+
//
156+
// This might be nil if the resource has not been created yet in the member cluster.
157+
//
158+
// +kubebuilder:validation:Optional
159+
ObservedInMemberClusterGeneration *int64 `json:"observedInMemberClusterGeneration"`
160+
161+
// FirstDiffedObservedTime is the timestamp when the configuration difference
162+
// was first detected.
163+
//
164+
// +kubebuilder:validation:Required
165+
// +kubebuilder:validation:Type=string
166+
// +kubebuilder:validation:Format=date-time
167+
FirstDiffedObservedTime metav1.Time `json:"firstDiffedObservedTime"`
168+
169+
// ObservedDiffs describes each field with configuration difference as found from the
170+
// member cluster side.
171+
//
172+
// Fleet might truncate the details as appropriate to control object size.
173+
//
174+
// Each entry specifies how the live state (the state on the member cluster side) compares
175+
// against the desired state (the state kept in the hub cluster manifest).
176+
//
177+
// +kubebuilder:validation:Optional
178+
ObservedDiffs []PatchDetail `json:"observedDiffs,omitempty"`
179+
}
180+
113181
// ManifestCondition represents the conditions of the resources deployed on
114182
// spoke cluster.
115183
type ManifestCondition struct {
@@ -120,6 +188,28 @@ type ManifestCondition struct {
120188
// Conditions represents the conditions of this resource on spoke cluster
121189
// +required
122190
Conditions []metav1.Condition `json:"conditions"`
191+
192+
// DriftDetails explains about the observed configuration drifts.
193+
// Fleet might truncate the details as appropriate to control object size.
194+
//
195+
// Note that configuration drifts can only occur on a resource if it is currently owned by
196+
// Fleet and its corresponding placement is set to use the ClientSideApply or ServerSideApply
197+
// apply strategy. In other words, DriftDetails and DiffDetails will not be populated
198+
// at the same time.
199+
//
200+
// +kubebuilder:validation:Optional
201+
DriftDetails *DriftDetails `json:"driftDetails,omitempty"`
202+
203+
// DiffDetails explains the details about the observed configuration differences.
204+
// Fleet might truncate the details as appropriate to control object size.
205+
//
206+
// Note that configuration differences can only occur on a resource if it is not currently owned
207+
// by Fleet (i.e., it is a pre-existing resource that needs to be taken over), or if its
208+
// corresponding placement is set to use the ReportDiff apply strategy. In other words,
209+
// DiffDetails and DriftDetails will not be populated at the same time.
210+
//
211+
// +kubebuilder:validation:Optional
212+
DiffDetails *DiffDetails `json:"diffDetails,omitempty"`
123213
}
124214

125215
// +genclient

apis/placement/v1/zz_generated.deepcopy.go

Lines changed: 153 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)