@@ -289,6 +289,57 @@ type RolloutStrategy struct {
289289 // Rolling update config params. Present only if RolloutStrategyType = RollingUpdate.
290290 // +optional
291291 RollingUpdate * RollingUpdateConfig `json:"rollingUpdate,omitempty"`
292+
293+ // ApplyStrategy describes how to resolve the conflict if the resource to be placed already exists in the target cluster
294+ // and is owned by other appliers.
295+ // +optional
296+ ApplyStrategy * ApplyStrategy `json:"applyStrategy,omitempty"`
297+ }
298+
299+ // ApplyStrategy describes how to resolve the conflict if the resource to be placed already exists in the target cluster
300+ // and is owned by other appliers.
301+ // Note: If multiple CRPs try to place the same resource with different apply strategy, the later ones will fail with the
302+ // reason ApplyConflictBetweenPlacements.
303+ type ApplyStrategy struct {
304+ // Type defines the type of strategy to use. Default to FailIfExists.
305+ // +kubebuilder:default=FailIfExists
306+ // +kubebuilder:validation:Enum=FailIfExists;ServerSideApply
307+ // +optional
308+ Type ApplyStrategyType `json:"type,omitempty"`
309+
310+ // ServerSideApplyConfig defines the configuration for server side apply. It is honored only when type is ServerSideApply.
311+ // +optional
312+ ServerSideApplyConfig * ServerSideApplyConfig `json:"serverSideApplyConfig,omitempty"`
313+ }
314+
315+ // ApplyStrategyType describes the type of the strategy used to resolve the conflict if the resource to be placed already
316+ // exists in the target cluster and is owned by other appliers.
317+ // +enum
318+ type ApplyStrategyType string
319+
320+ const (
321+ // ApplyStrategyTypeFailIfExists will fail to apply a resource if it already exists in the target cluster and is owned
322+ // by other appliers.
323+ ApplyStrategyTypeFailIfExists ApplyStrategyType = "FailIfExists"
324+
325+ // ApplyStrategyTypeServerSideApply will use server-side apply to resolve conflicts between the resource to be placed
326+ // and the existing resource in the target cluster.
327+ // Details: https://kubernetes.io/docs/reference/using-api/server-side-apply
328+ ApplyStrategyTypeServerSideApply ApplyStrategyType = "ServerSideApply"
329+ )
330+
331+ // ServerSideApplyConfig defines the configuration for server side apply.
332+ // Details: https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts
333+ type ServerSideApplyConfig struct {
334+ // Force represents to force apply to succeed when resolving the conflicts
335+ // For any conflicting fields,
336+ // - If true, use the values from the resource to be applied to overwrite the values of the existing resource in the
337+ // target cluster, as well as take over ownership of such fields.
338+ // - If false, apply will fail with the reason ApplyConflictWithOtherApplier.
339+ //
340+ // For non-conflicting fields, values stay unchanged and ownership are shared between appliers.
341+ // +optional
342+ ForceConflicts bool `json:"force"`
292343}
293344
294345// +enum
@@ -438,6 +489,16 @@ type ResourcePlacementStatus struct {
438489 // +optional
439490 ClusterName string `json:"clusterName,omitempty"`
440491
492+ // ApplicableResourceOverrides contains a list of applicable ResourceOverride snapshots associated with the selected
493+ // resources.
494+ // +optional
495+ ApplicableResourceOverrides []NamespacedName `json:"applicableResourceOverrides,omitempty"`
496+
497+ // ApplicableClusterResourceOverrides contains a list of applicable ClusterResourceOverride snapshots associated with
498+ // the selected resources.
499+ // +optional
500+ ApplicableClusterResourceOverrides []string `json:"applicableClusterResourceOverrides,omitempty"`
501+
441502 // +kubebuilder:validation:MaxItems=100
442503
443504 // FailedPlacements is a list of all the resources failed to be placed to the given cluster.
@@ -511,8 +572,35 @@ const (
511572 // (i.e., fleet-member-<member-name>) on the hub cluster.
512573 // - "False" means all the selected resources have not been synchronized under the per-cluster namespaces
513574 // (i.e., fleet-member-<member-name>) on the hub cluster yet.
575+ // To be deprecated, it will be replaced by ClusterResourcePlacementRolloutStarted and ClusterResourcePlacementWorkCreated
576+ // conditions.
514577 ClusterResourcePlacementSynchronizedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementSynchronized"
515578
579+ // ClusterResourcePlacementRolloutStartedConditionType indicates whether the selected resources start rolling out or
580+ // not.
581+ // Its condition status can be one of the following:
582+ // - "True" means the selected resources successfully start rolling out in all scheduled clusters.
583+ // - "False" means the selected resources have not been rolled out in all scheduled clusters yet.
584+ ClusterResourcePlacementRolloutStartedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementRolloutStarted"
585+
586+ // ClusterResourcePlacementOverriddenConditionType indicates whether all the selected resources have been overridden
587+ // successfully before applying to the target cluster.
588+ // Its condition status can be one of the following:
589+ // - "True" means all the selected resources are successfully overridden before applying to the target cluster or
590+ // override is not needed if there is no override defined with the reason of NoOverrideSpecified.
591+ // - "False" means some of them have failed. We will place some detailed failure in the FailedResourcePlacement array.
592+ // - "Unknown" means we haven't finished the override yet.
593+ ClusterResourcePlacementOverriddenConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementOverridden"
594+
595+ // ClusterResourcePlacementWorkCreatedConditionType indicates whether the selected resources are created under
596+ // the per-cluster namespaces (i.e., fleet-member-<member-name>) on the hub cluster.
597+ // Its condition status can be one of the following:
598+ // - "True" means all the selected resources are successfully created under the per-cluster namespaces
599+ // (i.e., fleet-member-<member-name>) on the hub cluster.
600+ // - "False" means all the selected resources have not been created under the per-cluster namespaces
601+ // (i.e., fleet-member-<member-name>) on the hub cluster yet.
602+ ClusterResourcePlacementWorkCreatedConditionType ClusterResourcePlacementConditionType = "ClusterResourcePlacementWorkCreated"
603+
516604 // ClusterResourcePlacementAppliedConditionType indicates whether all the selected member clusters have applied
517605 // the selected resources locally.
518606 // Its condition status can be one of the following:
@@ -532,6 +620,7 @@ const (
532620 // Its condition status can be one of the following:
533621 // - "True" means we have successfully scheduled the resources to satisfy the placement requirement.
534622 // - "False" means we didn't fully satisfy the placement requirement. We will fill the Message field.
623+ // TODO, use "Scheduled" instead.
535624 ResourceScheduledConditionType ResourcePlacementConditionType = "ResourceScheduled"
536625
537626 // ResourceWorkSynchronizedConditionType indicates whether we have created or updated the corresponding work object(s)
@@ -547,13 +636,44 @@ const (
547636 // - Rollout controller has decided not to create or update the resources in this cluster for now to honor the
548637 // rollout strategy configurations specified in the placement.
549638 // - Work is not created/updated because of the unknown reasons.
639+ // To be deprecated, it will be replaced by RolloutStarted and WorkCreated conditions.
550640 ResourceWorkSynchronizedConditionType ResourcePlacementConditionType = "WorkSynchronized"
551641
642+ // ResourceRolloutStartedConditionType indicates whether the selected resources start rolling out or
643+ // not.
644+ // Its condition status can be one of the following:
645+ // - "True" means the selected resources successfully start rolling out in the target clusters.
646+ // - "False" means the selected resources have not been rolled out in the target cluster yet to honor the rollout
647+ // strategy configurations specified in the placement
648+ // - "Unknown" means it is in the processing state.
649+ ResourceRolloutStartedConditionType ResourcePlacementConditionType = "RolloutStarted"
650+
651+ // ResourceOverriddenConditionType indicates whether all the selected resources have been overridden successfully
652+ // before applying to the target cluster if there is any override defined.
653+ // Its condition status can be one of the following:
654+ // - "True" means all the selected resources are successfully overridden before applying to the target cluster or
655+ // override is not needed if there is no override defined with the reason of NoOverrideSpecified.
656+ // - "False" means some of them have failed.
657+ // - "Unknown" means we haven't finished the override yet.
658+ ResourceOverriddenConditionType ResourcePlacementConditionType = "Overridden"
659+
660+ // ResourceWorkCreatedConditionType indicates whether we have created or updated the corresponding work object(s)
661+ // under the per-cluster namespaces (i.e., fleet-member-<member-name>) which have the latest resources selected by
662+ // the placement.
663+ // Its condition status can be one of the following:
664+ // - "True" means we have successfully created the latest corresponding work(s) or updated the existing work(s) to
665+ // the latest.
666+ // - "False" means we have not created the latest corresponding work(s) or updated the existing work(s) to the latest
667+ // yet.
668+ // - "Unknown" means we haven't finished creating work yet.
669+ ResourceWorkCreatedConditionType ResourcePlacementConditionType = "WorkCreated"
670+
552671 // ResourcesAppliedConditionType indicates whether the selected member cluster has applied the selected resources locally.
553672 // Its condition status can be one of the following:
554673 // - "True" means all the selected resources are successfully applied to the target cluster.
555674 // - "False" means some of them have failed.
556675 // - "Unknown" means we haven't finished the apply yet.
676+ // TODO: use "Applied" instead.
557677 ResourcesAppliedConditionType ResourcePlacementConditionType = "ResourceApplied"
558678)
559679
0 commit comments