Skip to content

Commit 29dacbe

Browse files
authored
Improve guestregister service diagnostics and recovery validation (#447)
Enhance rescue block by providing more detailed error reporting for cloudregister and zypper logs, including new tracking for 'THROW' errors. Update the final assertion to allow the task to succeed if the service restart attempt successfully restores the registration state. This prevents false positives for transient race conditions that were correctly handled during the rescue phase.
1 parent 7a2c5a9 commit 29dacbe

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

ansible/playbooks/tasks/check-guestregister-service.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
ansible.builtin.debug:
4545
msg:
4646
- "--- Rescue Block Entry Diagnosis for {{ inventory_hostname }} ---"
47-
- "Task 'Wait for cloud guest registration' result for this host: {{ guestregister_service_state | default('VARIABLE NOT DEFINED') }}"
48-
- "Individual host failure detected: {{ (guestregister_service_state.failed | default(false)) | ternary('YES', 'NO') }}"
49-
- "Current any_errors_fatal setting: {{ any_errors_fatal | default('NOT SET (default is False)') }}"
50-
- "Active hosts remaining in play: {{ ansible_play_hosts_all }}"
47+
- "Task 'Wait for cloud guest registration' result for this host:"
48+
- " rc: {{ guestregister_service_state.rc | default('UNKNOWN') }}"
49+
- " stdout: {{ guestregister_service_state.stdout_lines | default('UNKNOWN') }}"
5150

5251
# [DIAGNOSTIC] Initial service status and logs collection
5352
- name: Get guestregister.service status
@@ -72,19 +71,27 @@
7271
- name: Extract specific errors from cloudregister log
7372
ansible.builtin.shell: |
7473
set -o pipefail
75-
grep -E "ERROR:|WARNING:|401 Unauthorized|422|Removing (repository artifacts|credentials|repo|service):" /var/log/cloudregister | tail -n 20
74+
grep -E "ERROR:|WARNING:|401 (None|Unauthorized)|422|failed|(Deleting|Removing).*(repository artifacts|credentials|repo|service)|registration complete|No credentials entry" /var/log/cloudregister
7675
register: tailored_cloudregister_errors
7776
failed_when: false
7877
changed_when: false
7978

8079
- name: Search for Zypper lock in zypper.log
8180
ansible.builtin.shell: |
8281
set -o pipefail
83-
grep "System management is locked by the application with pid" /var/log/zypper.log | tail -n 5
82+
grep "System management is locked by the application with pid" /var/log/zypper.log
8483
register: zypper_log_lock_error
8584
failed_when: false
8685
changed_when: false
8786

87+
- name: Search for Zypper THROW in zypper.log
88+
ansible.builtin.shell: |
89+
set -o pipefail
90+
grep "THROW" /var/log/zypper.log
91+
register: zypper_log_throw
92+
failed_when: false
93+
changed_when: false
94+
8895
- name: Check repository state after failure
8996
ansible.builtin.command: zypper lr -u
9097
register: zypper_repos_after_fail
@@ -126,6 +133,7 @@
126133
- "--- Tailored Diagnostics for guestregister.service failure ---"
127134
- "Cloudregister Errors Summary: {{ tailored_cloudregister_errors.stdout_lines | default('None found') }}"
128135
- "Zypper Log Lock Errors: {{ zypper_log_lock_error.stdout_lines | default('None found') }}"
136+
- "Zypper Log throws: {{ zypper_log_throw.stdout_lines | default('None found') }}"
129137
- "Racing PIDs and Commands: {{ racing_pids_discovery.stdout_lines | default('No racing PIDs identified') }}"
130138
- "Clean-up/Reset detected: {{ 'Removing' in (tailored_cloudregister_errors.stdout | default('')) }}"
131139
- "SMT entries in /etc/hosts: {{ hosts_smt_entries.stdout_lines | default('Not found') }}"
@@ -262,5 +270,8 @@
262270

263271
- name: Fail if guestregister.service is not in the expected state
264272
ansible.builtin.assert:
265-
that: false
273+
that:
274+
- "'ActiveState=inactive' in restart_state.stdout"
275+
- "'Result=success' in restart_state.stdout"
276+
- "not to_be_registered"
266277
fail_msg: "FATAL: guestregister.service is not in the expected state (inactive/success) after retries. Check logs above for details."

0 commit comments

Comments
 (0)