Skip to content

fix(container): Fix cpu surge when the container terminal executes exit#8115

Merged
wanghe-fit2cloud merged 1 commit intodevfrom
pr@dev@fix_container
Mar 10, 2025
Merged

fix(container): Fix cpu surge when the container terminal executes exit#8115
wanghe-fit2cloud merged 1 commit intodevfrom
pr@dev@fix_container

Conversation

@ssongliu
Copy link
Copy Markdown
Member

No description provided.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Mar 10, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Mar 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from ssongliu. For more information see the Kubernetes Code Review Process.

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

Details 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

@1Panel-bot 1Panel-bot added the dev label Mar 10, 2025
setQuit(exitCh)
global.LOG.Errorf("A panic occurred during receive ws message, error message: %v", r)
}
}()
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.

The receiveWsMsg function has an issue with handling panics. The comment line about setting a quit channel (setQuit(exitCh) ) should be inside the deferred recovery block to ensure it is executed even if an error occurs within the recovery logic itself.

Modified Function:

func (sws *LocalWsSession) receiveWsMsg(exitCh chan bool) {
	defer func() {
	    var recoverError interface{}
	    if r = recover(); r != nil || recoverError = r.(type); recoverr{
    	    setQuit(exitCh)
            global.LOG.Errorf("A panic occurred during receive ws message, error message: %v", r)
        }
    }()
}

This change will prevent any unintended errors during recovery from halting the execution of other critical operations. Additionally, using a type cast helps safely access the recovered value when a runtime error occurs.

@sonarqubecloud
Copy link
Copy Markdown

@wanghe-fit2cloud wanghe-fit2cloud merged commit 38ca2dd into dev Mar 10, 2025
5 of 6 checks passed
@wanghe-fit2cloud wanghe-fit2cloud deleted the pr@dev@fix_container branch March 10, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants