From 913d128702d65078a4b67a892cfbf41a7dfeec14 Mon Sep 17 00:00:00 2001 From: Zhiying Lin <54013513+zhiying-lin@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:12:19 +0800 Subject: [PATCH] feat: rename crp conditions (#759) --- apis/placement/v1beta1/binding_types.go | 10 +- .../v1beta1/clusterresourceplacement_types.go | 38 ++---- .../watcher_integration_test.go | 4 +- .../controller_test.go | 8 +- .../placement_status.go | 2 +- .../placement_status_test.go | 120 +++++++++--------- pkg/controllers/workgenerator/controller.go | 4 +- .../controller_integration_test.go | 14 +- pkg/utils/condition/condition.go | 45 +++---- 9 files changed, 114 insertions(+), 131 deletions(-) diff --git a/apis/placement/v1beta1/binding_types.go b/apis/placement/v1beta1/binding_types.go index 27ffd55f5..e355f23ec 100644 --- a/apis/placement/v1beta1/binding_types.go +++ b/apis/placement/v1beta1/binding_types.go @@ -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: diff --git a/apis/placement/v1beta1/clusterresourceplacement_types.go b/apis/placement/v1beta1/clusterresourceplacement_types.go index e13e90b4a..5ccf90acf 100644 --- a/apis/placement/v1beta1/clusterresourceplacement_types.go +++ b/apis/placement/v1beta1/clusterresourceplacement_types.go @@ -699,7 +699,7 @@ const ( // (i.e., fleet-member-) on the hub cluster. // - "False" means all the selected resources have not been synchronized under the per-cluster namespaces // (i.e., fleet-member-) 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" @@ -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-) on the hub cluster. + // ClusterResourcePlacementWorkSynchronizedConditionType indicates whether the selected resources are created or updated + // under the per-cluster namespaces (i.e., fleet-member-) 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-) 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-) 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. @@ -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-) 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. @@ -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-) which have the latest resources selected by // the placement. // Its condition status can be one of the following: @@ -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: diff --git a/pkg/controllers/clusterresourcebindingwatcher/watcher_integration_test.go b/pkg/controllers/clusterresourcebindingwatcher/watcher_integration_test.go index e2d100182..5c7b1ca20 100644 --- a/pkg/controllers/clusterresourcebindingwatcher/watcher_integration_test.go +++ b/pkg/controllers/clusterresourcebindingwatcher/watcher_integration_test.go @@ -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() { diff --git a/pkg/controllers/clusterresourceplacement/controller_test.go b/pkg/controllers/clusterresourceplacement/controller_test.go index 123bf00ef..042e1bd5b 100644 --- a/pkg/controllers/clusterresourceplacement/controller_test.go +++ b/pkg/controllers/clusterresourceplacement/controller_test.go @@ -3220,7 +3220,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), ObservedGeneration: crpGeneration, }, }, @@ -3289,7 +3289,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) { }, { Status: metav1.ConditionFalse, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), ObservedGeneration: crpGeneration, }, }, @@ -3315,7 +3315,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), ObservedGeneration: crpGeneration, }, }, @@ -3351,7 +3351,7 @@ func TestIsRolloutComplete_withNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), ObservedGeneration: crpGeneration, }, }, diff --git a/pkg/controllers/clusterresourceplacement/placement_status.go b/pkg/controllers/clusterresourceplacement/placement_status.go index acf4593f4..0e3b443da 100644 --- a/pkg/controllers/clusterresourceplacement/placement_status.go +++ b/pkg/controllers/clusterresourceplacement/placement_status.go @@ -500,7 +500,7 @@ func (r *Reconciler) buildClusterResourceBindings(ctx context.Context, crp *flee // // RolloutStartedCondition resourceCondition = iota // OverriddenCondition -// WorkCreatedCondition +// WorkSynchronizedCondition // AppliedCondition // AvailableCondition // TotalCondition diff --git a/pkg/controllers/clusterresourceplacement/placement_status_test.go b/pkg/controllers/clusterresourceplacement/placement_status_test.go index 6fd020bcf..22665d996 100644 --- a/pkg/controllers/clusterresourceplacement/placement_status_test.go +++ b/pkg/controllers/clusterresourceplacement/placement_status_test.go @@ -3312,8 +3312,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -3374,8 +3374,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -3431,8 +3431,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -3600,8 +3600,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedUnknownReason, ObservedGeneration: 1, }, }, @@ -3637,8 +3637,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, }, @@ -3673,8 +3673,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, }, @@ -3797,8 +3797,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedUnknownReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -3856,8 +3856,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4114,8 +4114,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -4166,8 +4166,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -4312,8 +4312,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4385,8 +4385,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4442,8 +4442,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4535,8 +4535,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -4779,8 +4779,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4859,8 +4859,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, LastTransitionTime: metav1.NewTime(currentTime), }, @@ -4915,8 +4915,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, LastTransitionTime: oldTransitionTime, }, @@ -4972,8 +4972,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, LastTransitionTime: oldTransitionTime, }, @@ -5074,8 +5074,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, LastTransitionTime: oldTransitionTime, }, @@ -5121,8 +5121,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, LastTransitionTime: oldTransitionTime, }, @@ -5219,8 +5219,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -5271,8 +5271,8 @@ func TestSetPlacementStatus_useNewConditions(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -6769,8 +6769,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -6834,8 +6834,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, }, }, @@ -6982,8 +6982,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedUnknownReason, ObservedGeneration: 1, }, }, @@ -7021,8 +7021,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedUnknownReason, ObservedGeneration: crpGeneration, }, }, @@ -7066,8 +7066,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -7173,8 +7173,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, }, }, @@ -7218,8 +7218,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: 1, }, { @@ -7347,8 +7347,8 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) { }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: condition.WorkCreatedReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: condition.WorkSynchronizedReason, ObservedGeneration: crpGeneration, }, }, diff --git a/pkg/controllers/workgenerator/controller.go b/pkg/controllers/workgenerator/controller.go index 453c74aa6..6d65b4891 100644 --- a/pkg/controllers/workgenerator/controller.go +++ b/pkg/controllers/workgenerator/controller.go @@ -175,7 +175,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req controllerruntime.Reques }) resourceBinding.SetConditions(metav1.Condition{ Status: metav1.ConditionFalse, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), Reason: syncWorkFailedReason, Message: fmt.Sprintf("Failed to sychronize the work to the latest: %s", errorMessage), ObservedGeneration: resourceBinding.Generation, @@ -191,7 +191,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req controllerruntime.Reques }) resourceBinding.SetConditions(metav1.Condition{ Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ResourceBindingWorkCreated), + Type: string(fleetv1beta1.ResourceBindingWorkSynchronized), Reason: allWorkSyncedReason, ObservedGeneration: resourceBinding.Generation, Message: "All of the works are synchronized to the latest", diff --git a/pkg/controllers/workgenerator/controller_integration_test.go b/pkg/controllers/workgenerator/controller_integration_test.go index 08bb50198..c63926703 100644 --- a/pkg/controllers/workgenerator/controller_integration_test.go +++ b/pkg/controllers/workgenerator/controller_integration_test.go @@ -273,7 +273,7 @@ var _ = Describe("Test Work Generator Controller", func() { } // only check the work created status as the applied status reason changes depends on where the reconcile logic is return condition.IsConditionStatusTrue( - meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkCreated)), binding.GetGeneration()) + meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkSynchronized)), binding.GetGeneration()) }, timeout, interval).Should(BeTrue(), fmt.Sprintf("binding(%s) condition should be true", binding.Name)) // check the work is created by now work := placementv1beta1.Work{} @@ -491,7 +491,7 @@ var _ = Describe("Test Work Generator Controller", func() { } // only check the work created status as the applied status reason changes depends on where the reconcile logic is return condition.IsConditionStatusTrue( - meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkCreated)), binding.GetGeneration()) + meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkSynchronized)), binding.GetGeneration()) }, timeout, interval).Should(BeTrue(), fmt.Sprintf("binding(%s) condition should be true", binding.Name)) By(fmt.Sprintf("resource binding %s is reconciled", binding.Name)) // check the work that contains none enveloped object is updated @@ -596,7 +596,7 @@ var _ = Describe("Test Work Generator Controller", func() { } // only check the work created status as the applied status reason changes depends on where the reconcile logic is return condition.IsConditionStatusTrue( - meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkCreated)), binding.GetGeneration()) + meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkSynchronized)), binding.GetGeneration()) }, timeout, interval).Should(BeTrue(), fmt.Sprintf("binding(%s) condition should be true", binding.Name)) By(fmt.Sprintf("resource binding %s is reconciled", binding.Name)) // check the enveloped work is deleted @@ -963,7 +963,7 @@ var _ = Describe("Test Work Generator Controller", func() { } // only check the work created status as the applied status reason changes depends on where the reconcile logic is return condition.IsConditionStatusTrue( - meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkCreated)), binding.GetGeneration()) + meta.FindStatusCondition(binding.Status.Conditions, string(placementv1beta1.ResourceBindingWorkSynchronized)), binding.GetGeneration()) }, timeout, interval).Should(BeTrue(), fmt.Sprintf("binding(%s) condition should be true", binding.Name)) // check the work is created by now work := placementv1beta1.Work{} @@ -1214,7 +1214,7 @@ func verifyBindingStatusSyncedNotApplied(binding *placementv1beta1.ClusterResour ObservedGeneration: binding.GetGeneration(), }, { - Type: string(placementv1beta1.ResourceBindingWorkCreated), + Type: string(placementv1beta1.ResourceBindingWorkSynchronized), Status: metav1.ConditionTrue, Reason: allWorkSyncedReason, ObservedGeneration: binding.GetGeneration(), @@ -1253,7 +1253,7 @@ func verifyBindStatusAppliedNotAvailable(binding *placementv1beta1.ClusterResour ObservedGeneration: binding.GetGeneration(), }, { - Type: string(placementv1beta1.ResourceBindingWorkCreated), + Type: string(placementv1beta1.ResourceBindingWorkSynchronized), Status: metav1.ConditionTrue, Reason: allWorkSyncedReason, ObservedGeneration: binding.GetGeneration(), @@ -1298,7 +1298,7 @@ func verifyBindStatusAvail(binding *placementv1beta1.ClusterResourceBinding, has ObservedGeneration: binding.GetGeneration(), }, { - Type: string(placementv1beta1.ResourceBindingWorkCreated), + Type: string(placementv1beta1.ResourceBindingWorkSynchronized), Status: metav1.ConditionTrue, Reason: allWorkSyncedReason, ObservedGeneration: binding.GetGeneration(), diff --git a/pkg/utils/condition/condition.go b/pkg/utils/condition/condition.go index cd07da9cc..1c3cd9a46 100644 --- a/pkg/utils/condition/condition.go +++ b/pkg/utils/condition/condition.go @@ -41,16 +41,17 @@ const ( // OverriddenSucceededReason is the reason string of placement condition when the selected resources are overridden successfully. OverriddenSucceededReason = "OverriddenSucceeded" - // WorkCreatedUnknownReason is the reason string of placement condition when the work is pending to be created. - WorkCreatedUnknownReason = "WorkCreatedUnknown" + // WorkSynchronizedUnknownReason is the reason string of placement condition when the work is pending to be created + // or updated. + WorkSynchronizedUnknownReason = "WorkSynchronizedUnknown" - // WorkNotCreatedYetReason is the reason string of placement condition when not all corresponding works are created - // in the target cluster's namespace yet. - WorkNotCreatedYetReason = "WorkNotCreatedYet" + // WorkNotSynchronizedYetReason is the reason string of placement condition when not all corresponding works are created + // or updated in the target cluster's namespace yet. + WorkNotSynchronizedYetReason = "WorkNotSynchronizedYet" - // WorkCreatedReason is the reason string of placement condition when all corresponding works are created in the target - // cluster's namespace successfully. - WorkCreatedReason = "OverriddenSucceeded" + // WorkSynchronizedReason is the reason string of placement condition when all corresponding works are created or updated + // in the target cluster's namespace successfully. + WorkSynchronizedReason = "WorkSynchronized" // ApplyPendingReason is the reason string of placement condition when the selected resources are pending to apply. ApplyPendingReason = "ApplyPending" @@ -121,7 +122,7 @@ type resourceCondition int const ( RolloutStartedCondition resourceCondition = iota OverriddenCondition - WorkCreatedCondition + WorkSynchronizedCondition AppliedCondition AvailableCondition TotalCondition @@ -131,7 +132,7 @@ func (c resourceCondition) EventReasonForTrue() string { return []string{ "PlacementRolloutStarted", "PlacementOverriddenSucceeded", - "PlacementWorkCreated", + "PlacementWorkSynchronized", "PlacementApplied", "PlacementAvailable", }[c] @@ -141,7 +142,7 @@ func (c resourceCondition) EventMessageForTrue() string { return []string{ "Started rolling out the latest resources", "Placement has been successfully overridden", - "Work(s) have been created successfully for the selected cluster(s)", + "Work(s) have been created or updated successfully for the selected cluster(s)", "Resources have been applied to the selected cluster(s)", "Resources are available on the selected cluster(s)", }[c] @@ -152,7 +153,7 @@ func (c resourceCondition) ResourcePlacementConditionType() fleetv1beta1.Resourc return []fleetv1beta1.ResourcePlacementConditionType{ fleetv1beta1.ResourceRolloutStartedConditionType, fleetv1beta1.ResourceOverriddenConditionType, - fleetv1beta1.ResourceWorkCreatedConditionType, + fleetv1beta1.ResourceWorkSynchronizedConditionType, fleetv1beta1.ResourcesAppliedConditionType, fleetv1beta1.ResourcesAvailableConditionType, }[c] @@ -163,7 +164,7 @@ func (c resourceCondition) ResourceBindingConditionType() fleetv1beta1.ResourceB return []fleetv1beta1.ResourceBindingConditionType{ fleetv1beta1.ResourceBindingRolloutStarted, fleetv1beta1.ResourceBindingOverridden, - fleetv1beta1.ResourceBindingWorkCreated, + fleetv1beta1.ResourceBindingWorkSynchronized, fleetv1beta1.ResourceBindingApplied, fleetv1beta1.ResourceBindingAvailable, }[c] @@ -174,7 +175,7 @@ func (c resourceCondition) ClusterResourcePlacementConditionType() fleetv1beta1. return []fleetv1beta1.ClusterResourcePlacementConditionType{ fleetv1beta1.ClusterResourcePlacementRolloutStartedConditionType, fleetv1beta1.ClusterResourcePlacementOverriddenConditionType, - fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType, + fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType, fleetv1beta1.ClusterResourcePlacementAppliedConditionType, fleetv1beta1.ClusterResourcePlacementAvailableConditionType, }[c] @@ -199,8 +200,8 @@ func (c resourceCondition) UnknownResourceConditionPerCluster(generation int64) }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ResourceWorkCreatedConditionType), - Reason: WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ResourceWorkSynchronizedConditionType), + Reason: WorkSynchronizedUnknownReason, Message: "In the process of creating or updating the work object(s) in the hub cluster", ObservedGeneration: generation, }, @@ -240,8 +241,8 @@ func (c resourceCondition) UnknownClusterResourcePlacementCondition(generation i }, { Status: metav1.ConditionUnknown, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: WorkCreatedUnknownReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: WorkSynchronizedUnknownReason, Message: fmt.Sprintf("There are still %d cluster(s) in the process of creating or updating the work object(s) in the hub cluster", clusterCount), ObservedGeneration: generation, }, @@ -281,8 +282,8 @@ func (c resourceCondition) FalseClusterResourcePlacementCondition(generation int }, { Status: metav1.ConditionFalse, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: WorkNotCreatedYetReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: WorkNotSynchronizedYetReason, Message: fmt.Sprintf("There are %d cluster(s) which have not finished creating or updating work(s) yet", clusterCount), ObservedGeneration: generation, }, @@ -322,8 +323,8 @@ func (c resourceCondition) TrueClusterResourcePlacementCondition(generation int6 }, { Status: metav1.ConditionTrue, - Type: string(fleetv1beta1.ClusterResourcePlacementWorkCreatedConditionType), - Reason: WorkCreatedReason, + Type: string(fleetv1beta1.ClusterResourcePlacementWorkSynchronizedConditionType), + Reason: WorkSynchronizedReason, Message: fmt.Sprintf("Works(s) are succcesfully created or updated in the %d target clusters' namespaces", clusterCount), ObservedGeneration: generation, },