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

Update container_checker for multi-asic devices when state is 'always_enabled' #10067

Merged
merged 2 commits into from
Feb 24, 2022
Merged
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
16 changes: 11 additions & 5 deletions files/image_config/monit/container_checker
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_expected_running_containers():

expected_running_containers = set()
always_running_containers = set()

for container_name in feature_table.keys():
if feature_table[container_name]["state"] not in ["disabled", "always_disabled"]:
if multi_asic.is_multi_asic():
Expand All @@ -51,14 +51,20 @@ def get_expected_running_containers():
num_asics = multi_asic.get_num_asics()
for asic_id in range(num_asics):
expected_running_containers.add(container_name + str(asic_id))
elif feature_table[container_name]["state"] == 'always_enabled':
always_running_containers.add(container_name)
else:
expected_running_containers.add(container_name)

if feature_table[container_name]["state"] == 'always_enabled':
if multi_asic.is_multi_asic():
Copy link
Contributor

Choose a reason for hiding this comment

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

has_global_scope -- Is this true only for Database container?

Copy link
Contributor Author

@wenyiz2021 wenyiz2021 Feb 23, 2022

Choose a reason for hiding this comment

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

has_global_scope is True for other containers e.g. lldp, dhcp_relay, mux, etc
but here the if statement is under "if feature_table[container_name]["state"] == 'always_enabled'", which is only True for mux and databse, while mux doesn't seem to be a container as shown in 'docker ps -a'

Feature State AutoRestart SystemState UpdateTime ContainerId Version SetOwner CurrentOwner RemoteState


acms enabled enabled up 2022-02-22 19:20:47 acms local local none
bgp enabled enabled local
database always_enabled always_enabled local
dhcp_relay enabled enabled up 2022-02-22 19:21:10 dhcp_relay 20201231.54 kube local
lldp enabled enabled up 2022-02-22 19:20:53 lldp 20201231.54 kube local
mux always_disabled enabled local
pmon enabled enabled up 2022-02-22 19:20:48 pmon 20201231.54 kube local
radv enabled enabled up 2022-02-22 19:21:06 radv 20201231.54 kube local
restapi enabled enabled up 2022-02-22 19:20:47 restapi local local none
snmp enabled enabled up 2022-02-22 19:23:56 snmp 20201231.54 kube local
swss enabled enabled local
syncd enabled enabled local
teamd enabled enabled local
telemetry enabled enabled up 2022-02-22 19:23:59 telemetry 20201231.54 kube local

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 previous code on line 54 and 55 will add container with 'state' as 'always_enabled' to always_running_containers only if single-asic. I moved that condition one upper level, and let it decide separately for multi-asic and single-asic.

if feature_table[container_name]["has_global_scope"] == "True":
always_running_containers.add(container_name)
if feature_table[container_name]["has_per_asic_scope"] == "True":
num_asics = multi_asic.get_num_asics()
for asic_id in range(num_asics):
always_running_containers.add(container_name + str(asic_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please verify that indeed the container is running?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Renuka,
f2a9c49b7857 docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database4
bca510cdfd1c docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database5
f109ac36ee86 docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database1
8ba15862639d docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database2
c669bf6e465f docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database3
95801b05ada1 docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database0
df566813a493 docker-database:latest "/usr/local/bin/dock…" 23 hours ago Up 21 hours database

else:
always_running_containers.add(container_name)
return expected_running_containers, always_running_containers


def get_current_running_from_DB(always_running_containers):
"""
@summary: This function will get the current running container list
Expand Down