Azure / Azure/WALinuxAgent

[BUG] cloud-init service status checking log is confusing

Open
#1,772 4 comments 0 reactions 0 assignees View on GitHub
provisioning triaged
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

**Describe the bug: A clear and concise description of what the bug is.**
WALA reports these 2 logs if cloud-init-local.service is disabled, which may not work as expected:
INFO Daemon Error getting cloud-init enabled status from systemctl: Command '['systemctl', 'is-enabled', 'cloud-init-local.service']' returned non-zero exit status 1.
INFO Daemon Error getting cloud-init enabled status from service: Command '['service', 'cloud-init', 'status']' returned non-zero exit status 4.

Steps:
Create a VM with WALA installed and check waagent.log

**Distro and WALinuxAgent details (please complete the following information):**
- Distro and Version: RHEL-8.2
- WALinuxAgent version 2.2.45

**Additional context**
```
def _cloud_init_is_enabled_systemd():
try:
systemctl_output = subprocess.check_output([
'systemctl',
'is-enabled',
'cloud-init-local.service'
], stderr=subprocess.STDOUT).decode('utf-8').replace('\n', '')

unit_is_enabled = systemctl_output == 'enabled'
except Exception as exc:
logger.info('Error getting cloud-init enabled status from systemctl: {0}'.format(exc))
unit_is_enabled = False
```
The "systemctl is-enabled cloud-init-local.service will return 1 if status is "disabled". It will raise exception in subprocess.check_output and report 'Error getting cloud-init enabled status' which isn't correct.

Besides,
```
def cloud_init_is_enabled():
unit_is_enabled = _cloud_init_is_enabled_systemd() or _cloud_init_is_enabled_service()
```
It seems that the "_cloud_init_is_enabled_service()" function calls "service cloud-init status" command, which seems doesn't check whether the service is enabled but check the service running status. Not sure if it is by design. If not, please consider chkconfig.

Thanks!

Br,
Yuxin Sun

Contributor guide

Open the contributing guide

Research direction

Search for _cloud_init_is_enabled_systemd() and cloud_init_is_enabled(), then reproduce the cloud-init-local.service checks described in waagent.log on RHEL-8.2. Determine whether the fallback should test enabled state or running state, and verify that disabled services produce an accurate log message and the intended status behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, python
Domain
devops, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.