Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement stagedUpdateRun initialization #975

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pkg/controllers/rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"go.goms.io/fleet/pkg/utils/controller"
"go.goms.io/fleet/pkg/utils/defaulter"
"go.goms.io/fleet/pkg/utils/informer"
"go.goms.io/fleet/pkg/utils/overrider"
)

// Reconciler recomputes the cluster resource binding.
Expand Down Expand Up @@ -126,7 +127,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req runtime.Request) (runtim
// fill out all the default values for CRP just in case the mutation webhook is not enabled.
defaulter.SetDefaultsClusterResourcePlacement(&crp)

matchedCRO, matchedRO, err := r.fetchAllMatchingOverridesForResourceSnapshot(ctx, crp.Name, latestResourceSnapshot)
matchedCRO, matchedRO, err := overrider.FetchAllMatchingOverridesForResourceSnapshot(ctx, r.Client, r.InformerManager, crp.Name, latestResourceSnapshot)
if err != nil {
klog.ErrorS(err, "Failed to find all matching overrides for the clusterResourcePlacement", "clusterResourcePlacement", crpName)
return runtime.Result{}, err
Expand Down Expand Up @@ -371,8 +372,8 @@ func (r *Reconciler) pickBindingsToRoll(ctx context.Context, allBindings []*flee
// the scheduler has picked a cluster for this binding
schedulerTargetedBinds = append(schedulerTargetedBinds, binding)
// this binding has not been bound yet, so it is an update candidate
// pickFromResourceMatchedOverridesForTargetCluster always returns the ordered list of the overrides.
cro, ro, err := r.pickFromResourceMatchedOverridesForTargetCluster(ctx, binding, matchedCROs, matchedROs)
// PickFromResourceMatchedOverridesForTargetCluster always returns the ordered list of the overrides.
cro, ro, err := overrider.PickFromResourceMatchedOverridesForTargetCluster(ctx, r.Client, binding.Spec.TargetCluster, matchedCROs, matchedROs)
if err != nil {
return nil, nil, false, minWaitTime, err
}
Expand All @@ -396,8 +397,8 @@ func (r *Reconciler) pickBindingsToRoll(ctx context.Context, allBindings []*flee
} else {
canBeReadyBindings = append(canBeReadyBindings, binding)
}
// pickFromResourceMatchedOverridesForTargetCluster always returns the ordered list of the overrides.
cro, ro, err := r.pickFromResourceMatchedOverridesForTargetCluster(ctx, binding, matchedCROs, matchedROs)
// PickFromResourceMatchedOverridesForTargetCluster always returns the ordered list of the overrides.
cro, ro, err := overrider.PickFromResourceMatchedOverridesForTargetCluster(ctx, r.Client, binding.Spec.TargetCluster, matchedCROs, matchedROs)
if err != nil {
return nil, nil, false, 0, err
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/controllers/rollout/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/google/go-cmp/cmp/cmpopts"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/util/workqueue"
"k8s.io/utils/ptr"
Expand Down Expand Up @@ -64,6 +65,20 @@ var (
}
)

func serviceScheme(t *testing.T) *runtime.Scheme {
scheme := runtime.NewScheme()
if err := fleetv1beta1.AddToScheme(scheme); err != nil {
t.Fatalf("Failed to add placement v1beta1 scheme: %v", err)
}
if err := clusterv1beta1.AddToScheme(scheme); err != nil {
t.Fatalf("Failed to add cluster v1beta1 scheme: %v", err)
}
if err := fleetv1alpha1.AddToScheme(scheme); err != nil {
t.Fatalf("Failed to add placement v1alpha1 scheme: %v", err)
}
return scheme
}

func TestReconcilerHandleResourceSnapshot(t *testing.T) {
tests := map[string]struct {
snapshot client.Object
Expand Down
208 changes: 0 additions & 208 deletions pkg/controllers/rollout/override.go

This file was deleted.

Loading
Loading