Skip to content

Add OS version to rsyslog template.#22111

Merged
qiluo-msft merged 12 commits intosonic-net:masterfrom
liuh-80:dev/liuh/add_syslog_osversion
Apr 29, 2025
Merged

Add OS version to rsyslog template.#22111
qiluo-msft merged 12 commits intosonic-net:masterfrom
liuh-80:dev/liuh/add_syslog_osversion

Conversation

@liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Mar 21, 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.

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

Add OS version to rsyslog template.

Link to config_db schema for YANG module changes

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

@liuh-80
Copy link
Contributor Author

liuh-80 commented Mar 24, 2025

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80
Copy link
Contributor Author

liuh-80 commented Apr 5, 2025

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 changed the title [POC] Add OS version to rsyslog template. Add OS version to rsyslog template. Apr 15, 2025
@liuh-80 liuh-80 marked this pull request as ready for review April 15, 2025 03:30
@liuh-80 liuh-80 requested a review from lguohan as a code owner April 15, 2025 03:30
@liuh-80 liuh-80 requested a review from qiluo-msft April 15, 2025 03:31

hostname=$(hostname)

syslog_with_osversion=$(sonic-db-cli CONFIG_DB hget "DEVICE_METADATA|localhost" "syslog_with_osversion")
Copy link
Collaborator

Choose a reason for hiding this comment

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

syslog_with_osversion

Do you need to change yang model?

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

Copy link
Collaborator

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comment

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@liuh-80
Copy link
Contributor Author

liuh-80 commented Apr 23, 2025

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft qiluo-msft merged commit 9b79cef into sonic-net:master Apr 29, 2025
19 checks passed
qiluo-msft pushed a commit to sonic-net/sonic-host-services that referenced this pull request Apr 29, 2025
…art rsyslog-config service (#245)

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.

#### Description for the changelog
Monitor rsyslog feature flag change and update rsyslog config by restart rsyslog-config service
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