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

change: no default image for node creation in local cluster where image should be copied from existing nodes #1034

Merged
merged 1 commit into from
Mar 26, 2022

Conversation

iwilltry42
Copy link
Member

fixes #1005

@iwilltry42 iwilltry42 self-assigned this Mar 26, 2022
@iwilltry42 iwilltry42 added the enhancement New feature or request label Mar 26, 2022
@iwilltry42 iwilltry42 added this to the v5.4.0 milestone Mar 26, 2022
@iwilltry42 iwilltry42 merged commit 15d7dc9 into main Mar 26, 2022
@iwilltry42 iwilltry42 deleted the iwilltry42/issue1005 branch March 26, 2022 09:41
@CodingCanuck
Copy link

Could this have potentially broken the creation of tools nodes? I'm not familiar with the k3d codebase, but it looks like the NodeAddToClusterRemote() function that's now responsible for handling default images might not be called for tools node creation, which happens as part of a k3d image import command:

k3d/pkg/client/tools.go

Lines 101 to 126 in 852df77

func importWithToolsNode(ctx context.Context, runtime runtimes.Runtime, cluster *k3d.Cluster, imagesFromRuntime []string, imagesFromTar []string, opts k3d.ImageImportOpts) error {
// create tools node to export images
toolsNode, err := EnsureToolsNode(ctx, runtime, cluster)
if err != nil {
return fmt.Errorf("failed to ensure that tools node is running: %w", err)
}
var importTarNames []string
if len(imagesFromRuntime) > 0 {
// save image to tarfile in shared volume
l.Log().Infof("Saving %d image(s) from runtime...", len(imagesFromRuntime))
tarName := fmt.Sprintf("%s/k3d-%s-images-%s.tar", k3d.DefaultImageVolumeMountPath, cluster.Name, time.Now().Format("20060102150405"))
if err := runtime.ExecInNode(ctx, toolsNode, append([]string{"./k3d-tools", "save-image", "-d", tarName}, imagesFromRuntime...)); err != nil {
return fmt.Errorf("failed to save image(s) in tools container for cluster '%s': %w", cluster.Name, err)
}
importTarNames = append(importTarNames, tarName)
}
if len(imagesFromTar) > 0 {
// copy tarfiles to shared volume
l.Log().Infof("Saving %d tarball(s) to shared image volume...", len(imagesFromTar))
for _, file := range imagesFromTar {
tarName := fmt.Sprintf("%s/k3d-%s-images-%s-file-%s", k3d.DefaultImageVolumeMountPath, cluster.Name, time.Now().Format("20060102150405"), path.Base(file))
if err := runtime.CopyToNode(ctx, file, tarName, toolsNode); err != nil {
l.Log().Errorf("failed to copy image tar '%s' to tools node! Error below:\n%+v", file, err)
(though I might not be tracing this correctly!)

See error I'm hitting with 5.4.1: #954 (comment)

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

Successfully merging this pull request may close these issues.

[Enhancement] k3d node create to copy image version from target cluster
2 participants