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: slice overflow panic sometimes during node info parsing #1955

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

BaiMeow
Copy link
Contributor

@BaiMeow BaiMeow commented Aug 16, 2023

What type of PR is this?

bug fixing

What this PR does / why we need it:

check slice ahead to avoid panic cause by slice index out of bounds.

when sep not empty, strings.Split always return a slice which length larger than one, so the original check not working.

if check not passed, return err for retry.

the pr is just a random thing for me after meeting a panic when using kk to setup my k8e cluster.

panic: runtime error: index out of range [0] with length 0

goroutine 563 [running]:
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/k8e.(*K8eStatus).SearchNodesInfo(0xc0000aeb40, {0x2757f10?, 0xc000a12f00?})
        github.com/kubesphere/kubekey/v3/cmd/kk/pkg/k8e/k8e_status.go:106 +0x33e
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/k8e.(*GetClusterStatus).Execute(0xc000011608, {0x2757f10, 0xc000a12f00})
        github.com/kubesphere/kubekey/v3/cmd/kk/pkg/k8e/tasks.go:77 +0x1ae
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).ExecuteWithRetry(0xc00032ae40, {0x2757f10, 0xc000a12f00})
        github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:216 +0x119
github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).Run(0xc00032ae40, {0x2757f10, 0xc000a12f00}, {0x275df38, 0xc00053de30}, 0x0?, 0x0?)
        github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:152 +0x1c5
created by github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task.(*RemoteTask).RunWithTimeout
        github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task/remote_task.go:109 +0x16d

Which issue(s) this PR fixes:

It's easy to fix, so I didn't have a issue first about it.

Special notes for reviewers:

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


@ks-ci-bot ks-ci-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 16, 2023
@pixiake
Copy link
Collaborator

pixiake commented Aug 23, 2023

@BaiMeow Thanks for this contributions !

/lgtm
/approve

@ks-ci-bot ks-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2023
@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: 7877e133c234e75cbd2813a3f0211221ef2f1b08

@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BaiMeow, pixiake

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

@ks-ci-bot ks-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 23, 2023
@ks-ci-bot ks-ci-bot merged commit 8b11847 into kubesphere:master Aug 23, 2023
3 checks passed
@pixiake
Copy link
Collaborator

pixiake commented Aug 24, 2023

@all-contributors please add @BaiMeow for code

@allcontributors
Copy link
Contributor

@pixiake

I've put up a pull request to add @BaiMeow! 🎉

@pixiake
Copy link
Collaborator

pixiake commented Aug 24, 2023

@all-contributors please add @BaiMeow for code

@allcontributors
Copy link
Contributor

@pixiake

@BaiMeow already contributed before to code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants