diff --git a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go index 840d7a2509e..367cf1f6f3e 100644 --- a/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go +++ b/pkg/yurtmanager/controller/platformadmin/platformadmin_controller.go @@ -219,8 +219,20 @@ func (r *ReconcilePlatformAdmin) Reconcile(ctx context.Context, request reconcil // resource are patched back to the API server. defer func(isDeleted *bool) { if !*isDeleted { - platformAdmin.Status = *platformAdminStatus + // Finally check whether PlatformAdmin is Ready + platformAdminStatus.Ready = true + if cond := util.GetPlatformAdminCondition(*platformAdminStatus, iotv1alpha2.ConfigmapAvailableCondition); cond.Status == corev1.ConditionFalse { + platformAdminStatus.Ready = false + } + if cond := util.GetPlatformAdminCondition(*platformAdminStatus, iotv1alpha2.ComponentAvailableCondition); cond.Status == corev1.ConditionFalse { + platformAdminStatus.Ready = false + } + if platformAdminStatus.UnreadyComponentNum != 0 { + platformAdminStatus.Ready = false + } + // Finally update the status of PlatformAdmin + platformAdmin.Status = *platformAdminStatus if err := r.Status().Update(ctx, platformAdmin); err != nil { klog.Errorf(Format("Update the status of PlatformAdmin %s/%s failed", platformAdmin.Namespace, platformAdmin.Name)) reterr = kerrors.NewAggregate([]error{reterr, err}) @@ -257,8 +269,6 @@ func (r *ReconcilePlatformAdmin) reconcileDelete(ctx context.Context, platformAd } desiredComponents = append(desiredComponents, additionalComponents...) - //TODO: handle PlatformAdmin.Spec.Components - for _, dc := range desiredComponents { if err := r.Get( ctx, @@ -332,7 +342,6 @@ func (r *ReconcilePlatformAdmin) reconcileNormal(ctx context.Context, platformAd util.SetPlatformAdminCondition(platformAdminStatus, util.NewPlatformAdminCondition(iotv1alpha2.ComponentAvailableCondition, corev1.ConditionTrue, "", "")) // Update the metadata of PlatformAdmin - platformAdminStatus.Ready = true if err := r.Client.Update(ctx, platformAdmin); err != nil { klog.Errorf(Format("Update PlatformAdmin %s error %v", klog.KObj(platformAdmin), err)) return reconcile.Result{}, err diff --git a/test/e2e/util/nodepool.go b/test/e2e/util/nodepool.go index b63cfb0a124..3f310e59c26 100644 --- a/test/e2e/util/nodepool.go +++ b/test/e2e/util/nodepool.go @@ -142,7 +142,7 @@ func PrepareNodePoolWithNode(ctx context.Context, k8sClient client.Client, nodeN } patchObj := client.MergeFrom(node.DeepCopy()) - node.Labels[apps.NodePoolLabel] = NodePoolName + node.Labels[projectinfo.GetNodePoolLabel()] = NodePoolName if err := k8sClient.Patch(ctx, node, patchObj); err != nil { return err diff --git a/test/e2e/yurt/iot.go b/test/e2e/yurt/iot.go index 3a0b2b00230..e10602feecd 100644 --- a/test/e2e/yurt/iot.go +++ b/test/e2e/yurt/iot.go @@ -54,23 +54,17 @@ var _ = Describe("OpenYurt IoT Test", func() { Name: namespaceName, }, } + Eventually( func() error { - return k8sClient.Delete(ctx, &ns, client.PropagationPolicy(metav1.DeletePropagationForeground)) - }).WithTimeout(timeout).WithPolling(time.Millisecond * 500).Should(SatisfyAny(BeNil(), &util.NotFoundMatcher{})) + return k8sClient.Delete(ctx, &ns, client.PropagationPolicy(metav1.DeletePropagationBackground)) + }, timeout, 500*time.Millisecond).Should(SatisfyAny(BeNil(), &util.NotFoundMatcher{})) By("make sure the needed namespace are removed") - res := &corev1.Namespace{} - Eventually( - func() error { - return k8sClient.Get(ctx, client.ObjectKey{ - Name: namespaceName, - }, res) - }).WithTimeout(timeout).WithPolling(time.Millisecond * 500).Should(&util.NotFoundMatcher{}) Eventually( func() error { return k8sClient.Create(ctx, &ns) - }).WithTimeout(timeout).WithPolling(time.Millisecond * 300).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{})) + }, timeout, 500*time.Millisecond).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{})) } createPlatformAdmin := func(version string) { @@ -81,7 +75,7 @@ var _ = Describe("OpenYurt IoT Test", func() { Namespace: namespaceName, }, }) - }).WithTimeout(timeout).WithPolling(500 * time.Millisecond).Should(SatisfyAny(BeNil(), &util.NotFoundMatcher{})) + }, timeout, 500*time.Millisecond).Should(SatisfyAny(BeNil(), &util.NotFoundMatcher{})) testPlatformAdmin := iotv1alpha2.PlatformAdmin{ ObjectMeta: metav1.ObjectMeta{ @@ -95,7 +89,7 @@ var _ = Describe("OpenYurt IoT Test", func() { } Eventually(func() error { return k8sClient.Create(ctx, &testPlatformAdmin) - }).WithTimeout(timeout).WithPolling(500 * time.Millisecond).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{})) + }, timeout, 500*time.Millisecond).Should(SatisfyAny(BeNil(), &util.AlreadyExistMatcher{})) } BeforeEach(func() {