The Wayback Machine - https://web.archive.org/web/20251014182827/https://github.com/docker/buildx/pull/2606/
Skip to content

Conversation

crazy-max
Copy link
Member

fixes #2597

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Comment on lines 143 to 170
var err error
var cc ClientConfig
cc, err = ctxkube.ConfigFromEndpoint(endpoint, contextStore)
if err != nil {
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock".
// try again with name="default".
// FIXME(@AkihiroSuda): n should retain real context name.
cc, err = ctxkube.ConfigFromEndpoint("default", contextStore)
if err != nil {
logrus.Error(err)
}
}

tryToUseKubeConfigInCluster := false
if cc == nil {
tryToUseKubeConfigInCluster = true
} else {
if _, err := cc.ClientConfig(); err != nil {
tryToUseKubeConfigInCluster = true
}
}
if tryToUseKubeConfigInCluster {
ccInCluster := ClientConfigInCluster{}
if _, err := ccInCluster.ClientConfig(); err == nil {
logrus.Debug("using kube config in cluster")
cc = ccInCluster
}
}
Copy link
Member Author

@crazy-max crazy-max Jul 16, 2024

Choose a reason for hiding this comment

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

didn't touch this logic and just moved it from builder package for now but should look at it more closely as follow-up.

@crazy-max crazy-max force-pushed the builder-move-kube-cfg branch from 111de87 to b74993b Compare July 17, 2024 08:26
@crazy-max crazy-max added this to the v0.17.0 milestone Jul 17, 2024
@crazy-max
Copy link
Member Author

crazy-max commented Aug 7, 2024

@AkihiroSuda When you have time could you take another look please? Thanks

Copy link
Collaborator

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

if err != nil {
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock".
// try again with name="default".
// FIXME(@AkihiroSuda): n should retain real context name.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What was "n"?

Maybe the variable was renamed since then? (hard to check from phone now)

Copy link
Member Author

@crazy-max crazy-max Aug 7, 2024

Choose a reason for hiding this comment

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

Seems it was the driver config

func(i int, n store.Node) {

I will update this comment.

Also as we now have ContextStore in driver InitConfig maybe it would be fine to have ContextName as well and use it here?

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max force-pushed the builder-move-kube-cfg branch from b74993b to acf0216 Compare August 7, 2024 12:01
@crazy-max crazy-max merged commit 9a0c320 into docker:master Aug 7, 2024
@crazy-max crazy-max deleted the builder-move-kube-cfg branch August 7, 2024 12:44
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.

optimize k8s config initialization

2 participants