Skip to content

Commit b2f5d3a

Browse files
authored
Fix Graphd Autofailover When Autoscaler Scale Up and Then Down (#552)
* Fix stacktrace and nebula autoscalar stuck during failover * remove unnecessary comment
1 parent e9bb151 commit b2f5d3a

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

apis/apps/v1alpha1/nebulacluster_common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
kruisev1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
2828
appsv1 "k8s.io/api/apps/v1"
2929
corev1 "k8s.io/api/core/v1"
30+
apiresource "k8s.io/apimachinery/pkg/api/resource"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3233
"k8s.io/apimachinery/pkg/runtime"

pkg/controller/component/graphd_cluster.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ func (c *graphdCluster) syncNebulaClusterStatus(
268268
nc.Status.Graphd.Phase = v1alpha1.RunningPhase
269269
}
270270

271-
workloadReplicas := getWorkloadReplicas(nc.Status.Graphd.Workload)
272-
if !nc.IsAutoFailoverEnabled() ||
273-
pointer.Int32Deref(nc.Spec.Graphd.Replicas, 0) != workloadReplicas {
271+
if !nc.IsAutoFailoverEnabled() {
274272
return syncComponentStatus(nc.GraphdComponent(), &nc.Status.Graphd, oldWorkload)
275273
}
276274

pkg/controller/component/graphd_failover.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ func (g *graphdFailover) toleratePods(nc *v1alpha1.NebulaCluster) ([]string, err
105105
if fh.PodRebuilt {
106106
continue
107107
}
108+
108109
pod, err := g.clientSet.Pod().GetPod(nc.Namespace, podName)
109110
if err != nil && !apierrors.IsNotFound(err) {
110111
return nil, err
111112
}
112-
if pod != nil && isPodTerminating(pod) {
113+
if pod == nil {
114+
continue
115+
}
116+
117+
if isPodTerminating(pod) {
113118
return nil, utilerrors.ReconcileErrorf("failure graphd pod [%s/%s] is deleting", nc.Namespace, podName)
114119
}
115120
if isPodHealthy(pod) {

0 commit comments

Comments
 (0)