Skip to content

Commit

Permalink
add master_identifier to supervisorctl sstate and instance_status
Browse files Browse the repository at this point in the history
  • Loading branch information
julien6387 committed Aug 7, 2023
1 parent b9f788d commit 21de75e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
Such a **Supvisors** instance is considered active and is updated with received events but cannot be part of any
starting sequence until all starting jobs in progress are completed.

* Add `master_identifier` to the output of the XML-RPCs `get_supvisors_state` and `get_instances_info`.
The `supervisorctl` commands `sstate` and `instance_status` have also been updated.

* Highlight the process line hovered by the cursor in the **Supvisors** Web UI.

* Remove the figures from the **Supvisors** Web UI when `matplotlib` is not installed.
Expand Down
16 changes: 12 additions & 4 deletions supvisors/supvisorsctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,19 @@ def do_sstate(self, _):
self.ctl.output(f'ERROR ({e.faultString})')
self.ctl.exitstatus = LSBInitExitStatuses.GENERIC
else:
max_master = ControllerPlugin.max_template([state_modes], 'master_identifier', 'Master')
max_starting = ControllerPlugin.max_template([state_modes], 'starting_jobs', 'Starting')
max_stopping = ControllerPlugin.max_template([state_modes], 'stopping_jobs', 'Stopping')
template = f'%(state)-16s%(discovery)-11s%(starting)-{max_starting}s%(stopping)-{max_stopping}s'
template = (f'%(state)-16s%(discovery)-11s%(master)-{max_master}s%(starting)-{max_starting}s'
f'%(stopping)-{max_stopping}s')
# print title
payload = {'state': 'State', 'discovery': 'Discovery', 'starting': 'Starting', 'stopping': 'Stopping'}
payload = {'state': 'State', 'discovery': 'Discovery', 'master': 'Master',
'starting': 'Starting', 'stopping': 'Stopping'}
self.ctl.output(template % payload)
# print data
line = template % {'state': state_modes['fsm_statename'],
'discovery': state_modes['discovery_mode'],
'master': state_modes['master_identifier'],
'starting': state_modes['starting_jobs'],
'stopping': state_modes['stopping_jobs']}
self.ctl.output(line)
Expand Down Expand Up @@ -175,12 +179,14 @@ def do_instance_status(self, arg):
max_node_names = ControllerPlugin.max_template(info_list, 'node_name', 'Node')
template = (f'%(identifier)-{max_identifiers}s%(node_name)-{max_node_names}s%(port)-7s'
'%(state)-11s%(discovery)-11s%(load)-6s%(ltime)-10s%(counter)-9s%(failure)-9s'
'%(fsm_state)-16s%(starting)-10s%(stopping)-10s')
f'%(fsm_state)-16s%(discovery)-11s%(master)-{max_node_names}s'
'%(starting)-10s%(stopping)-10s')
# print title
payload = {'identifier': 'Supervisor', 'node_name': 'Node', 'port': 'Port',
'state': 'State', 'discovery': 'Discovery',
'load': 'Load', 'ltime': 'Time', 'counter': 'Counter', 'failure': 'Failure',
'fsm_state': 'FSM', 'starting': 'Starting', 'stopping': 'Stopping'}
'fsm_state': 'FSM', 'master': 'Master', 'discovery': 'Discovery',
'starting': 'Starting', 'stopping': 'Stopping'}
self.ctl.output(template % payload)
# check request args
identifiers = arg.split()
Expand All @@ -197,6 +203,8 @@ def do_instance_status(self, arg):
'counter': info['sequence_counter'],
'failure': info['process_failure'],
'fsm_state': info['fsm_statename'],
'discovery': info['discovery_mode'],
'master': info['master_identifier'],
'starting': info['starting_jobs'],
'stopping': info['stopping_jobs']}
self.ctl.output(template % payload)
Expand Down
9 changes: 6 additions & 3 deletions supvisors/tests/test_supvisorsctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def test_strategies(controller, plugin, mocked_check):
def test_sstate(controller, plugin, mocked_check):
""" Test the sstate request. """
mocked_rpc = plugin.supvisors().get_supvisors_state
mocked_rpc.return_value = {'fsm_statecode': 10, 'fsm_statename': 'running', 'discovery_mode': True,
mocked_rpc.return_value = {'fsm_statecode': 10, 'fsm_statename': 'running',
'discovery_mode': True, 'master_identifier': '10.0.0.1',
'starting_jobs': [], 'stopping_jobs': ['10.0.0.1', 'test']}
_check_call(controller, mocked_check, mocked_rpc, plugin.help_sstate, plugin.do_sstate, '', [call()])

Expand All @@ -324,12 +325,14 @@ def test_instance_status(controller, plugin, mocked_check):
'statename': 'running', 'discovery_mode': True,
'loading': 10, 'local_time': 1500, 'sequence_counter': 12,
'process_failure': False,
'fsm_statename': 'OPERATION', 'starting_jobs': True, 'stopping_jobs': False},
'fsm_statename': 'OPERATION', 'discovery_mode': False, 'master_identifier': '10.0.0.1',
'starting_jobs': True, 'stopping_jobs': False},
{'identifier': '10.0.0.2', 'node_name': '10.0.0.2', 'port': 60000,
'statename': 'stopped', 'discovery_mode': False,
'loading': 0, 'local_time': 100, 'sequence_counter': 15,
'process_failure': True,
'fsm_statename': 'CONCILATION', 'starting_jobs': False, 'stopping_jobs': True}]
'fsm_statename': 'CONCILATION', 'discovery_mode': True, 'master_identifier': 'hostname',
'starting_jobs': False, 'stopping_jobs': True}]
_check_call(controller, mocked_check, mocked_rpc, plugin.help_instance_status, plugin.do_instance_status,
'', [call()])
_check_call(controller, mocked_check, mocked_rpc, plugin.help_instance_status, plugin.do_instance_status,
Expand Down

0 comments on commit 21de75e

Please sign in to comment.