Skip to content

Commit

Permalink
fix: fix service port error
Browse files Browse the repository at this point in the history
Fixed the bug where the service port disappears when a node in the EMQX cluster crashes.

Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Sep 1, 2023
1 parent 618acea commit 5a4c09d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions controllers/apps/v1beta3/emqx_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,26 @@ type EmqxReconciler struct {
}

func (r *EmqxReconciler) Do(ctx context.Context, instance appsv1beta3.Emqx) (ctrl.Result, error) {
var resources []client.Object
var err error
var emqxNodes []appsv1beta3.EmqxNode
emqxNodes, err = r.getNodeStatusesByAPI(instance)
if err != nil {
r.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeStatues", err.Error())
condition := appsv1beta3.NewCondition(
appsv1beta3.ConditionRunning,
corev1.ConditionFalse,
"FailedToGetNodeStatues",
err.Error(),
)
instance.SetCondition(*condition)
_ = r.Status().Update(ctx, instance)
}
instance = updateEmqxStatus(instance, emqxNodes)
if err = r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}

var resources []client.Object
postFn := func(client.Object) error { return nil }

sts := generateStatefulSetDef(instance)
Expand Down Expand Up @@ -180,7 +198,7 @@ func (r *EmqxReconciler) Do(ctx context.Context, instance appsv1beta3.Emqx) (ctr
return ctrl.Result{RequeueAfter: time.Duration(5) * time.Second}, err
}

emqxNodes, err := r.getNodeStatusesByAPI(instance)
emqxNodes, err = r.getNodeStatusesByAPI(instance)
if err != nil {
r.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeStatues", err.Error())
condition := appsv1beta3.NewCondition(
Expand Down

0 comments on commit 5a4c09d

Please sign in to comment.