Skip to content

Commit 570b44c

Browse files
feat: rename the conditions so they are not confusing (#165)
1 parent b7ed047 commit 570b44c

21 files changed

+654
-655
lines changed

apis/placement/v1beta1/clusterresourceplacement_types.go

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ type PlacementStatus struct {
894894
// In these cases, some of them may not have assigned clusters when we cannot fill the required number of clusters.
895895
// TODO, For pickAll type, considering providing unselected clusters info.
896896
// +kubebuilder:validation:Optional
897-
PlacementStatuses []ResourcePlacementStatus `json:"placementStatuses,omitempty"`
897+
PlacementStatuses []PerClusterPlacementStatus `json:"placementStatuses,omitempty"`
898898

899899
// +patchMergeKey=type
900900
// +patchStrategy=merge
@@ -973,8 +973,8 @@ const (
973973
ResourceEnvelopeType EnvelopeType = "ResourceEnvelope"
974974
)
975975

976-
// ResourcePlacementStatus represents the placement status of selected resources for one target cluster.
977-
type ResourcePlacementStatus struct {
976+
// PerClusterPlacementStatus represents the placement status of selected resources for one target cluster.
977+
type PerClusterPlacementStatus struct {
978978
// ClusterName is the name of the cluster this resource is assigned to.
979979
// If it is not empty, its value should be unique cross all placement decisions for the Placement.
980980
// +kubebuilder:validation:Optional
@@ -1173,7 +1173,7 @@ type Toleration struct {
11731173
Effect corev1.TaintEffect `json:"effect,omitempty"`
11741174
}
11751175

1176-
// ClusterResourcePlacementConditionType defines a specific condition of a cluster resource placement.
1176+
// ClusterResourcePlacementConditionType defines a specific condition of a cluster resource placement object.
11771177
// +enum
11781178
type ClusterResourcePlacementConditionType string
11791179

@@ -1243,7 +1243,7 @@ const (
12431243
ClusterResourcePlacementDiffReportedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementDiffReported"
12441244
)
12451245

1246-
// ResourcePlacementConditionType defines a specific condition of a resource placement.
1246+
// ResourcePlacementConditionType defines a specific condition of a resource placement object.
12471247
// +enum
12481248
type ResourcePlacementConditionType string
12491249

@@ -1313,59 +1313,58 @@ const (
13131313
ResourcePlacemenDiffReportedConditionType ResourcePlacementConditionType = "ResourcePlacemenDiffReported"
13141314
)
13151315

1316-
// PlacementConditionType defines a specific condition of a resource placement.
1316+
// PerClusterPlacementConditionType defines a specific condition of a per cluster placement.
13171317
// +enum
1318-
type PlacementConditionType string
1318+
type PerClusterPlacementConditionType string
13191319

13201320
const (
1321-
// ResourceScheduledConditionType indicates whether we have successfully scheduled the selected resources.
1321+
// PerClusterScheduledConditionType indicates whether we have successfully scheduled the selected resources on a particular cluster.
13221322
// Its condition status can be one of the following:
13231323
// - "True" means we have successfully scheduled the resources to satisfy the placement requirement.
13241324
// - "False" means we didn't fully satisfy the placement requirement. We will fill the Message field.
1325-
ResourceScheduledConditionType PlacementConditionType = "Scheduled"
1325+
PerClusterScheduledConditionType PerClusterPlacementConditionType = "Scheduled"
13261326

1327-
// ResourceRolloutStartedConditionType indicates whether the selected resources start rolling out or
1328-
// not.
1327+
// PerClusterRolloutStartedConditionType indicates whether the selected resources start rolling out on that particular member cluster.
13291328
// Its condition status can be one of the following:
13301329
// - "True" means the selected resources successfully start rolling out in the target clusters.
13311330
// - "False" means the selected resources have not been rolled out in the target cluster yet to honor the rollout
13321331
// strategy configurations specified in the placement
13331332
// - "Unknown" means it is in the processing state.
1334-
ResourceRolloutStartedConditionType PlacementConditionType = "RolloutStarted"
1333+
PerClusterRolloutStartedConditionType PerClusterPlacementConditionType = "RolloutStarted"
13351334

1336-
// ResourceOverriddenConditionType indicates whether all the selected resources have been overridden successfully
1335+
// PerClusterOverriddenConditionType indicates whether all the selected resources have been overridden successfully
13371336
// before applying to the target cluster if there is any override defined.
13381337
// Its condition status can be one of the following:
13391338
// - "True" means all the selected resources are successfully overridden before applying to the target cluster or
13401339
// override is not needed if there is no override defined with the reason of NoOverrideSpecified.
13411340
// - "False" means some of them have failed.
13421341
// - "Unknown" means we haven't finished the override yet.
1343-
ResourceOverriddenConditionType PlacementConditionType = "Overridden"
1342+
PerClusterOverriddenConditionType PerClusterPlacementConditionType = "Overridden"
13441343

1345-
// ResourceWorkSynchronizedConditionType indicates whether we have created or updated the corresponding work object(s)
1346-
// under the per-cluster namespaces (i.e., fleet-member-<member-name>) which have the latest resources selected by
1344+
// PerClusterWorkSynchronizedConditionType indicates whether we have created or updated the corresponding work object(s)
1345+
// under that particular cluster namespaces (i.e., fleet-member-<member-name>) which have the latest resources selected by
13471346
// the placement.
13481347
// Its condition status can be one of the following:
13491348
// - "True" means we have successfully created the latest corresponding work(s) or updated the existing work(s) to
13501349
// the latest.
13511350
// - "False" means we have not created the latest corresponding work(s) or updated the existing work(s) to the latest
13521351
// yet.
13531352
// - "Unknown" means we haven't finished creating work yet.
1354-
ResourceWorkSynchronizedConditionType PlacementConditionType = "WorkSynchronized"
1353+
PerClusterWorkSynchronizedConditionType PerClusterPlacementConditionType = "WorkSynchronized"
13551354

1356-
// ResourcesAppliedConditionType indicates whether the selected member cluster has applied the selected resources locally.
1355+
// PerClusterAppliedConditionType indicates whether the selected member cluster has applied the selected resources.
13571356
// Its condition status can be one of the following:
13581357
// - "True" means all the selected resources are successfully applied to the target cluster.
13591358
// - "False" means some of them have failed.
13601359
// - "Unknown" means we haven't finished the apply yet.
1361-
ResourcesAppliedConditionType PlacementConditionType = "Applied"
1360+
PerClusterAppliedConditionType PerClusterPlacementConditionType = "Applied"
13621361

1363-
// ResourcesAvailableConditionType indicates whether the selected resources are available on the selected member cluster.
1362+
// PerClusterAvailableConditionType indicates whether the selected resources are available on the selected member cluster.
13641363
// Its condition status can be one of the following:
13651364
// - "True" means all the selected resources are available on the target cluster.
13661365
// - "False" means some of them are not available yet.
13671366
// - "Unknown" means we haven't finished the apply yet so that we cannot check the resource availability.
1368-
ResourcesAvailableConditionType PlacementConditionType = "Available"
1367+
PerClusterAvailableConditionType PerClusterPlacementConditionType = "Available"
13691368

13701369
// ResourceDiffReportedConditionType indicates whether Fleet has reported configuration
13711370
// differences between the desired states of resources as kept in the hub cluster and the
@@ -1376,7 +1375,7 @@ const (
13761375
// * False: Fleet has not yet reported the complete set of configuration differences on the
13771376
// member cluster, or an error has occurred.
13781377
// * Unknown: Fleet has not finished processing the diff reporting yet.
1379-
ResourcesDiffReportedConditionType PlacementConditionType = "DiffReported"
1378+
PerClusterDiffReportedConditionType PerClusterPlacementConditionType = "DiffReported"
13801379
)
13811380

13821381
// PlacementType identifies the type of placement.

apis/placement/v1beta1/zz_generated.deepcopy.go

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

pkg/controllers/clusterresourceplacement/controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ func (r *Reconciler) setPlacementStatus(
979979
// The undeleted resources on these old clusters could lead to failed synchronized or applied condition.
980980
// Today, we only track the resources progress if the same cluster is selected again.
981981
klog.V(2).InfoS("Resetting the resource placement status since scheduled condition is unknown", "placement", klog.KObj(placementObj))
982-
placementStatus.PlacementStatuses = []fleetv1beta1.ResourcePlacementStatus{}
982+
placementStatus.PlacementStatuses = []fleetv1beta1.PerClusterPlacementStatus{}
983983
return false, nil
984984
}
985985

@@ -991,7 +991,7 @@ func (r *Reconciler) setPlacementStatus(
991991
failedToScheduleClusterCount := calculateFailedToScheduleClusterCount(placementObj, selected, unselected)
992992

993993
// Prepare the resource placement status (status per cluster) in the placement status.
994-
allRPS := make([]fleetv1beta1.ResourcePlacementStatus, 0, len(latestSchedulingPolicySnapshot.GetPolicySnapshotStatus().ClusterDecisions))
994+
allRPS := make([]fleetv1beta1.PerClusterPlacementStatus, 0, len(latestSchedulingPolicySnapshot.GetPolicySnapshotStatus().ClusterDecisions))
995995

996996
// For clusters that have been selected, set the resource placement status based on the
997997
// respective resource binding status for each of them.
@@ -1049,7 +1049,7 @@ func (r *Reconciler) determineRolloutStateForPlacementWithExternalRolloutStrateg
10491049
ctx context.Context,
10501050
placementObj fleetv1beta1.PlacementObj,
10511051
selected []*fleetv1beta1.ClusterDecision,
1052-
allRPS []fleetv1beta1.ResourcePlacementStatus,
1052+
allRPS []fleetv1beta1.PerClusterPlacementStatus,
10531053
selectedResourceIDs []fleetv1beta1.ResourceIdentifier,
10541054
) (bool, error) {
10551055
if len(selected) == 0 {
@@ -1133,7 +1133,7 @@ func (r *Reconciler) determineRolloutStateForPlacementWithExternalRolloutStrateg
11331133
}
11341134

11351135
for i := range len(selected) {
1136-
rolloutStartedCond := meta.FindStatusCondition(allRPS[i].Conditions, string(fleetv1beta1.ResourceRolloutStartedConditionType))
1136+
rolloutStartedCond := meta.FindStatusCondition(allRPS[i].Conditions, string(fleetv1beta1.PerClusterRolloutStartedConditionType))
11371137
if !condition.IsConditionStatusTrue(rolloutStartedCond, placementObj.GetGeneration()) &&
11381138
!condition.IsConditionStatusFalse(rolloutStartedCond, placementObj.GetGeneration()) {
11391139
klog.V(2).InfoS("Placement has External rollout strategy and some cluster is in RolloutStarted Unknown state, set RolloutStarted condition to Unknown",

0 commit comments

Comments
 (0)