Repository navigation
fix(fe-controller): guard dereference while trying to clear resources - #533
Open
brucearctor wants to merge 1 commit into
Open
brucearctor wants to merge 1 commit into
brucearctor wants to merge 1 commit into
Conversation
Member
|
cc @morningman |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: close #532
Related PR: #522
Problem Summary:
Following up on #522,
fe.Controller.ClearResourcesinpkg/controller/sub_controller/fe/controller.gopanics with a nil-pointer dereference whencluster.Spec.FeSpecisnilwhilecluster.Status.FEStatusis non-nil:DorisClusterReconciler.Reconcile,r.clearNoEffectResources(ctx, dcr)(andr.resourceClean(ctx, dcr)on deletion) callsClearResourceson each sub-controller beforeUpdateComponentStatusresetscluster.Status.FEStatus = nil.cluster.Spec.FeSpec == nilandcluster.Status.FEStatus != nil,fc.ClearResourcescallsfc.RecycleResources(ctx, cluster, v1.Component_FE)->d.recycleFEResources(ctx, cluster), which immediately evaluateslen(dcr.Spec.FeSpec.PersistentVolumes)and panics on the nilFeSpec.be.Controller.ClearResources,cn.Controller.ClearResources(fix(cn-controller): guard dereference while trying to clear resources #522), andbroker.Controller.ClearResources,fe.Controller.ClearResourcesdid not callfc.ClearCommonResources(ctx, cluster, v1.Component_FE)whencluster.Spec.FeSpec == nil.This PR guards
if cluster.Spec.FeSpec == nilinfe.Controller.ClearResourcesand delegates tofc.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
FeSpecdereference infeController.ClearResourceswhenfeSpecis removed whilefeStatusis set.Check List (For Author)
Test
go test ./pkg/controller/sub_controller/fe/... -v -count=1go vet ./...Behavior changed:
cluster.Spec.FeSpec == nilandcluster.Status.FEStatus != nil,fe.Controller.ClearResourcesnow cleans up common FE resources (StatefulSetandServices) instead of panicking inRecycleResources.Does this need documentation?
Check List (For Reviewer who merge this PR)