Skip to content

Commit e12883b

Browse files
Merge branch 'main' of github.com:inspec/train into feature/CHEF-2414-warn-azure-deprecation
2 parents 655ed6c + 9c90ec3 commit e12883b

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
<!-- release_rollup -->
66

77
<!-- latest_stable_release -->
8+
## [v3.10.8](https://github.com/inspec/train/tree/v3.10.8) (2023-06-23)
9+
10+
#### Merged Pull Requests
11+
- Fix cannot find a UUID when connect using train with local transport inside docker container [#747](https://github.com/inspec/train/pull/747) ([Vasu1105](https://github.com/Vasu1105))
12+
<!-- latest_stable_release -->
13+
814
## [v3.10.7](https://github.com/inspec/train/tree/v3.10.7) (2022-10-19)
915

1016
#### Merged Pull Requests
@@ -14,7 +20,6 @@
1420
- Fix Cisco Nexus version detection [#737](https://github.com/inspec/train/pull/737) ([trickyearlobe](https://github.com/trickyearlobe))
1521
- Update net-ssh requirement from &gt;= 2.9, &lt; 7.0 to &gt;= 2.9, &lt; 8.0 [#733](https://github.com/inspec/train/pull/733) ([dependabot[bot]](https://github.com/dependabot[bot]))
1622
- Allow net-scp 4.0.0 [#739](https://github.com/inspec/train/pull/739) ([clintoncwolfe](https://github.com/clintoncwolfe))
17-
<!-- latest_stable_release -->
1823

1924
## [v3.10.1](https://github.com/inspec/train/tree/v3.10.1) (2022-06-29)
2025

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10.7
1+
3.10.8

lib/train/platforms/detect/helpers/os_common.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def unix_uuid
117117
(unix_uuid_from_chef ||
118118
unix_uuid_from_machine_file ||
119119
uuid_from_command ||
120+
uuid_from_containerized_system ||
120121
raise(Train::TransportError, "Cannot find a UUID for your node."))
121122
end
122123

@@ -155,6 +156,28 @@ def uuid_from_command
155156
uuid_from_string(result.stdout.chomp) if result.exit_status == 0 && !result.stdout.empty?
156157
end
157158

159+
# This will run if anyone is running Train with local transport inside docker container
160+
# This is fallback plan, if other ways of getting uuid fails for local transport running inside docker container
161+
# TODO: This needs to be improved to support other container runtime
162+
def uuid_from_containerized_system
163+
uuid = nil
164+
165+
if File.exist?("/proc/self/cgroup")
166+
cmd = @backend.run_command("head -1 /proc/self/cgroup|cut -d/ -f3")
167+
unless cmd.stdout.strip.empty?
168+
uuid = cmd.stdout.strip
169+
end
170+
end
171+
172+
if uuid.nil? && File.exist?("/proc/self/mountinfo")
173+
cmd = @backend.run_command("cat /proc/self/mountinfo | grep -i /docker/containers/ | head -n 1 | awk '{print $4}' | awk NF=NF FS=/ | awk '{print $3}'")
174+
unless cmd.stdout.strip.empty?
175+
uuid = cmd.stdout.strip
176+
end
177+
end
178+
uuid
179+
end
180+
158181
# This hashes the passed string into SHA1.
159182
# Then it downgrades the 160bit SHA1 to a 128bit
160183
# then we format it as a valid UUIDv5.

lib/train/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# Author:: Dominik Richter (<dominik.richter@gmail.com>)
33

44
module Train
5-
VERSION = "3.10.7".freeze
5+
VERSION = "3.10.8".freeze
66
end

0 commit comments

Comments
 (0)