Skip to content

Commit

Permalink
Removing failover label from constants, filtering out duplicated reso…
Browse files Browse the repository at this point in the history
…urces

Signed-off-by: mszacillo <mszacillo@bloomberg.net>
  • Loading branch information
mszacillo committed Nov 5, 2024
1 parent 5dba54e commit 2d434bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions pkg/apis/work/v1alpha2/well_known_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ const (
// Additional options will be added here in the future.
DeletionProtectionLabelKey = "resourcetemplate.karmada.io/deletion-protected"
DeletionProtectionAlways = "Always"

// ResourceBindingFailoverLabel If a resource is failed over by karmada, this label will be attached
// to the rescheduled workload. The value will denote the type of failover that occurred, either cluster or application.
// This can be useful if applications are stateful and need to know when they have been failed over by Karmada,
// as opposed to being scheduled fresh.
ResourceBindingFailoverLabel = "resourcebinding.karmada.io/failover-type"
)

// Define eviction reasons.
Expand Down
6 changes: 6 additions & 0 deletions pkg/controllers/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ import (
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"

policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
workv1alpha2 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha2"
"github.com/karmada-io/karmada/pkg/util/helper"
)

// UpdateFailoverStatus adds a failoverHistoryItem to the failoverHistory field in the ResourceBinding.
func UpdateFailoverStatus(client client.Client, binding *workv1alpha2.ResourceBinding, clusters []string, failoverType workv1alpha2.FailoverReason) (err error) {
// If the resource is Duplicated, then it does not have a concept of failover. We skip attaching that status here.
placement := binding.Spec.Placement
if placement != nil && placement.ReplicaSchedulingType() == policyv1alpha1.ReplicaSchedulingTypeDuplicated {
return nil
}
klog.V(4).Infof("Updating failover status for ResourceBinding(%s/%s)", binding.Name, binding.Namespace)
err = retry.RetryOnConflict(retry.DefaultRetry, func() (err error) {
_, err = helper.UpdateStatus(context.Background(), client, binding, func() error {
Expand Down

0 comments on commit 2d434bd

Please sign in to comment.