Skip to content

Commit

Permalink
feat: rename crp conditions (Azure#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiying-lin authored Apr 16, 2024
1 parent 3bf1d3a commit 913d128
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 131 deletions.
10 changes: 5 additions & 5 deletions apis/placement/v1beta1/binding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ const (
// - "True" means the corresponding work CR is created in the target cluster's namespace.
// - "False" means the corresponding work CR is not created yet.
// - "Unknown" means it is unknown.
// TODO, will be replaced by "WorkCreated"
// TODO, will be replaced by "WorkSynchronized"
ResourceBindingBound ResourceBindingConditionType = "Bound"

// ResourceBindingWorkCreated indicates the work created condition of the given resources.
// ResourceBindingWorkSynchronized indicates the work synchronized condition of the given resources.
// Its condition status can be one of the following:
// - "True" means all corresponding works are created in the target cluster's namespace.
// - "False" means not all corresponding works are created in the target cluster's namespace yet.
// - "True" means all corresponding works are created or updated in the target cluster's namespace.
// - "False" means not all corresponding works are created or updated in the target cluster's namespace yet.
// - "Unknown" means it is unknown.
ResourceBindingWorkCreated ResourceBindingConditionType = "WorkCreated"
ResourceBindingWorkSynchronized ResourceBindingConditionType = "WorkSynchronized"

// ResourceBindingApplied indicates the applied condition of the given resources.
// Its condition status can be one of the following:
Expand Down
38 changes: 10 additions & 28 deletions apis/placement/v1beta1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ const (
// (i.e., fleet-member-<member-name>) on the hub cluster.
// - "False" means all the selected resources have not been synchronized under the per-cluster namespaces
// (i.e., fleet-member-<member-name>) on the hub cluster yet.
// To be deprecated, it will be replaced by ClusterResourcePlacementRolloutStarted and ClusterResourcePlacementWorkCreated
// To be deprecated, it will be replaced by ClusterResourcePlacementRolloutStarted and ClusterResourcePlacementWorkSynchronized
// conditions.
ClusterResourcePlacementSynchronizedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementSynchronized"

Expand All @@ -720,15 +720,15 @@ const (
// - "Unknown" means we haven't finished the override yet.
ClusterResourcePlacementOverriddenConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementOverridden"

// ClusterResourcePlacementWorkCreatedConditionType indicates whether the selected resources are created under
// the per-cluster namespaces (i.e., fleet-member-<member-name>) on the hub cluster.
// ClusterResourcePlacementWorkSynchronizedConditionType indicates whether the selected resources are created or updated
// under the per-cluster namespaces (i.e., fleet-member-<member-name>) on the hub cluster.
// Its condition status can be one of the following:
// - "True" means all the selected resources are successfully created under the per-cluster namespaces
// - "True" means all the selected resources are successfully created or updated under the per-cluster namespaces
// (i.e., fleet-member-<member-name>) on the hub cluster.
// - "False" means all the selected resources have not been created under the per-cluster namespaces
// - "False" means all the selected resources have not been created or updated under the per-cluster namespaces
// (i.e., fleet-member-<member-name>) on the hub cluster yet.
// - "Unknown" means we haven't started processing the work yet.
ClusterResourcePlacementWorkCreatedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementWorkCreated"
ClusterResourcePlacementWorkSynchronizedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementWorkSynchronized"

// ClusterResourcePlacementAppliedConditionType indicates whether all the selected member clusters have applied
// the selected resources locally.
Expand Down Expand Up @@ -758,24 +758,7 @@ const (
// Its condition status can be one of the following:
// - "True" means we have successfully scheduled the resources to satisfy the placement requirement.
// - "False" means we didn't fully satisfy the placement requirement. We will fill the Message field.
// TODO, use "Scheduled" instead.
ResourceScheduledConditionType ResourcePlacementConditionType = "ResourceScheduled"

// ResourceWorkSynchronizedConditionType indicates whether we have created or updated the corresponding work object(s)
// under the per-cluster namespaces (i.e., fleet-member-<member-name>) which have the latest resources selected by
// the placement.
// Its condition status can be one of the following:
// - "True" means we have successfully created the latest corresponding work(s) or updated the existing work(s) to
// the latest.
// - "False" means we have not created the latest corresponding work(s) or updated the existing work(s) to the latest
// yet.
// There are few possibilities:
// - In the processing state
// - Rollout controller has decided not to create or update the resources in this cluster for now to honor the
// rollout strategy configurations specified in the placement.
// - Work is not created/updated because of the unknown reasons.
// To be deprecated, it will be replaced by RolloutStarted and WorkCreated conditions.
ResourceWorkSynchronizedConditionType ResourcePlacementConditionType = "WorkSynchronized"
ResourceScheduledConditionType ResourcePlacementConditionType = "Scheduled"

// ResourceRolloutStartedConditionType indicates whether the selected resources start rolling out or
// not.
Expand All @@ -795,7 +778,7 @@ const (
// - "Unknown" means we haven't finished the override yet.
ResourceOverriddenConditionType ResourcePlacementConditionType = "Overridden"

// ResourceWorkCreatedConditionType indicates whether we have created or updated the corresponding work object(s)
// ResourceWorkSynchronizedConditionType indicates whether we have created or updated the corresponding work object(s)
// under the per-cluster namespaces (i.e., fleet-member-<member-name>) which have the latest resources selected by
// the placement.
// Its condition status can be one of the following:
Expand All @@ -804,15 +787,14 @@ const (
// - "False" means we have not created the latest corresponding work(s) or updated the existing work(s) to the latest
// yet.
// - "Unknown" means we haven't finished creating work yet.
ResourceWorkCreatedConditionType ResourcePlacementConditionType = "WorkCreated"
ResourceWorkSynchronizedConditionType ResourcePlacementConditionType = "WorkSynchronized"

// ResourcesAppliedConditionType indicates whether the selected member cluster has applied the selected resources locally.
// Its condition status can be one of the following:
// - "True" means all the selected resources are successfully applied to the target cluster.
// - "False" means some of them have failed.
// - "Unknown" means we haven't finished the apply yet.
// TODO: use "Applied" instead.
ResourcesAppliedConditionType ResourcePlacementConditionType = "ResourceApplied"
ResourcesAppliedConditionType ResourcePlacementConditionType = "Applied"

// ResourcesAvailableConditionType indicates whether the selected resources are available on the selected member cluster.
// Its condition status can be one of the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ var _ = Describe("Test ClusterResourceBinding Watcher - update status", Serial,
})

It("Should enqueue the clusterResourcePlacement name for reconciling, when clusterResourceBinding status changes - WorkCreated", func() {
validateWhenUpdateClusterResourceBindingStatusWithCondition(fleetv1beta1.ResourceBindingWorkCreated, crb.Generation, metav1.ConditionTrue, testReason1)
validateWhenUpdateClusterResourceBindingStatusWithCondition(fleetv1beta1.ResourceBindingWorkCreated, crb.Generation, metav1.ConditionFalse, testReason1)
validateWhenUpdateClusterResourceBindingStatusWithCondition(fleetv1beta1.ResourceBindingWorkSynchronized, crb.Generation, metav1.ConditionTrue, testReason1)
validateWhenUpdateClusterResourceBindingStatusWithCondition(fleetv1beta1.ResourceBindingWorkSynchronized, crb.Generation, metav1.ConditionFalse, testReason1)
})

It("Should enqueue the clusterResourcePlacement name for reconciling, when clusterResourceBinding status changes - Applied", func() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/clusterresourceplacement/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3220,7 +3220,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) {
},
{
Status: metav1.ConditionTrue,
Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType),
Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType),
ObservedGeneration: crpGeneration,
},
},
Expand Down Expand Up @@ -3289,7 +3289,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) {
},
{
Status: metav1.ConditionFalse,
Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType),
Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType),
ObservedGeneration: crpGeneration,
},
},
Expand All @@ -3315,7 +3315,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) {
},
{
Status: metav1.ConditionTrue,
Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType),
Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType),
ObservedGeneration: crpGeneration,
},
},
Expand Down Expand Up @@ -3351,7 +3351,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) {
},
{
Status: metav1.ConditionTrue,
Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType),
Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType),
ObservedGeneration: crpGeneration,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func (r *Reconciler) buildClusterResourceBindings(ctx context.Context, crp *flee
//
// RolloutStartedCondition resourceCondition = iota
// OverriddenCondition
// WorkCreatedCondition
// WorkSynchronizedCondition
// AppliedCondition
// AvailableCondition
// TotalCondition
Expand Down
Loading

0 comments on commit 913d128

Please sign in to comment.