knife-proxmox-ve 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d5214d06c2b3094351f1e2824fc0d3e9cceba436f2053bb32001b41fe18ea5c
4
- data.tar.gz: fad9ae85bb184f7dd8fdb6e54cac5a15a8f9036f1f5f4a07b939cd0a4a0e3f3a
3
+ metadata.gz: fbd3b9c6dcb50cfa79244a9ff639c08e2b4417bdc99416a870b0a9886367a888
4
+ data.tar.gz: e4c7f6ab01e458c4794651ac8927f8aecb5a1e42368b7222862f25e6b85d08bc
5
5
  SHA512:
6
- metadata.gz: c4d3a3bdff34585a82c46888572244512f06a7a17b94475b135f2d5f520c2b47d983e07f69cb40baa2ebc2fca8526db2cd5c6c7928ab1f778d2db28061167a05
7
- data.tar.gz: 9008cdcd204db73879b3f2a4602e202d821dd70b9df217ebc8ff90e59342e7ff805c516497cd7c62970c531fd6f04df7e69f2fac84305836ba1f9faf821f7630
6
+ metadata.gz: 7633f2ed9ae45c09629598331707b209076eb32e477239a5cc91732339eb8947f4637631ef974e99604eac66fbb8ef59ed5ebab07ec24dee427d1037053ef5c6
7
+ data.tar.gz: 3df97180d137de70f035416f88d487b13d3f562ec02087b2b8e382abea081dcc7b91c0fa6475ef15453dde08d857290e8b703f39d2015aca121228bba7f60e73
@@ -28,13 +28,30 @@ class Chef
28
28
  CINC_PRODUCT = "cinc"
29
29
  CINC_INSTALL_URL = "https://omnitruck.cinc.sh/install.sh"
30
30
 
31
- # A freshly cloned VM often still runs cloud-init (which itself drives apt) when SSH first
32
- # answers. Installing the client then races cloud-init for the dpkg lock and fails
33
- # non-deterministically. Block on cloud-init completion before the omnibus install so a
34
- # single `vm bootstrap` is reliable. Guarded so non-cloud-init images don't error, and
35
- # `|| true` so a degraded/errored cloud-init state still lets the bootstrap proceed.
36
- CLOUD_INIT_WAIT_COMMAND =
37
- "if command -v cloud-init >/dev/null 2>&1; then cloud-init status --wait >/dev/null 2>&1 || true; fi"
31
+ # A freshly cloned VM is still settling when SSH first answers, and two independent
32
+ # subsystems contend for the dpkg lock: cloud-init (which itself drives apt) and the
33
+ # apt-daily / unattended-upgrades systemd timers, which fire on their own schedule even
34
+ # after cloud-init reports done. Installing the client or the first client run's package
35
+ # resources then races them for the lock and fails non-deterministically. Clear the field
36
+ # before the omnibus install, in order:
37
+ # 1. wait for cloud-init to finish;
38
+ # 2. stop the apt-daily / unattended-upgrades timers and any in-flight run, so nothing
39
+ # grabs the lock again for the rest of this boot (`stop`, not `disable`/`mask`: the
40
+ # services return on the next reboot, leaving the image unchanged);
41
+ # 3. block (bounded) until the dpkg lock a stopped run may still hold is released.
42
+ # Every step is guarded on the tool existing and `|| true`, so non-cloud-init / non-systemd
43
+ # / non-apt images and degraded states still let the bootstrap proceed.
44
+ PREINSTALL_WAIT_COMMAND = <<~SH
45
+ if command -v cloud-init >/dev/null 2>&1; then cloud-init status --wait >/dev/null 2>&1 || true; fi
46
+ if command -v systemctl >/dev/null 2>&1; then
47
+ systemctl stop apt-daily.timer apt-daily-upgrade.timer apt-daily.service apt-daily-upgrade.service unattended-upgrades.service >/dev/null 2>&1 || true
48
+ fi
49
+ if command -v flock >/dev/null 2>&1; then
50
+ for lock in /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock; do
51
+ [ -e "$lock" ] && flock -w 300 "$lock" true >/dev/null 2>&1 || true
52
+ done
53
+ fi
54
+ SH
38
55
 
39
56
  deps do
40
57
  require "chef/knife/bootstrap"
@@ -60,8 +77,8 @@ class Chef
60
77
  # TOFU: a freshly cloned VM has no entry in known_hosts. Accept its key on
61
78
  # first connect rather than failing the bootstrap or disabling verification.
62
79
  config[:ssh_verify_host_key] ||= :accept_new
63
- # Wait for cloud-init to finish before the bootstrap installs the client (see constant).
64
- config[:bootstrap_preinstall_command] ||= CLOUD_INIT_WAIT_COMMAND
80
+ # Drain cloud-init and the dpkg lock before the bootstrap installs the client (see constant).
81
+ config[:bootstrap_preinstall_command] ||= PREINSTALL_WAIT_COMMAND
65
82
  end
66
83
 
67
84
  # The bootstrap target host does not exist yet — it is resolved to the VM's IP
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Knife
4
4
  module Proxmox
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-proxmox-ve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Wojcieszonek