Skip to content

Commit

Permalink
fix regression in supervisorctl application_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
julien6387 committed Aug 27, 2022
1 parent 6ee2aec commit 421e471
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Fix process CPU times in statistics so that children processes are all taken into account.

* Fix regression in `supervisorctl application_rules` where the former `distributed` entry was still used
instead of `distribution`.

* A process is not considered disabled anymore when process rules don't allow any candidate **Supvisors** instance.

* When `psutil` is not installed on a host, the statistics-related options of the Process and Host pages
Expand Down
14 changes: 7 additions & 7 deletions supvisors/supvisorsctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import errno
import socket
import sys

from types import MethodType

from supervisor import supervisorctl
Expand All @@ -32,7 +31,7 @@
from supervisor.supervisorctl import Controller, ControllerPluginBase, LSBInitExitStatuses

from .rpcinterface import API_VERSION, RPCInterface, expand_faults
from .ttypes import ConciliationStrategies, StartingStrategies, PayloadList, Payload, enum_names
from .ttypes import ConciliationStrategies, StartingStrategies, PayloadList, enum_names
from .utils import simple_localtime


Expand Down Expand Up @@ -256,10 +255,10 @@ def do_application_rules(self, arg):
max_appli = ControllerPlugin.max_template(rules_list, 'application_name', 'Application')
max_identifiers = ControllerPlugin.max_template(rules_list, 'identifiers', 'Supervisor')
# print title
template = (f'%(appli)-{max_appli}s%(managed)-9s%(distributed)-13s%(identifiers)-{max_identifiers}s'
'%(start_seq)-7s%(stop_seq)-7s%(starting_strategy)-13s%(starting_failure_strategy)-18s'
template = (f'%(appli)-{max_appli}s%(managed)-9s%(distribution)-17s%(identifiers)-{max_identifiers}s'
'%(start_seq)-7s%(stop_seq)-7s%(starting_strategy)-18s%(starting_failure_strategy)-18s'
'%(running_failure_strategy)s')
title = {'appli': 'Application', 'managed': 'Managed', 'distributed': 'Distributed',
title = {'appli': 'Application', 'managed': 'Managed', 'distribution': 'Distribution',
'identifiers': 'Supervisor', 'start_seq': 'Start', 'stop_seq': 'Stop',
'starting_strategy': 'Starting', 'starting_failure_strategy': 'Starting_Failure',
'running_failure_strategy': 'Running_Failure'}
Expand All @@ -268,14 +267,15 @@ def do_application_rules(self, arg):
for rules in rules_list:
if rules['managed']:
payload = {'appli': rules['application_name'], 'managed': True,
'distributed': rules['distributed'], 'identifiers': rules.get('identifiers', 'n/a'),
'distribution': rules['distribution'],
'identifiers': rules.get('identifiers', 'n/a'),
'start_seq': rules['start_sequence'], 'stop_seq': rules['stop_sequence'],
'starting_strategy': rules['starting_strategy'],
'starting_failure_strategy': rules['starting_failure_strategy'],
'running_failure_strategy': rules['running_failure_strategy']}
else:
payload = {'appli': rules['application_name'], 'managed': False,
'distributed': 'n/a', 'identifiers': 'n/a',
'distribution': 'n/a', 'identifiers': 'n/a',
'start_seq': 'n/a', 'stop_seq': 'n/a',
'starting_strategy': 'n/a',
'starting_failure_strategy': 'n/a',
Expand Down
8 changes: 4 additions & 4 deletions supvisors/tests/test_supvisorsctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# limitations under the License.
# ======================================================================

import pytest
from unittest.mock import call, Mock

import pytest
from supervisor.supervisorctl import DefaultControllerPlugin
from supervisor.xmlrpc import Faults
from unittest.mock import call, Mock

from supvisors.supvisorsctl import *
from supvisors.ttypes import SupvisorsFaults
Expand Down Expand Up @@ -347,11 +347,11 @@ def test_application_rules(controller, plugin, mocked_check):
mocked_appli.return_value = [{'application_name': 'appli_1'}, {'application_name': 'appli_2'},
{'application_name': 'appli_3'}]
mocked_rpc = plugin.supvisors().get_application_rules
returned_rules = [{'application_name': 'appli_1', 'managed': True, 'distributed': True,
returned_rules = [{'application_name': 'appli_1', 'managed': True, 'distribution': 'SINGLE_NODE',
'start_sequence': 2, 'stop_sequence': 3, 'starting_strategy': 'CONFIG',
'starting_failure_strategy': 'ABORT', 'running_failure_strategy': 'CONTINUE'},
{'application_name': 'appli_2', 'managed': True,
'distributed': False, 'addresses': ['10.0.0.1', '10.0.0.2', '10.0.0.3'],
'distribution': 'ALL_INSTANCES', 'addresses': ['10.0.0.1', '10.0.0.2', '10.0.0.3'],
'start_sequence': 1, 'stop_sequence': 0, 'starting_strategy': 'LESS_LOADED',
'starting_failure_strategy': 'CONTINUE', 'running_failure_strategy': 'RESTART_APPLICATION'},
{'application_name': 'appli_3', 'managed': False}]
Expand Down

0 comments on commit 421e471

Please sign in to comment.