Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

ingress: fix YurtIngress CR status update error #33

Merged
merged 1 commit into from
Jan 7, 2022
Merged
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
27 changes: 13 additions & 14 deletions pkg/yurtappmanager/controller/yurtingress/yurtingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (r *YurtIngressReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
notReadyPool := appsv1alpha1.IngressNotReadyPool{Name: pool, Info: nil}
instance.Status.Conditions.IngressNotReadyPools = append(instance.Status.Conditions.IngressNotReadyPools, notReadyPool)
instance.Status.UnreadyNum += 1
}
}
if removedPools != nil {
Expand All @@ -175,14 +176,18 @@ func (r *YurtIngressReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, err
}
}
if !removePoolfromCondition(instance, pool) {
if desiredPoolNames != nil && !removePoolfromCondition(instance, pool) {
klog.V(4).Infof("Pool/%s is not found from conditions!", pool)
}
}
if desiredPoolNames == nil {
if err := yurtapputil.DeleteNginxIngressCommonResource(r.Client); err != nil {
return ctrl.Result{}, err
}
instance.Status.Conditions.IngressReadyPools = nil
instance.Status.Conditions.IngressNotReadyPools = nil
instance.Status.ReadyNum = 0
instance.Status.UnreadyNum = 0
}
}
if unchangedPools != nil {
Expand Down Expand Up @@ -255,13 +260,10 @@ func removePoolfromCondition(ying *appsv1alpha1.YurtIngress, poolname string) bo
if pool == poolname {
length := len(ying.Status.Conditions.IngressReadyPools)
if i == length-1 {
if length == 1 {
ying.Status.Conditions.IngressReadyPools = nil
} else {
ying.Status.Conditions.IngressReadyPools = ying.Status.Conditions.IngressReadyPools[:i-1]
}
ying.Status.Conditions.IngressReadyPools = ying.Status.Conditions.IngressReadyPools[:i]
} else {
ying.Status.Conditions.IngressReadyPools[i] = ying.Status.Conditions.IngressReadyPools[i+1]
ying.Status.Conditions.IngressReadyPools = append(ying.Status.Conditions.IngressReadyPools[:i],
ying.Status.Conditions.IngressReadyPools[i+1:]...)
}
if ying.Status.ReadyNum >= 1 {
ying.Status.ReadyNum -= 1
Expand All @@ -273,13 +275,10 @@ func removePoolfromCondition(ying *appsv1alpha1.YurtIngress, poolname string) bo
if pool.Name == poolname {
length := len(ying.Status.Conditions.IngressNotReadyPools)
if i == length-1 {
if length == 1 {
ying.Status.Conditions.IngressNotReadyPools = nil
} else {
ying.Status.Conditions.IngressNotReadyPools = ying.Status.Conditions.IngressNotReadyPools[:i-1]
}
ying.Status.Conditions.IngressNotReadyPools = ying.Status.Conditions.IngressNotReadyPools[:i]
} else {
ying.Status.Conditions.IngressNotReadyPools[i] = ying.Status.Conditions.IngressNotReadyPools[i+1]
ying.Status.Conditions.IngressNotReadyPools = append(ying.Status.Conditions.IngressNotReadyPools[:i],
ying.Status.Conditions.IngressNotReadyPools[i+1:]...)
}
if ying.Status.UnreadyNum >= 1 {
ying.Status.UnreadyNum -= 1
Expand Down Expand Up @@ -357,7 +356,7 @@ func prepareDeploymentOwnerReferences(instance *appsv1alpha1.YurtIngress) *metav
isController := true
isBlockOwnerDeletion := true
ownerRef := metav1.OwnerReference{
//TODO: optimze the APIVersion/Kind with instance values
//TODO: optimize the APIVersion/Kind with instance values
APIVersion: "apps.openyurt.io/v1alpha1",
Kind: "YurtIngress",
Name: instance.Name,
Expand Down