Fix panic when webhook specifies a rendering template via ConfigMap#305
Open
yuguorui wants to merge 2 commits intoAliyunContainerService:masterfrom
Open
Fix panic when webhook specifies a rendering template via ConfigMap#305yuguorui wants to merge 2 commits intoAliyunContainerService:masterfrom
yuguorui wants to merge 2 commits intoAliyunContainerService:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a panic that occurs when webhook sinks specify a rendering template via ConfigMap by adding nil checks for the URI parameter in the Kubernetes client configuration functions.
Key Changes:
- Added nil check for URI parameter before accessing its properties to prevent panic
- Modified client singleton retrieval logic to handle nil URI cases
- Fixed minor formatting issue in Dockerfile
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| deploy/Dockerfile | Added missing -y flag to apt-get install command for consistency |
| common/kubernetes/configs.go | Added nil checks for URI parameter to prevent panic when webhook uses ConfigMap templates |
Comments suppressed due to low confidence (3)
common/kubernetes/configs.go:96
- The code accesses
configOverrides.ClusterInfo.Serverwithout checking ifconfigOverridesis nil. Whenuriis nil,configOverridesremains nil (as initialized on line 71), which will cause a panic. Add a nil check forconfigOverridesbefore accessing its fields.
if configOverrides.ClusterInfo.Server != "" {
common/kubernetes/configs.go:101
- These lines access
configOverridesfields without a nil check. Whenuriis nil,configOverrideswill be nil, causing a panic. Wrap these accesses in a nil check forconfigOverrides.
kubeConfig.Insecure = configOverrides.ClusterInfo.InsecureSkipTLSVerify
if configOverrides.ClusterInfo.InsecureSkipTLSVerify {
common/kubernetes/configs.go:1
- The code accesses
configOverrides.ClusterInfofields without checking ifconfigOverridesis nil. Whenuriis nil, this will cause a panic. Add appropriate nil checks or provide default values whenconfigOverridesis nil.
// Copyright 2014 Google Inc. All Rights Reserved.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
added 2 commits
October 28, 2025 01:15
NewWebHookSink() will try to retrieve the k8s client with kubernetes.GetKubernetesClient(nil), which cause a panic by having a nil on k8s client. Allow kubernetes.GetKubernetesClient(nil) to fallback to in-cluster config instead of return nil to the caller. Signed-off-by: ruogui.ygr <ruogui.ygr@alibaba-inc.com>
Signed-off-by: ruogui.ygr <ruogui.ygr@alibaba-inc.com>
Contributor
|
Hi @yuguorui , thanks for your contribution! Could you provide detailed information on how to reproduce this panic? |
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 type of PR is this?
PR类型是什么?
/kind bug
What this PR does / why we need it:
这个PR解决了什么问题:
Fix panic when webhook sinks specifies a rendering template via ConfigMap
Which issue(s) this PR fixes:
PR相关联issue:
Fixes #
Does this PR introduce a breaking change?:
PR带来的破坏性变更:
NONE
Test/Final result:
测试/最终运行结果: