Skip to content

Monitor rsyslog feature flag change and update rsyslog config by restart rsyslog-config service #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 29, 2025

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Apr 22, 2025

Monitor rsyslog feature flag change and update rsyslog config by restart rsyslog-config service

Why I did it

Another PR add new feature flag syslog_with_osversion
sonic-net/sonic-buildimage#22111

Work item tracking
  • Microsoft ADO (number only): 31890431

How I did it

Update hostcfgd to minitor DEVICE_METADATA table change and restart rsyslog-config service to update rsyslog template.

How to verify it

Pass all test case.
Manually verified the code change work:

admin@vlab-01:$ sonic-db-cli CONFIG_DB hset "DEVICE_METADATA|localhost" "syslog_with_osversion" "true"
1
admin@vlab-01:
$ sudo cat /var/log/syslog | grep "DeviceMetaCfg"
2025 Apr 22 08:38:12.642805 vlab-01 INFO hostcfgd: DeviceMetaCfg: Restart rsyslog-config after feature flag change to true

admin@vlab-01:$ sonic-db-cli CONFIG_DB hset "DEVICE_METADATA|localhost" "syslog_with_osversion" "false"
0
admin@vlab-01:
$ sudo cat /var/log/syslog | grep "DeviceMetaCfg"
2025 Apr 22 08:38:41.561592 vlab-01 INFO hostcfgd: DeviceMetaCfg: Restart rsyslog-config after feature flag change to false

admin@vlab-01:~$ sudo systemctl status rsyslog-config
● rsyslog-config.service - Update rsyslog configuration
Loaded: loaded (/lib/systemd/system/rsyslog-config.service; enabled-runtime; preset: enabled)
Active: active (exited) since Tue 2025-04-22 08:38:41 UTC; 23s ago
Process: 846029 ExecStart=/usr/bin/rsyslog-config.sh (code=exited, status=0/SUCCESS)
Main PID: 846029 (code=exited, status=0/SUCCESS)

Apr 22 08:38:40 vlab-01 systemd[1]: Starting rsyslog-config.service - Update rsyslog configuration...
Apr 22 08:38:41 vlab-01 systemd[1]: Finished rsyslog-config.service - Update rsyslog configuration.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Monitor rsyslog feature flag change and update rsyslog config by restart rsyslog-config service

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 requested a review from qiluo-msft April 22, 2025 10:15
scripts/hostcfgd Outdated
syslog.syslog(syslog.LOG_DEBUG,
f'DeviceMetaCfg: syslog with os version: {syslog_with_osversion}')

if syslog_with_osversion is None:
Copy link
Contributor

@qiluo-msft qiluo-msft Apr 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syslog_with_osversion

Should we check the new config with current running config, if only changed, restart service ? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

qiluo-msft pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Apr 29, 2025
Add OS version to rsyslog template.

Why I did it
Add OS version information to rsyslog will help investigation SONiC issue happened during OS upgrade.

Work item tracking
Microsoft ADO (number only): 31890431
How I did it
Add OS version to rsyslog template
Make this feature CONFIG_DB flag: DEVICE_METADATA table 'syslog_with_osversion' field
A hostcfgd PR to restart rsyslog-config service accotding to config change:
sonic-net/sonic-host-services#245

How to verify it
Pass all test case.
Manually verified the syslog contains version info after enable it.
@qiluo-msft qiluo-msft merged commit 8237b5d into sonic-net:master Apr 29, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants