Skip to content

fix(fe-controller): guard dereference while trying to clear resources - #533

Open
brucearctor wants to merge 1 commit into
apache:masterfrom
brucearctor:fix/532-fe-clearresources-nil-fespec
Open

brucearctor wants to merge 1 commit into
apache:masterfrom
brucearctor:fix/532-fe-clearresources-nil-fespec

Conversation

@brucearctor

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close #532

Related PR: #522

Problem Summary:

Following up on #522, fe.Controller.ClearResources in pkg/controller/sub_controller/fe/controller.go panics with a nil-pointer dereference when cluster.Spec.FeSpec is nil while cluster.Status.FEStatus is non-nil:

  1. In DorisClusterReconciler.Reconcile, r.clearNoEffectResources(ctx, dcr) (and r.resourceClean(ctx, dcr) on deletion) calls ClearResources on each sub-controller before UpdateComponentStatus resets cluster.Status.FEStatus = nil.
  2. When cluster.Spec.FeSpec == nil and cluster.Status.FEStatus != nil, fc.ClearResources calls fc.RecycleResources(ctx, cluster, v1.Component_FE) -> d.recycleFEResources(ctx, cluster), which immediately evaluates len(dcr.Spec.FeSpec.PersistentVolumes) and panics on the nil FeSpec.
  3. In addition, unlike be.Controller.ClearResources, cn.Controller.ClearResources (fix(cn-controller): guard dereference while trying to clear resources #522), and broker.Controller.ClearResources, fe.Controller.ClearResources did not call fc.ClearCommonResources(ctx, cluster, v1.Component_FE) when cluster.Spec.FeSpec == nil.

This PR guards if cluster.Spec.FeSpec == nil in fe.Controller.ClearResources and delegates to fc.ClearCommonResources(ctx, cluster, v1.Component_FE), matching the other sub-controllers, and adds unit tests using the fake client.

cc @Owen-CH-Leung @Al-assad

Release note

Fix nil FeSpec dereference in feController.ClearResources when feSpec is removed while feStatus is set.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
      • go test ./pkg/controller/sub_controller/fe/... -v -count=1
      • go vet ./...
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes. When cluster.Spec.FeSpec == nil and cluster.Status.FEStatus != nil, fe.Controller.ClearResources now cleans up common FE resources (StatefulSet and Services) instead of panicking in RecycleResources.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Al-assad Al-assad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Al-assad

Al-assad commented Nov 2, 2026

Copy link
Copy Markdown
Member

cc @morningman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] feController ClearResources panics on nil FeSpec when FEStatus is set

2 participants