Merge ~ltrager/maas:lp1917652_2.9 into maas:2.9

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: e6b616fd08a020cac13d94495aab8649bce41145
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1917652_2.9
Merge into: maas:2.9
Diff against target: 331 lines (+69/-37)
2 files modified
src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py (+29/-18)
src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py (+40/-19)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Lee Trager (community) Approve
Review via email: mp+400365@code.launchpad.net

Commit message

LP: #1917652 - Increase timeout for BMC detection commands.

Some BMCs are very slow to respond. Increase the timeout for commands run
by 30-maas-01-bmc-config to 180s so the test doesn't time out.

Cherry-pick of dd3af77

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1917652_2.9 lp:~ltrager/maas/+git/maas into -b 2.9 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: e6b616fd08a020cac13d94495aab8649bce41145

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py b/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py
2index ae082c7..42e4c79 100755
3--- a/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py
4+++ b/src/metadataserver/builtin_scripts/commissioning_scripts/bmc_config.py
5@@ -80,6 +80,13 @@ import urllib
6 from paramiko.client import MissingHostKeyPolicy, SSHClient
7 import yaml
8
9+# Most commands execute very quickly. A timeout is used to catch commands which
10+# hang. Sometimes a hanging command can be handled, othertimes not. 3 minutes
11+# is used as the timeout as some BMCs respond slowly when a large amount of
12+# data is being returned. LP:1917652 was due to a slow responding BMC which
13+# timed out when IPMI._bmc_get_config() was called.
14+COMMAND_TIMEOUT = 60 * 3
15+
16
17 def exit_skipped():
18 """Write a result YAML indicating the test has been skipped."""
19@@ -174,7 +181,7 @@ class IPMI(BMCConfig):
20 proc = run(
21 cmd,
22 stdout=PIPE,
23- timeout=60,
24+ timeout=COMMAND_TIMEOUT,
25 )
26 except Exception:
27 print(
28@@ -215,7 +222,7 @@ class IPMI(BMCConfig):
29 "--commit",
30 "--key-pair=%s:%s=%s" % (section, key, value),
31 ],
32- timeout=60,
33+ timeout=COMMAND_TIMEOUT,
34 )
35 # If the value was set update the cache.
36 if section not in self._bmc_config:
37@@ -246,7 +253,7 @@ class IPMI(BMCConfig):
38 @staticmethod
39 @lru_cache(maxsize=1)
40 def _get_ipmi_locate_output():
41- return check_output(["ipmi-locate"], timeout=60).decode()
42+ return check_output(["ipmi-locate"], timeout=COMMAND_TIMEOUT).decode()
43
44 @staticmethod
45 @lru_cache(maxsize=1)
46@@ -261,7 +268,7 @@ class IPMI(BMCConfig):
47 check_output(
48 ["ipmitool", "lan", "print", i],
49 stderr=DEVNULL,
50- timeout=60,
51+ timeout=COMMAND_TIMEOUT,
52 ).decode(),
53 )
54 except (CalledProcessError, TimeoutExpired):
55@@ -559,7 +566,7 @@ class IPMI(BMCConfig):
56 "cipher_privs",
57 new_cipher_suite_privs,
58 ],
59- timeout=60,
60+ timeout=COMMAND_TIMEOUT,
61 )
62 return new_cipher_suite_privs
63
64@@ -794,7 +801,9 @@ class HPMoonshot(BMCConfig):
65 def detected(self):
66 try:
67 output = check_output(
68- ["ipmitool", "raw", "06", "01"], timeout=60, stderr=DEVNULL
69+ ["ipmitool", "raw", "06", "01"],
70+ timeout=COMMAND_TIMEOUT,
71+ stderr=DEVNULL,
72 ).decode()
73 except Exception:
74 return False
75@@ -806,7 +815,7 @@ class HPMoonshot(BMCConfig):
76
77 def _get_local_address(self):
78 output = check_output(
79- ["ipmitool", "raw", "0x2c", "1", "0"], timeout=60
80+ ["ipmitool", "raw", "0x2c", "1", "0"], timeout=COMMAND_TIMEOUT
81 ).decode()
82 return "0x%s" % output.split()[2]
83
84@@ -825,7 +834,7 @@ class HPMoonshot(BMCConfig):
85 "1",
86 "0",
87 ],
88- timeout=60,
89+ timeout=COMMAND_TIMEOUT,
90 ).decode()
91 return "0x%s" % output.split()[2]
92
93@@ -858,7 +867,7 @@ class HPMoonshot(BMCConfig):
94 "print",
95 "2",
96 ],
97- timeout=60,
98+ timeout=COMMAND_TIMEOUT,
99 ).decode()
100 m = re.search(
101 r"IP Address\s+:\s+"
102@@ -888,7 +897,7 @@ class HPMoonshot(BMCConfig):
103 "mcloc",
104 "-v",
105 ],
106- timeout=60,
107+ timeout=COMMAND_TIMEOUT,
108 ).decode()
109 local_chan = self._get_channel_number(local_address, output)
110 cartridge_chan = self._get_channel_number(node_address, output)
111@@ -932,13 +941,14 @@ class Wedge(BMCConfig):
112 # XXX ltrager 2020-09-16 - It would be better to get these values from
113 # /sys but no test system is available.
114 sys_manufacturer = check_output(
115- ["dmidecode", "-s", "system-manufacturer"], timeout=60
116+ ["dmidecode", "-s", "system-manufacturer"], timeout=COMMAND_TIMEOUT
117 ).decode()
118 prod_name = check_output(
119- ["dmidecode", "-s", "system-product-name"], timeout=60
120+ ["dmidecode", "-s", "system-product-name"], timeout=COMMAND_TIMEOUT
121 ).decode()
122 baseboard_prod_name = check_output(
123- ["dmidecode", "-s", "baseboard-product-name"], timeout=60
124+ ["dmidecode", "-s", "baseboard-product-name"],
125+ timeout=COMMAND_TIMEOUT,
126 ).decode()
127 if (
128 (sys_manufacturer == "Intel" and prod_name == "EPGSVR")
129@@ -961,7 +971,8 @@ class Wedge(BMCConfig):
130 # "fe80::ff:fe00:2" is the address for the device to the internal
131 # BMC network.
132 output = check_output(
133- ["ip", "-o", "a", "show", "to", "fe80::ff:fe00:2"], timeout=60
134+ ["ip", "-o", "a", "show", "to", "fe80::ff:fe00:2"],
135+ timeout=COMMAND_TIMEOUT,
136 ).decode()
137 # fe80::1 is the BMC's LLA.
138 return "fe80::1%%%s" % output.split()[1]
139@@ -1003,7 +1014,7 @@ class Wedge(BMCConfig):
140 password=self.password,
141 )
142 _, stdout, _ = client.exec_command(
143- "ip -o -4 addr show", timeout=60
144+ "ip -o -4 addr show", timeout=COMMAND_TIMEOUT
145 )
146 return (
147 stdout.read().decode().splitlines()[1].split()[3].split("/")[0]
148@@ -1103,7 +1114,7 @@ def main():
149 # XXX: andreserl 2013-04-09 bug=1064527: Try to detect if node
150 # is a Virtual Machine. If it is, do not try to detect IPMI.
151 try:
152- check_call(["systemd-detect-virt", "-q"], timeout=60)
153+ check_call(["systemd-detect-virt", "-q"], timeout=COMMAND_TIMEOUT)
154 except CalledProcessError:
155 pass
156 else:
157@@ -1120,11 +1131,11 @@ def main():
158 # The IPMI modules will fail to load if loaded on unsupported
159 # hardware.
160 try:
161- run(["sudo", "-E", "modprobe", module], timeout=60)
162+ run(["sudo", "-E", "modprobe", module], timeout=COMMAND_TIMEOUT)
163 except TimeoutExpired:
164 pass
165 try:
166- run(["sudo", "-E", "udevadm", "settle"], timeout=60)
167+ run(["sudo", "-E", "udevadm", "settle"], timeout=COMMAND_TIMEOUT)
168 except TimeoutExpired:
169 pass
170 detect_and_configure(args, bmc_config_path)
171diff --git a/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py b/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py
172index d1674af..7fb5cc5 100644
173--- a/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py
174+++ b/src/metadataserver/builtin_scripts/commissioning_scripts/tests/test_bmc_config.py
175@@ -167,7 +167,7 @@ EndSection
176 "--commit",
177 f"--key-pair={section}:{key}={value}",
178 ],
179- timeout=60,
180+ timeout=bmc_config.COMMAND_TIMEOUT,
181 ),
182 )
183 self.assertEqual({section: {key: value}}, self.ipmi._bmc_config)
184@@ -201,7 +201,7 @@ EndSection
185 "--commit",
186 "--key-pair=User2:SOL_Payload_Access=Yes",
187 ],
188- timeout=60,
189+ timeout=bmc_config.COMMAND_TIMEOUT,
190 ),
191 )
192 # Verify cache has been updated
193@@ -248,7 +248,9 @@ EndSection
194 self.assertEqual(ret, self.ipmi._get_ipmi_locate_output())
195 self.assertThat(
196 self.mock_check_output,
197- MockCalledOnceWith(["ipmi-locate"], timeout=60),
198+ MockCalledOnceWith(
199+ ["ipmi-locate"], timeout=bmc_config.COMMAND_TIMEOUT
200+ ),
201 )
202
203 def test_get_ipmitool_lan_print(self):
204@@ -271,17 +273,17 @@ EndSection
205 call(
206 ["ipmitool", "lan", "print", "0"],
207 stderr=DEVNULL,
208- timeout=60,
209+ timeout=bmc_config.COMMAND_TIMEOUT,
210 ),
211 call(
212 ["ipmitool", "lan", "print", "1"],
213 stderr=DEVNULL,
214- timeout=60,
215+ timeout=bmc_config.COMMAND_TIMEOUT,
216 ),
217 call(
218 ["ipmitool", "lan", "print", "2"],
219 stderr=DEVNULL,
220- timeout=60,
221+ timeout=bmc_config.COMMAND_TIMEOUT,
222 ),
223 ),
224 )
225@@ -742,7 +744,7 @@ EndSection
226 "cipher_privs",
227 "XXXaXXXXaXXXaXXXX",
228 ],
229- timeout=60,
230+ timeout=bmc_config.COMMAND_TIMEOUT,
231 )
232
233 def test_configure_ipmitool_cipher_suite_ids_does_nothing_when_set(self):
234@@ -814,7 +816,7 @@ EndSection
235 "cipher_privs",
236 "XXXaXXXXXXXXXXXX",
237 ],
238- timeout=60,
239+ timeout=bmc_config.COMMAND_TIMEOUT,
240 )
241 self.assertEqual("", self.ipmi._cipher_suite_id)
242
243@@ -1132,7 +1134,9 @@ class TestHPMoonshot(MAASTestCase):
244 self.assertThat(
245 self.mock_check_output,
246 MockCalledOnceWith(
247- ["ipmitool", "raw", "06", "01"], timeout=60, stderr=DEVNULL
248+ ["ipmitool", "raw", "06", "01"],
249+ timeout=bmc_config.COMMAND_TIMEOUT,
250+ stderr=DEVNULL,
251 ),
252 )
253
254@@ -1150,7 +1154,8 @@ class TestHPMoonshot(MAASTestCase):
255 self.assertThat(
256 self.mock_check_output,
257 MockCalledOnceWith(
258- ["ipmitool", "raw", "0x2c", "1", "0"], timeout=60
259+ ["ipmitool", "raw", "0x2c", "1", "0"],
260+ timeout=bmc_config.COMMAND_TIMEOUT,
261 ),
262 )
263
264@@ -1179,7 +1184,7 @@ class TestHPMoonshot(MAASTestCase):
265 "print",
266 "2",
267 ],
268- timeout=60,
269+ timeout=bmc_config.COMMAND_TIMEOUT,
270 ),
271 )
272
273@@ -1207,7 +1212,7 @@ class TestHPMoonshot(MAASTestCase):
274 "print",
275 "2",
276 ],
277- timeout=60,
278+ timeout=bmc_config.COMMAND_TIMEOUT,
279 ),
280 )
281
282@@ -1276,7 +1281,7 @@ class TestHPMoonshot(MAASTestCase):
283 "mcloc",
284 "-v",
285 ],
286- timeout=60,
287+ timeout=bmc_config.COMMAND_TIMEOUT,
288 ),
289 )
290 self.assertThat(
291@@ -1544,18 +1549,34 @@ class TestMain(MAASTestCase):
292
293 self.assertThat(
294 self.mock_check_call,
295- MockCalledOnceWith(["systemd-detect-virt", "-q"], timeout=60),
296+ MockCalledOnceWith(
297+ ["systemd-detect-virt", "-q"],
298+ timeout=bmc_config.COMMAND_TIMEOUT,
299+ ),
300 )
301 self.assertThat(
302 mock_run,
303 MockCallsMatch(
304 call(
305- ["sudo", "-E", "modprobe", "ipmi_msghandler"], timeout=60
306+ ["sudo", "-E", "modprobe", "ipmi_msghandler"],
307+ timeout=bmc_config.COMMAND_TIMEOUT,
308+ ),
309+ call(
310+ ["sudo", "-E", "modprobe", "ipmi_devintf"],
311+ timeout=bmc_config.COMMAND_TIMEOUT,
312+ ),
313+ call(
314+ ["sudo", "-E", "modprobe", "ipmi_si"],
315+ timeout=bmc_config.COMMAND_TIMEOUT,
316+ ),
317+ call(
318+ ["sudo", "-E", "modprobe", "ipmi_ssif"],
319+ timeout=bmc_config.COMMAND_TIMEOUT,
320+ ),
321+ call(
322+ ["sudo", "-E", "udevadm", "settle"],
323+ timeout=bmc_config.COMMAND_TIMEOUT,
324 ),
325- call(["sudo", "-E", "modprobe", "ipmi_devintf"], timeout=60),
326- call(["sudo", "-E", "modprobe", "ipmi_si"], timeout=60),
327- call(["sudo", "-E", "modprobe", "ipmi_ssif"], timeout=60),
328- call(["sudo", "-E", "udevadm", "settle"], timeout=60),
329 ),
330 )
331 self.assertThat(mock_detect_and_configure, MockCalledOnce())

Subscribers

People subscribed via source and target branches