Skip to content

Commit

Permalink
Merge pull request #543 from deitch/fix-lima-startup-issues
Browse files Browse the repository at this point in the history
lima startup issues fixed
  • Loading branch information
deitch committed Jul 11, 2023
2 parents c439c1d + 53f46f9 commit d17874e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/container/lima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ provision:
script: |
rm -f $HOME/containerd.sock
ln -s /proc/$(cat $XDG_RUNTIME_DIR/containerd-rootless/child_pid)/root/run/containerd/containerd.sock ${HOME}/containerd.sock
- mode: system
script: |
chmod 0755 /etc/cni
- mode: system
script: |
chmod 0755 /etc/cni
13 changes: 10 additions & 3 deletions pkg/container/lima_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,15 @@ func (l *lima) terminateVM(ctx context.Context, cfg *Config) error {

func (l *lima) WorkspaceTar(ctx context.Context, cfg *Config) (io.ReadCloser, error) {
pr, pw := io.Pipe()
err := l.nerdctl(ctx, melangeVMName, nil, pw, nil, "exec", "-i", "tar", "cf", "-", "-C", runnerWorkdir, "melange-out")
return pr, err
go func() {
defer pw.Close()

if err := l.nerdctl(ctx, melangeVMName, nil, pw, nil, "exec", "-i", cfg.PodID, "tar", "cf", "-", "-C", runnerWorkdir, "melange-out"); err != nil {
pw.CloseWithError(fmt.Errorf("failed to tar workspace: %w", err))
}
}()

return pr, nil
}

// these private functions handle some reusable code to avoid duplication.
Expand Down Expand Up @@ -333,7 +340,7 @@ func (l *lima) start(ctx context.Context, name string, exists bool) error {

if !exists {
buf = bytes.NewReader(config)
args = append(args, "/dev/stdin")
args = append(args, "-")
}
return l.limactl(ctx, buf, nil, nil, args...)
}
Expand Down

0 comments on commit d17874e

Please sign in to comment.