Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ejob nil pointer bug #1016

Merged

Conversation

hellolijj
Copy link
Collaborator

Ⅰ. Describe what this PR does

fix ejob nil pointer.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how to verify it

ejob controller will not panic if ejob.spec.replicas not set.

E0706 15:49:38.652110 655 runtime.go:78] Observed a panic: "invalid memory address or nil pointer dereference" (runtime error: invalid memory address or nil pointer dereference) goroutine 1837 [running]: k8s.io/apimachinery/pkg/util/runtime.logPanic({0x1a206c0, 0x2e57b80}) /home/admin/204_20220705195047156_295115616_code/kruise/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:74 +0x85 k8s.io/apimachinery/pkg/util/runtime.HandleCrash({0x0, 0x0, 0xc0262d7fe0}) /home/admin/204_20220705195047156_295115616_code/kruise/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:48 +0x75 panic({0x1a206c0, 0x2e57b80}) /usr/local/go/src/runtime/panic.go:1038 +0x215 github.com/openkruise/kruise/pkg/controller/ephemeraljob.(*ReconcileEphemeralJob).filterPods(0xc0160c2e40, 0xc01f1e5880) /home/admin/204_20220705195047156_295115616_code/kruise/pkg/controller/ephemeraljob/ephemeraljob_controller.go:258 +0x31e

Ⅳ. Special notes for reviews

@kruise-bot kruise-bot requested review from Fei-Guo and FillZpp July 6, 2022 09:29
@kruise-bot kruise-bot added the size/XS size/XS: 0-9 label Jul 6, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1016 (dcad401) into master (5380c57) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1016      +/-   ##
==========================================
+ Coverage   49.64%   49.66%   +0.01%     
==========================================
  Files         124      124              
  Lines       12078    12078              
==========================================
+ Hits         5996     5998       +2     
+ Misses       5166     5164       -2     
  Partials      916      916              
Flag Coverage Δ
unittests 49.66% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/controller/daemonset/daemonset_update.go 55.75% <0.00%> (+0.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5380c57...dcad401. Read the comment docs.

@@ -255,7 +255,9 @@ func (r *ReconcileEphemeralJob) filterPods(job *appsv1alpha1.EphemeralJob) ([]*v
continue
}

if len(targetPods) < int(*job.Spec.Replicas) {
if job.Spec.Replicas == nil {
targetPods = append(targetPods, &podList.Items[i])
Copy link

Choose a reason for hiding this comment

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

gofmt: File is not gofmt-ed with -s

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@hellolijj hellolijj force-pushed the fix-bug/ejob-nil-pointer-bug branch 3 times, most recently from 7f47cd8 to 4de129c Compare July 7, 2022 10:46
@kruise-bot kruise-bot added size/S size/S 10-29 and removed size/XS size/XS: 0-9 labels Jul 7, 2022
@hellolijj hellolijj force-pushed the fix-bug/ejob-nil-pointer-bug branch from 4de129c to e5f2d54 Compare July 8, 2022 03:18
Signed-off-by: JunjunLi <junjunli666@gmail.com>
@hellolijj hellolijj force-pushed the fix-bug/ejob-nil-pointer-bug branch from e5f2d54 to 1b32918 Compare July 8, 2022 03:34
Copy link
Member

@FillZpp FillZpp left a comment

Choose a reason for hiding this comment

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

/lgtm

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FillZpp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot merged commit c29b0c1 into openkruise:master Jul 11, 2022
@FillZpp FillZpp added this to the v1.3.0 milestone Jul 21, 2022
diannaowa pushed a commit to diannaowa/kruise that referenced this pull request Sep 14, 2022
Signed-off-by: JunjunLi <junjunli666@gmail.com>
Signed-off-by: Liu Zhenwei <zwliu@thoughtworks.com>
ppbits pushed a commit to ppbits/kruise that referenced this pull request Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants