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

Fix multi-asic behaviour for watermarkstat #3060

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 146 additions & 12 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,38 @@ def watermark():
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
@watermark.command('headroom')
def clear_wm_pg_headroom():
def clear_wm_pg_headroom(namespace):
"""Clear user headroom WM for pg"""
command = ['watermarkstat', '-c', '-t', 'pg_headroom']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('shared')
def clear_wm_pg_shared():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_pg_shared(namespace):
"""Clear user shared WM for pg"""
command = ['watermarkstat', '-c', '-t', 'pg_shared']
if namespace:
command += ['-n', str(namespace)]
run_command(command)

@priority_group.group()
Expand All @@ -261,16 +283,38 @@ def persistent_watermark():
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@persistent_watermark.command('headroom')
def clear_pwm_pg_headroom():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_pg_headroom(namespace):
"""Clear persistent headroom WM for pg"""
command = ['watermarkstat', '-c', '-p', '-t', 'pg_headroom']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('shared')
def clear_pwm_pg_shared():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_pg_shared(namespace):
"""Clear persistent shared WM for pg"""
command = ['watermarkstat', '-c', '-p', '-t', 'pg_shared']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


Expand All @@ -285,69 +329,159 @@ def watermark():
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@watermark.command('unicast')
def clear_wm_q_uni():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_uni(namespace):
"""Clear user WM for unicast queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_uni']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('multicast')
def clear_wm_q_multi():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_multi(namespace):
"""Clear user WM for multicast queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_multi']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@watermark.command('all')
def clear_wm_q_all():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_wm_q_all(namespace):
"""Clear user WM for all queues"""
command = ['watermarkstat', '-c', '-t', 'q_shared_all']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@queue.group(name='persistent-watermark')
def persistent_watermark():
"""Clear queue persistent WM. One does not simply clear WM, root is required"""
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")


@persistent_watermark.command('unicast')
def clear_pwm_q_uni():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_uni(namespace):
"""Clear persistent WM for persistent queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_uni']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('multicast')
def clear_pwm_q_multi():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_multi(namespace):
"""Clear persistent WM for multicast queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_multi']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@persistent_watermark.command('all')
def clear_pwm_q_all():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def clear_pwm_q_all(namespace):
"""Clear persistent WM for all queues"""
command = ['watermarkstat', '-c', '-p', '-t', 'q_shared_all']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@cli.group(name='headroom-pool')
def headroom_pool():
"""Clear headroom pool WM"""
pass


@headroom_pool.command('watermark')
def watermark():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def watermark(namespace):
"""Clear headroom pool user WM. One does not simply clear WM, root is required"""
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")

command = ['watermarkstat', '-c', '-t', 'headroom_pool']
if namespace:
command += ['-n', str(namespace)]
run_command(command)


@headroom_pool.command('persistent-watermark')
def persistent_watermark():
@click.option('--namespace',
'-n',
'namespace',
default=None,
type=str,
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def persistent_watermark(namespace):
"""Clear headroom pool persistent WM. One does not simply clear WM, root is required"""
if os.geteuid() != 0:
sys.exit("Root privileges are required for this operation")

command = ['watermarkstat', '-c', '-p', '-t', 'headroom_pool']
if namespace:
command += ['-n', str(namespace)]
run_command(command)

#
Expand Down
Loading
Loading