colima icon indicating copy to clipboard operation
colima copied to clipboard

Provision scripts are ignored when VM is just created

Open Noksa opened this issue 1 year ago • 1 comments

Description

Provision scripts are ignored when we start VM first time (create it)

Version

colima version 0.6.9
git commit: c3a31ed05f5fab8b2cdbae835198e8fb1717fd0f

runtime: docker
arch: aarch64
client: v27.0.3
server: v26.1.1
limactl version 0.22.0
qemu-img version 9.0.1
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

Operating System

  • [ ] macOS Intel <= 13 (Ventura)
  • [ ] macOS Intel >= 14 (Sonoma)
  • [ ] Apple Silicon <= 13 (Ventura)
  • [X] Apple Silicon >= 14 (Sonoma)
  • [ ] Linux

Output of colima status

INFO[0000] colima is running using macOS Virtualization.Framework
INFO[0000] arch: aarch64
INFO[0000] runtime: docker
INFO[0000] mountType: virtiofs
INFO[0000] socket: unix:///Users/alexandr/.colima/default/docker.sock
INFO[0000] kubernetes: enabled

Reproduction Steps

  1. Add provision block in template as follows:
provision:
  - mode: system
    script: |
      cat <<EOF > /etc/systemd/system/docker.service.d/docker-buildkit-env.conf
      [Service]
      Environment="BUILDKIT_STEP_LOG_MAX_SIZE=20971520"
      Environment="BUILDKIT_STEP_LOG_MAX_SPEED=1048576"
      EOF
      systemctl daemon-reload
      systemctl restart docker
  1. Clean install VM
colima start
  1. Check that file is not present: colima ssh -- ls /etc/systemd/system/docker.service.d

  2. Stop and start again

colima stop && colima start
  1. Now file is present

Expected behaviour

Provision scripts should be considered when we do start first time

Additional context

As a workaround we can use colima start --edit but just save template without changes. In this case, scripts will be run

Noksa avatar Jul 04 '24 17:07 Noksa

I too have this problem and the workaround does not work for me.

My custom provision section are never executed.

colima version 0.7.5
git commit: 1588c066b9ab9dae8205ef265929c7eb43dca473

runtime: docker
arch: aarch64
client: v27.2.0
server: v27.1.1

davidolrik avatar Sep 02 '24 10:09 davidolrik

@Noksa I went through this process myself, part of the issue here is there is next to no signal to confirm when and where your commands are being executed. If I were to guess, the problem you've indicated above is that you're trying to create a file in a directory that doesn't exist, but there's no way for that subsystem to communicate errors back to you so it just fails.

The simplest way I have found to check to see if startup scripts are working is to just create a bogus configuration that attempts to execute a command that does not exist:

provision:
  - mode: system
    script: bogus-command

this works for other mode's as well, which helped me confirm that boot was actually being executed.

The next step of getting signal is to create a simple file and verify that post-boot:

provision:
  - mode: system
    script: whoami > info-whoami.txt
  - mode: system
    script: pwd > info-pwd.txt
  - mode: system
    script: mount > info-mount.txt

and observe that those files exist in / post-boot.

From there, you can build up to a command that executes the way you intend. I hope this helps!

blast-hardcheese avatar Oct 01 '25 17:10 blast-hardcheese