Skip to content

Commit 32b7305

Browse files
committed
reboot-limit: handle empty dev group gracefully
The reboot-limit-dev target was failing when the dev group had no hosts, which is a common configuration when not using A/B testing. Fix by checking if the dev group has any hosts before attempting to run ansible-playbook. This allows reboot-limit-tests to work correctly even when only baseline hosts are configured. The check uses a simple grep to see if there are any hostnames listed after the [dev] group header in the hosts file. Generated-by: Claude AI Reviewed-by: Chuck Lever <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent cbff820 commit 32b7305

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

workflows/demos/reboot-limit/Makefile

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,24 @@ reboot-limit-baseline-reset:
175175
reboot-limit-tests: reboot-limit-baseline reboot-limit-dev
176176

177177
# Below are the corresponding dev targets
178+
# Check if dev group has hosts before running
178179
reboot-limit-dev: $(KDEVOPS_EXTRA_VARS)
179-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
180-
--limit 'dev' \
181-
playbooks/reboot-limit.yml \
182-
--tags vars,first_run,reset \
183-
--extra-vars=@./extra_vars.yaml \
184-
--extra-vars="reboot_limit_max=$(REBOOT_LIMIT_MAX)"
185-
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
186-
--limit 'dev' \
187-
playbooks/reboot-limit.yml \
188-
--tags vars,run_tests,copy_results \
189-
--extra-vars=@./extra_vars.yaml \
190-
--extra-vars="reboot_limit_max=$(REBOOT_LIMIT_MAX)"
180+
$(Q)if grep -A1 '^\[dev\]' hosts | grep -qE '^[a-zA-Z0-9]'; then \
181+
ansible-playbook $(ANSIBLE_VERBOSE) \
182+
--limit 'dev' \
183+
playbooks/reboot-limit.yml \
184+
--tags vars,first_run,reset \
185+
--extra-vars=@./extra_vars.yaml \
186+
--extra-vars="reboot_limit_max=$(REBOOT_LIMIT_MAX)" && \
187+
ansible-playbook $(ANSIBLE_VERBOSE) \
188+
--limit 'dev' \
189+
playbooks/reboot-limit.yml \
190+
--tags vars,run_tests,copy_results \
191+
--extra-vars=@./extra_vars.yaml \
192+
--extra-vars="reboot_limit_max=$(REBOOT_LIMIT_MAX)"; \
193+
else \
194+
echo "No hosts found in dev group, skipping dev tests"; \
195+
fi
191196

192197
reboot-limit-dev-loop:
193198
$(Q)$(REBOOT_LIMIT_LOOP) dev

0 commit comments

Comments
 (0)