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: scheduler ignore KUBECONFIG env even if this environment variable is set #681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shouren
Copy link
Collaborator

@Shouren Shouren commented Dec 5, 2024

What type of PR is this?
/kind bug

What this PR does / why we need it:
The implementation of NewClient function in pkg/k8sutil/client.go gets *restclient.Config from InClusterConfig api first even if the KUBECONFIG env has been set which is out of expect. This PR fix it.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/scheduler/scheduler.go 0.00% 1 Missing ⚠️
Flag Coverage Δ
unittests 32.69% <0.00%> (+0.30%) ⬆️

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

Files with missing lines Coverage Δ
pkg/scheduler/scheduler.go 33.61% <0.00%> (+1.37%) ⬆️

@Shouren Shouren force-pushed the fix/k8s-client-for-scheduler branch 3 times, most recently from ae54f90 to dda05c5 Compare December 5, 2024 10:04
@Shouren Shouren changed the title fix: scheduler force using InClusterConfig when KUBECONFIG is set fix: scheduler ignore KUBECONFIG env Dec 5, 2024
@Shouren Shouren force-pushed the fix/k8s-client-for-scheduler branch 4 times, most recently from 57fee3a to 4aae789 Compare December 5, 2024 11:18
@@ -125,7 +126,7 @@ func (s *Scheduler) onDelPod(obj interface{}) {
}

func (s *Scheduler) Start() {
kubeClient, err := k8sutil.NewClient()
kubeClient, err := client.NewClient()
Copy link
Member

Choose a reason for hiding this comment

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

you can use client.GetClient() to get kubeClient, because this kubeClient having init function Initialization completed.

Copy link
Collaborator Author

@Shouren Shouren Dec 6, 2024

Choose a reason for hiding this comment

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

Good idea. By doing so, some the unused code can also be removed

@lengrongfu
Copy link
Member

suggest title: fix: scheduler ignore KUBECONFIG env even if this environment variable is set

@Shouren Shouren changed the title fix: scheduler ignore KUBECONFIG env fix: scheduler ignore KUBECONFIG env even if this environment variable is set Dec 6, 2024
@Shouren Shouren force-pushed the fix/k8s-client-for-scheduler branch 3 times, most recently from 7e05044 to 2637cf5 Compare December 6, 2024 03:39
@lengrongfu
Copy link
Member

@Shouren can you rebase main branch? because having resolve code lint question.

…il/client in pkg/scheduler/scheduler.go

Signed-off-by: Shouren Yang <[email protected]>
@Shouren Shouren force-pushed the fix/k8s-client-for-scheduler branch from 2637cf5 to 09448b9 Compare December 6, 2024 07:27
@Shouren
Copy link
Collaborator Author

Shouren commented Dec 6, 2024

@Shouren can you rebase main branch? because having resolve code lint question.

@lengrongfu All right, rebase is done.

@lengrongfu
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants