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

[counters] Keep counters cache in a single directory #2232

Merged
merged 11 commits into from
Jul 27, 2022

Conversation

stepanblyschak
Copy link
Contributor

What I did

To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory.

How I did it

Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script.

How to verify it

Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

stepanblyschak and others added 3 commits June 15, 2022 21:05
Place all counters cache in a single temporary repository. Then, when
swss starts in cold or fast mode we can clear this directory. Before
this change, every application is storing counters cache file in a
different location under different names, so it is hard to manage the
cache and know which files in /tmp need to be cleaned.

Added UserCache class which helps creating application specific per-user
cache directories.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
@stepanblyschak stepanblyschak marked this pull request as ready for review June 24, 2022 11:53
@stepanblyschak
Copy link
Contributor Author

Request for 202111, 202205

@stepanblyschak stepanblyschak changed the title Counters cache [counters] Keep counters cache in a single directory Jun 24, 2022
@lgtm-com
Copy link

lgtm-com bot commented Jun 24, 2022

This pull request introduces 5 alerts when merging 913e376 into f64d280 - view on LGTM.com

new alerts:

  • 5 for Unused local variable

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
…tion is removed

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
…tion is removed

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
…tion is removed

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
@liat-grozovik
Copy link
Collaborator

@qiluo-msft , @yxieca could you please help to review or assing someone to do so?

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
@liat-grozovik liat-grozovik merged commit feeac84 into sonic-net:master Jul 27, 2022
liat-grozovik pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Jul 28, 2022
A change in sonic-utilities makes all cache files be saved into a
/tmp/cache. On swss restart this cache has to be removed in case swss
starts in cold or fast mode. A related cache restoration in the warmboot
finalizer script is also updated to use new location.

- Why I did it
To fix #9817. Clear the cache directory on swss.sh except for warm start.
Also, adopted finalize-warmboot script to take the cache directory.

- How I did it
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location.

- How to verify it
Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
@yxieca
Copy link
Contributor

yxieca commented Jul 28, 2022

@stepanblyschak please raise separate PR for 202205.

@stepanblyschak
Copy link
Contributor Author

@yxieca 202205 PR #2280

yxieca pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Aug 8, 2022
A change in sonic-utilities makes all cache files be saved into a
/tmp/cache. On swss restart this cache has to be removed in case swss
starts in cold or fast mode. A related cache restoration in the warmboot
finalizer script is also updated to use new location.

- Why I did it
To fix #9817. Clear the cache directory on swss.sh except for warm start.
Also, adopted finalize-warmboot script to take the cache directory.

- How I did it
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location.

- How to verify it
Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
skbarista pushed a commit to skbarista/sonic-buildimage that referenced this pull request Aug 17, 2022
…-net#11244)

A change in sonic-utilities makes all cache files be saved into a
/tmp/cache. On swss restart this cache has to be removed in case swss
starts in cold or fast mode. A related cache restoration in the warmboot
finalizer script is also updated to use new location.

- Why I did it
To fix sonic-net#9817. Clear the cache directory on swss.sh except for warm start.
Also, adopted finalize-warmboot script to take the cache directory.

- How I did it
A change in sonic-utilities makes all cache files be saved into a /tmp/cache. On swss restart this cache has to be removed in case swss starts in cold or fast mode. A related cache restoration in the warmboot finalizer script is also updated to use new location.

- How to verify it
Run togather with sonic-net/sonic-utilities#2232. Verify counters cache is removed on config reload, cold/fast reboots, swss restart.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
preetham-singh pushed a commit to preetham-singh/sonic-utilities that referenced this pull request Nov 21, 2022
- What I did
To fix sonic-net/sonic-buildimage#9817. Cache all counters in the same place. Created a UserCache helper class to access the cache directory.

- How I did it
Implemented UserCache class. Changed all stats commands to use new class. Adopted fast-reboot script.

- How to verify it
Run on the switch and verify counters stats command and clear commands work correctly. After config reload or cold/fast reboot counters cache is removed.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cached counter file is not cleared during config reload, causing portstat give wrong counter values
4 participants