mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-08-23 22:26:49 +00:00
Remove checking leases on hub (#901)
Scorecard supply-chain security / Scorecard analysis (push) Failing after 55s
Post / images (amd64) (push) Failing after 5m16s
Post / images (arm64) (push) Failing after 5m18s
Post / image manifest (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 22m35s
Scorecard supply-chain security / Scorecard analysis (push) Failing after 55s
Post / images (amd64) (push) Failing after 5m16s
Post / images (arm64) (push) Failing after 5m18s
Post / image manifest (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 22m35s
Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
@@ -37,7 +37,6 @@ type managedClusterAddOnLeaseController struct {
|
||||
patcher patcher.Patcher[
|
||||
*addonv1alpha1.ManagedClusterAddOn, addonv1alpha1.ManagedClusterAddOnSpec, addonv1alpha1.ManagedClusterAddOnStatus]
|
||||
addOnLister addonlisterv1alpha1.ManagedClusterAddOnLister
|
||||
hubLeaseClient coordv1client.CoordinationV1Interface
|
||||
managementLeaseClient coordv1client.CoordinationV1Interface
|
||||
spokeLeaseClient coordv1client.CoordinationV1Interface
|
||||
}
|
||||
@@ -46,7 +45,6 @@ type managedClusterAddOnLeaseController struct {
|
||||
func NewManagedClusterAddOnLeaseController(clusterName string,
|
||||
addOnClient addonclient.Interface,
|
||||
addOnInformer addoninformerv1alpha1.ManagedClusterAddOnInformer,
|
||||
hubLeaseClient coordv1client.CoordinationV1Interface,
|
||||
managementLeaseClient coordv1client.CoordinationV1Interface,
|
||||
spokeLeaseClient coordv1client.CoordinationV1Interface,
|
||||
resyncInterval time.Duration,
|
||||
@@ -58,7 +56,6 @@ func NewManagedClusterAddOnLeaseController(clusterName string,
|
||||
*addonv1alpha1.ManagedClusterAddOn, addonv1alpha1.ManagedClusterAddOnSpec, addonv1alpha1.ManagedClusterAddOnStatus](
|
||||
addOnClient.AddonV1alpha1().ManagedClusterAddOns(clusterName)),
|
||||
addOnLister: addOnInformer.Lister(),
|
||||
hubLeaseClient: hubLeaseClient,
|
||||
managementLeaseClient: managementLeaseClient,
|
||||
spokeLeaseClient: spokeLeaseClient,
|
||||
}
|
||||
@@ -131,31 +128,6 @@ func (c *managedClusterAddOnLeaseController) syncSingle(ctx context.Context,
|
||||
var condition metav1.Condition
|
||||
switch {
|
||||
case errors.IsNotFound(err):
|
||||
// for backward compatible, for lower versions kubernetes (less than 1.14), addons update their leases on hub
|
||||
// cluster, so if we cannot find addon lease on managed/management cluster, we will try to use addon hub lease.
|
||||
// TODO remove this after we no longer support lower versions kubernetes (less than 1.14)
|
||||
observedLease, err = c.hubLeaseClient.Leases(addOn.Namespace).Get(ctx, addOn.Name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if now.Before(observedLease.Spec.RenewTime.Add(gracePeriod)) {
|
||||
// the lease is constantly updated, update its addon status to available
|
||||
condition = metav1.Condition{
|
||||
Type: addonv1alpha1.ManagedClusterAddOnConditionAvailable,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: "ManagedClusterAddOnLeaseUpdated",
|
||||
Message: fmt.Sprintf("%s add-on is available.", addOn.Name),
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
// the lease is not constantly updated, update its addon status to unavailable
|
||||
condition = metav1.Condition{
|
||||
Type: addonv1alpha1.ManagedClusterAddOnConditionAvailable,
|
||||
Status: metav1.ConditionFalse,
|
||||
Reason: "ManagedClusterAddOnLeaseUpdateStopped",
|
||||
Message: fmt.Sprintf("%s add-on is not available.", addOn.Name),
|
||||
}
|
||||
break
|
||||
}
|
||||
condition = metav1.Condition{
|
||||
Type: addonv1alpha1.ManagedClusterAddOnConditionAvailable,
|
||||
Status: metav1.ConditionUnknown,
|
||||
|
||||
@@ -325,35 +325,6 @@ func TestSync(t *testing.T) {
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "addon update its lease constantly (compatibility)",
|
||||
queueKey: "test/test",
|
||||
addOns: []runtime.Object{&addonv1alpha1.ManagedClusterAddOn{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: testinghelpers.TestManagedClusterName,
|
||||
Name: "test",
|
||||
},
|
||||
}},
|
||||
hubLeases: []runtime.Object{testinghelpers.NewAddOnLease(testinghelpers.TestManagedClusterName, "test", now)},
|
||||
spokeLeases: []runtime.Object{},
|
||||
validateActions: func(t *testing.T, ctx *testingcommon.FakeSyncContext, actions []clienttesting.Action) {
|
||||
testingcommon.AssertActions(t, actions, "patch")
|
||||
patch := actions[0].(clienttesting.PatchAction).GetPatch()
|
||||
addOn := &addonv1alpha1.ManagedClusterAddOn{}
|
||||
err := json.Unmarshal(patch, addOn)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
addOnCond := meta.FindStatusCondition(addOn.Status.Conditions, "Available")
|
||||
if addOnCond == nil {
|
||||
t.Errorf("expected addon available condition, but failed")
|
||||
return
|
||||
}
|
||||
if addOnCond.Status != metav1.ConditionTrue {
|
||||
t.Errorf("expected addon available condition is available, but failed")
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "addon has customized health check",
|
||||
queueKey: "test/test",
|
||||
@@ -387,14 +358,12 @@ func TestSync(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
hubClient := kubefake.NewSimpleClientset(c.hubLeases...)
|
||||
managementLeaseClient := kubefake.NewSimpleClientset(c.managementLeases...)
|
||||
spokeLeaseClient := kubefake.NewSimpleClientset(c.spokeLeases...)
|
||||
managementLeaseClient := kubefake.NewClientset(c.managementLeases...)
|
||||
spokeLeaseClient := kubefake.NewClientset(c.spokeLeases...)
|
||||
|
||||
ctrl := &managedClusterAddOnLeaseController{
|
||||
clusterName: testinghelpers.TestManagedClusterName,
|
||||
clock: clocktesting.NewFakeClock(time.Now()),
|
||||
hubLeaseClient: hubClient.CoordinationV1(),
|
||||
clusterName: testinghelpers.TestManagedClusterName,
|
||||
clock: clocktesting.NewFakeClock(time.Now()),
|
||||
patcher: patcher.NewPatcher[
|
||||
*addonv1alpha1.ManagedClusterAddOn, addonv1alpha1.ManagedClusterAddOnSpec, addonv1alpha1.ManagedClusterAddOnStatus](
|
||||
addOnClient.AddonV1alpha1().ManagedClusterAddOns(testinghelpers.TestManagedClusterName)),
|
||||
|
||||
@@ -454,7 +454,6 @@ func (o *SpokeAgentConfig) RunSpokeAgentWithSpokeInformers(ctx context.Context,
|
||||
o.agentOptions.SpokeClusterName,
|
||||
addOnClient,
|
||||
addOnInformerFactory.Addon().V1alpha1().ManagedClusterAddOns(),
|
||||
hubKubeClient.CoordinationV1(),
|
||||
managementKubeClient.CoordinationV1(),
|
||||
spokeKubeClient.CoordinationV1(),
|
||||
AddOnLeaseControllerSyncInterval, //TODO: this interval time should be allowed to change from outside
|
||||
|
||||
Reference in New Issue
Block a user