Skip to content

Commit

Permalink
Rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelawyu committed Jan 7, 2025
1 parent 253cec3 commit e550027
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ func (r *Reconciler) pickBindingsToRoll(ctx context.Context, allBindings []*flee
}
// The binding needs update if it's not pointing to the latest resource resourceBinding or the overrides.
if binding.Spec.ResourceSnapshotName != latestResourceSnapshot.Name || !equality.Semantic.DeepEqual(binding.Spec.ClusterResourceOverrideSnapshots, cro) || !equality.Semantic.DeepEqual(binding.Spec.ResourceOverrideSnapshots, ro) {
updateInfo := createUpdateInfo(binding, crp, latestResourceSnapshot, cro, ro)
updateInfo := createUpdateInfo(binding, latestResourceSnapshot, cro, ro)
if bindingFailed {
// the binding has been applied but failed to apply, we can safely update it to latest resources without affecting max unavailable count
applyFailedUpdateCandidates = append(applyFailedUpdateCandidates, updateInfo)
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/rollout/controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ var _ = Describe("Test the rollout Controller", func() {
It("should push apply strategy changes to all the bindings (if applicable)", func() {
// Create a CRP.
targetClusterCount := int32(3)
rolloutCRP = clusterResourcePlacementForTest(testCRPName, createPlacementPolicyForTest(fleetv1beta1.PickNPlacementType, targetClusterCount))
rolloutCRP = clusterResourcePlacementForTest(
testCRPName,
createPlacementPolicyForTest(fleetv1beta1.PickNPlacementType, targetClusterCount),
createPlacementRolloutStrategyForTest(fleetv1beta1.RollingUpdateRolloutStrategyType, generateDefaultRollingUpdateConfig(), nil))
Expect(k8sClient.Create(ctx, rolloutCRP)).Should(Succeed(), "Failed to create CRP")

// Create a master cluster resource snapshot.
Expand Down
5 changes: 3 additions & 2 deletions pkg/controllers/rollout/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/util/workqueue"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -42,6 +41,8 @@ var (
cluster5 = "cluster-5"
cluster6 = "cluster-6"

crpName = "test-crp"

cmpOptions = []cmp.Option{
cmp.AllowUnexported(toBeUpdatedBinding{}),
cmpopts.EquateEmpty(),
Expand Down Expand Up @@ -2798,7 +2799,7 @@ func TestProcessApplyStrategyUpdates(t *testing.T) {
}

fakeClient := fake.NewClientBuilder().
WithScheme(scheme.Scheme).
WithScheme(serviceScheme(t)).
WithObjects(objs...).
Build()
r := &Reconciler{
Expand Down
10 changes: 10 additions & 0 deletions pkg/controllers/rollout/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/manager"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1"
fleetv1alpha1 "go.goms.io/fleet/apis/placement/v1alpha1"
fleetv1beta1 "go.goms.io/fleet/apis/placement/v1beta1"
)

var (
Expand Down Expand Up @@ -66,6 +70,12 @@ var _ = BeforeSuite(func() {
Expect(err).Should(Succeed())
Expect(cfg).NotTo(BeNil())

//+kubebuilder:scaffold:scheme
By("Set all the customized scheme")
Expect(fleetv1beta1.AddToScheme(scheme.Scheme)).Should(Succeed())
Expect(clusterv1beta1.AddToScheme(scheme.Scheme)).Should(Succeed())
Expect(fleetv1alpha1.AddToScheme(scheme.Scheme)).Should(Succeed())

By("starting the controller manager")
klog.InitFlags(flag.CommandLine)
flag.Parse()
Expand Down

0 comments on commit e550027

Please sign in to comment.