From fe7656c43b049b1649d72436723a7fae632b4378 Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:39:49 +0800 Subject: [PATCH] fix: fix nil pointer error Signed-off-by: Rory Z <16801068+Rory-Z@users.noreply.github.com> --- RELEASE.md | 8 +++---- .../apps/v2beta1/update_emqx_status.go | 24 ++++++++++--------- deploy/charts/emqx-operator/Chart.yaml | 4 ++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index d240a853f..798505821 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,6 +1,6 @@ # Release Note 🍻 -EMQX Operator 2.2.23 has been released. +EMQX Operator 2.2.24-rc.1 has been released. ## Supported version + apps.emqx.io/v2beta1 @@ -13,11 +13,11 @@ EMQX Operator 2.2.23 has been released. + EMQX at 4.4.14 and later + EMQX Enterprise at 4.4.14 and later -## Other Changes ✨ +## Fixes 🐞 + `apps.emqx.io/v2beta1 EMQX`. - + Delete `apps.emqx.io/v2beta1/EMQX/status.coreNodes[*].uptime` and `apps.emqx.io/v2beta1/EMQX/status.replicantNodes[*].uptime`, because EMQX operator will constantly updating them. This is unnecessary wear and tear. + + Fix sometimes will got nil pointer error. ## How to install/upgrade EMQX Operator 💡 @@ -29,7 +29,7 @@ helm repo update helm upgrade --install emqx-operator emqx/emqx-operator \ --namespace emqx-operator-system \ --create-namespace \ - --version 2.2.23 + --version 2.2.24-rc.1 kubectl wait --for=condition=Ready pods -l "control-plane=controller-manager" -n emqx-operator-system ``` diff --git a/controllers/apps/v2beta1/update_emqx_status.go b/controllers/apps/v2beta1/update_emqx_status.go index 3bff86a91..7d7232d2b 100644 --- a/controllers/apps/v2beta1/update_emqx_status.go +++ b/controllers/apps/v2beta1/update_emqx_status.go @@ -117,19 +117,21 @@ func (u *updateStatus) reconcile(ctx context.Context, logger logr.Logger, instan } } - isEnterpriser := false - for _, node := range coreNodes { - if node.ControllerUID == currentSts.UID && node.Edition == "Enterprise" { - isEnterpriser = true - break + if currentSts != nil { + isEnterpriser := false + for _, node := range coreNodes { + if node.ControllerUID == currentSts.UID && node.Edition == "Enterprise" { + isEnterpriser = true + break + } } - } - if isEnterpriser { - nodeEvacuationsStatus, err := getNodeEvacuationStatusByAPI(r) - if err != nil { - u.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeEvacuationStatuses", err.Error()) + if isEnterpriser { + nodeEvacuationsStatus, err := getNodeEvacuationStatusByAPI(r) + if err != nil { + u.EventRecorder.Event(instance, corev1.EventTypeWarning, "FailedToGetNodeEvacuationStatuses", err.Error()) + } + instance.Status.NodeEvacuationsStatus = nodeEvacuationsStatus } - instance.Status.NodeEvacuationsStatus = nodeEvacuationsStatus } // update status condition diff --git a/deploy/charts/emqx-operator/Chart.yaml b/deploy/charts/emqx-operator/Chart.yaml index 3de3bfee5..a08c8f286 100644 --- a/deploy/charts/emqx-operator/Chart.yaml +++ b/deploy/charts/emqx-operator/Chart.yaml @@ -15,12 +15,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.2.23 +version: 2.2.24-rc.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 2.2.23 +appVersion: 2.2.24-rc.1 sources: - https://github.com/emqx/emqx-operator/tree/main/deploy/charts/emqx-operator