Skip to content
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

Banner HLD #1361

Merged
merged 1 commit into from
Dec 3, 2023
Merged

Banner HLD #1361

merged 1 commit into from
Dec 3, 2023

Conversation

SviatoslavBoichuk
Copy link
Contributor

@SviatoslavBoichuk SviatoslavBoichuk commented Jun 12, 2023

This document provides general information about Banner implementation in SONiC

The scope of this document is to cover definition, design and implementation of SONiC Banner feature and Banner CLI.

PR title state context
Banner YANG Model/SystemD service GitHub issue/pull request detail GitHub pull request check contexts
Banner Config handler GitHub issue/pull request detail GitHub pull request check contexts
Banner Config DB GitHub issue/pull request detail GitHub pull request check contexts
Banner CLI GitHub issue/pull request detail GitHub pull request check contexts

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 12, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: SviatoslavBoichuk (e82c388)

@linux-foundation-easycla
Copy link

CLA Missing ID CLA Not Signed


description "BANNER_MESSAGE part of config_db.json";

container pre_login {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


}

container post_login {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of adding 3 containers i.e pre_login, post_login & post_logout, can we have the BANNER table name and key as "global" and three 3 attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


}

container post_login {
Copy link
Collaborator

@venkatmahalingam venkatmahalingam Jun 27, 2023

Choose a reason for hiding this comment

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

Rename the field name as motd and add descriptions for all three fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@yxieca
Copy link
Contributor

yxieca commented Jun 27, 2023

Questions:

  1. Does banner feature support dynamic contents, e.g. uptime, date, login IP, etc.
  2. How does banner feature support contents with multiple lines?

@zhangyanzhao
Copy link
Collaborator

@SviatoslavBoichuk
Copy link
Contributor Author

Questions:

  1. Does banner feature support dynamic contents, e.g. uptime, date, login IP, etc.
Answer: No, it is not supported.
  1. How does banner feature support contents with multiple lines?
Answer: yes, I updated HLD - please see detail there.

yxieca
yxieca previously approved these changes Aug 7, 2023
@yxieca
Copy link
Contributor

yxieca commented Aug 7, 2023

Questions:

  1. Does banner feature support dynamic contents, e.g. uptime, date, login IP, etc.
Answer: No, it is not supported.

What does it take to get something like this? https://gist.github.com/bearlike/d5c90dd24e43e0c5cf89342ac4331358

@liat-grozovik
Copy link
Collaborator

@SviatoslavBoichuk pls refer to the latest questions and if no further open issues, i will go a head and merge it.
when do we expect code PRs to be avaialble?

@SviatoslavBoichuk
Copy link
Contributor Author

Questions:

  1. Does banner feature support dynamic contents, e.g. uptime, date, login IP, etc.
Answer: No, it is not supported.

What does it take to get something like this? https://gist.github.com/bearlike/d5c90dd24e43e0c5cf89342ac4331358

Originally feature was designed to provide opportunity for users to configure the Banner messages (even if it is just simple string) via CLI commands and save it to Redis Config DB, so it will be restored after SONiC upgrade (better user experiance).

In case of the scripts - I don't see easy way to provide the same functionality for user as I described above.

@SviatoslavBoichuk
Copy link
Contributor Author

@SviatoslavBoichuk pls refer to the latest questions and if no further open issues, i will go a head and merge it. when do we expect code PRs to be avaialble?

Provided reply to the latest questions. The code PRs planned to be published ~ middle of September (in worst case end of September).

| :-----------: | :-----------------------------------------------------------------------------: |
| login | Display a banner to the users connected locally or remotely before login prompt |
| motd | Display a banner to the users after login prompt |
| logout | Display a logout banner to the users connected locally or remotely |
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Please explain the purpose or use case of logout banner requirement.
  2. Mention the Linux banner files (/etc/banner, /etc/motd, etc) where the banners are maintained for completeness

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Purpose to have logout message is - full interface (login-motd-logout)
  2. Updated HLD and mentioned Linux files

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, still not convinced about the use case for logout banner. Linux does not support logout banner natively, seems to be something new being brought as SONiC specific. I would recommend to add logout banner, if valid use case is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logout message supported by bash (bash.bash_logout file). The logout message will be written from ConfDB to new file: /etc/logout_message. And "bash.bash_logout" will be modified to read logout message from "/etc/logout_message" and display it (via 'echo'). Some vendors, for example Mellanox (https://docs.nvidia.com/networking/display/onyxv3102002/ui+commands#src-80577389_UICommands-Banner) support logout banner, so it might be useful for users.

**This feature will support the following functionality:**
1. Show Banner configuration
2. Configure Banner
1. Feature state
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is enable / disable of banner feature is supported? If so, unable to locate the respective commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated HLD with feature state enable/disable command (please see section 2.3.1 Config command group)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be great if below details are added into HLD

  1. The behavior when feature state is disabled ==> Is it intended to revert back to default SONiC banner? If not, what is the procedure to revert back to default banner?
  2. The behavior of when feature state is enabled ==> Is user configured banner will be applied into system only when state is enabled?
  3. The behavior of banner configuration when feature state is disabled
  4. The provisions to revert back to default banners independently, looks like currently the feature state disabled option is meant for that (if the assumption is correct). Both banners will be reverted to default. I would suggest to add default option in both command syntax (config login banner default, config motd banner default) and remove the feature enable / disable option. This will provide flexibility to user to manage the banners independently and consistent with other configuration commands to set default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated Flows section in HLD with explanation regarding feature state.
Regarding reverting back to default SONiC banners. AFAIK SONiC OS doesn't have an infra to restore configuration to default values, and whatever configuration you changed - to revert it back to "default" you need to configured "default" value again manually. The same is for this feature.


<!-- omit in toc -->
### 2.5.2 Banner config flow
![Banner config flow](images/banner_config_diagram.png "Figure 3: Banner config flow")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would recommend to update the banner files directly from hostcfgd service. This will avoid introducing another service (banner-config) which is intended to fetch the data from redis & update the banner files.
Is there any advantage of introducing new host service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The hostcfgd (after reboot) start later then network service - means banner might not be updated when user login to the system.
It is main goal to use the systemd service as single point where the banners will be updated and it will start before network service.

3. Save configuration and reboot device - expected to see configured message after login prompt.
3. Configure logout banner message
1. Logout form system - expected to see configured logout message.
2. Do not save configuration and reboot device. Logout from system after reboot - expected to see default message before login prompt.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hope that expected result shall be the default logout banner message after login + logout sequence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

3. Configure logout banner message
1. Logout form system - expected to see configured logout message.
2. Do not save configuration and reboot device. Logout from system after reboot - expected to see default message before login prompt.
3. Save configuration and reboot device. Logout from system after reboot expected to see configured message before login prompt.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hope that expected result shall be the configured logout banner message after login + logout sequence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@liat-grozovik
Copy link
Collaborator

@yxieca @venkatmahalingam @dharmaraj-gurusamy any further comments? if not we wish to merge this PR and share the code PRs soon

This feature require access to SONiC DB. All messages (MOTD, login and logout) saved into the SONiC config database. Hostcfgd will listen for the configuration changes in corresponding tables and restart banner-config service. Banner config service - it is simple SystemD service which runs before we get SSH connection. It reads configured messages from database and apply it to Linux.

**The Linux files will be used:**
1. /etc/issue.net and /etc/issue - Login message
Copy link
Collaborator

Choose a reason for hiding this comment

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

I hope that Debian uses /etc/login.warn file as default login banner file & Linux flavors use /etc/issue and /etc/issue.net files. Please correct me, if wrong. If so, any reason why it is not being updated & introducing new files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't see /etc/login.warn file is used by SONiC. The messages is configured to /etc/motd, /etc/issue.net files.
The Banner feature is going use the same files. We introduce only 1 new file: /etc/logout_message for logout banner.
This file will be used in "bash.bash_logout" script to read and display configured logout message.

| :-----------: | :-----------------------------------------------------------------------------: |
| login | Display a banner to the users connected locally or remotely before login prompt |
| motd | Display a banner to the users after login prompt |
| logout | Display a logout banner to the users connected locally or remotely |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, still not convinced about the use case for logout banner. Linux does not support logout banner natively, seems to be something new being brought as SONiC specific. I would recommend to add logout banner, if valid use case is available.

**This feature will support the following functionality:**
1. Show Banner configuration
2. Configure Banner
1. Feature state
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be great if below details are added into HLD

  1. The behavior when feature state is disabled ==> Is it intended to revert back to default SONiC banner? If not, what is the procedure to revert back to default banner?
  2. The behavior of when feature state is enabled ==> Is user configured banner will be applied into system only when state is enabled?
  3. The behavior of banner configuration when feature state is disabled
  4. The provisions to revert back to default banners independently, looks like currently the feature state disabled option is meant for that (if the assumption is correct). Both banners will be reverted to default. I would suggest to add default option in both command syntax (config login banner default, config motd banner default) and remove the feature enable / disable option. This will provide flexibility to user to manage the banners independently and consistent with other configuration commands to set default values.

@liat-grozovik
Copy link
Collaborator

@SviatoslavBoichuk
do you have already the code PRs available? can you please add them to the PR description according to the tracking template? i will then be able to merge the HLD

@SviatoslavBoichuk
Copy link
Contributor Author

@SviatoslavBoichuk do you have already the code PRs available? can you please add them to the PR description according to the tracking template? i will then be able to merge the HLD

Hi @liat-grozovik , I update description with code PRs.

@liat-grozovik liat-grozovik merged commit 6c0b90b into sonic-net:master Dec 3, 2023
1 check passed
@liat-grozovik liat-grozovik changed the title [SONiC] Banner HLD Banner HLD Dec 3, 2023

This feature require access to SONiC DB. All messages (MOTD, login and logout) saved into the SONiC config database. Hostcfgd will listen for the configuration changes in corresponding tables and restart banner-config service. Banner config service - it is simple SystemD service which runs before we get SSH connection. It reads configured messages from database and apply it to Linux.

**The Linux files will be used:**
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering why should user not directly update the linux files. What is the value added by this HLD?

Is there a really scenarios that we need to config banner per device? If no, maybe a single command line to update these "Linux files" will be good enough. No dependency on database, hostcfgd, no need to have another service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The banner messages are user configuration.
We would like to provide to user simple CLI commands to configure messages.
Saved banners to Config DB will be restored after upgrade, so user don't need to set them again.

@skg-net
Copy link
Member

skg-net commented Feb 6, 2024

@SviatoslavBoichuk Can you please update the Quality Metric (Alpha/Beta/GA) for the feature either in this PR comments or in HLD itself based on https://github.com/sonic-net/SONiC/blob/master/doc/SONiC%20feature%20quality%20definition.md
Thanks

liat-grozovik pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Apr 16, 2024
- Why I did it
Added Banner feature related services according to HLD: sonic-net/SONiC#1361

- How I did it
Added banner-config systemd service, YANG model for new ConfDB table and YANG model tests

- How to verify it
Manual test

Co-authored-by: Sviatoslav Boichuk <sviatoslavb@nvidia.com>
liat-grozovik pushed a commit to sonic-net/sonic-swss-common that referenced this pull request May 7, 2024
- Why I did it
Added Banner feature related Config DB table according to HLD: sonic-net/SONiC#1361

- How I did it
Added Banner table name to schema.h.

Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
arfeigin pushed a commit to arfeigin/sonic-swss-common that referenced this pull request Jun 27, 2024
- Why I did it
Added Banner feature related Config DB table according to HLD: sonic-net/SONiC#1361

- How I did it
Added Banner table name to schema.h.

Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

9 participants