Skip to content

T7528: only stop service if previously deployed #4547

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

Open
wants to merge 1 commit into
base: current
Choose a base branch
from

Conversation

nvollmar
Copy link
Contributor

@nvollmar nvollmar commented Jun 6, 2025

Change summary

Apply tries to stop services that weren't configured in the first place. Adding check to only try to stop services which were installed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

How to test / Smoketest result

set interfaces dummy dum0 address '192.0.2.1/32'
set service monitoring prometheus node-exporter collectors textfile
set service monitoring prometheus node-exporter listen-address '192.0.2.1'

Verify logs not trying to stop in-existing vrr/blackbox exporter services

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Copy link

github-actions bot commented Jun 6, 2025

👍
No issues in PR Title / Commit Title

Copy link
Member

@sever-sever sever-sever left a comment

Choose a reason for hiding this comment

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

Works as expected

@sever-sever sever-sever requested a review from c-po June 6, 2025 09:33
@sever-sever sever-sever added the bp/circinus Create automatic backport for circinus label Jun 6, 2025
Copy link
Member

@sever-sever sever-sever left a comment

Choose a reason for hiding this comment

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

Smoketest fail:

 DEBUG - Running Testcase: /usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py
DEBUG - test_01_node_exporter (__main__.TestMonitoringPrometheus.test_01_node_exporter) ... FAIL
DEBUG - test_02_frr_exporter (__main__.TestMonitoringPrometheus.test_02_frr_exporter) ... FAIL
DEBUG - test_03_blackbox_exporter (__main__.TestMonitoringPrometheus.test_03_blackbox_exporter) ... FAIL
DEBUG - test_04_blackbox_exporter_with_config (__main__.TestMonitoringPrometheus.test_04_blackbox_exporter_with_config) ... FAIL
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_01_node_exporter (__main__.TestMonitoringPrometheus.test_01_node_exporter)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 54, in tearDown
DEBUG -     self.assertFalse(process_named_running(NODE_EXPORTER_PROCESS_NAME))
DEBUG - AssertionError: 205301 is not false
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_02_frr_exporter (__main__.TestMonitoringPrometheus.test_02_frr_exporter)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 54, in tearDown
DEBUG -     self.assertFalse(process_named_running(NODE_EXPORTER_PROCESS_NAME))
DEBUG - AssertionError: 205301 is not false
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_03_blackbox_exporter (__main__.TestMonitoringPrometheus.test_03_blackbox_exporter)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 54, in tearDown
DEBUG -     self.assertFalse(process_named_running(NODE_EXPORTER_PROCESS_NAME))
DEBUG - AssertionError: 205301 is not false
DEBUG - 
DEBUG - ======================================================================
DEBUG - FAIL: test_04_blackbox_exporter_with_config (__main__.TestMonitoringPrometheus.test_04_blackbox_exporter_with_config)
DEBUG - ----------------------------------------------------------------------
DEBUG - Traceback (most recent call last):
DEBUG -   File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 54, in tearDown
DEBUG -     self.assertFalse(process_named_running(NODE_EXPORTER_PROCESS_NAME))
DEBUG - AssertionError: 205301 is not false
DEBUG - 
DEBUG - ----------------------------------------------------------------------
DEBUG - Ran 4 tests in 17.966s
DEBUG - 
DEBUG - FAILED (failures=4)

Copy link

github-actions bot commented Jun 6, 2025

CI integration ❌ failed!

Details

CI logs

  • CLI Smoketests (no interfaces) ❌ failed
  • CLI Smoketests (interfaces only) 👍 passed
  • Config tests 👍 passed
  • RAID1 tests 👍 passed
  • TPM tests 👍 passed

@nvollmar
Copy link
Contributor Author

nvollmar commented Jun 8, 2025

DEBUG - Running Testcase: /usr/libexec/vyos/tests/smoke/cli/test_container.py
DEBUG - test_api_socket (__main__.TestContainer.test_api_socket) ... ok
DEBUG - test_basic (__main__.TestContainer.test_basic) ... ok
DEBUG - test_cpu_limit (__main__.TestContainer.test_cpu_limit) ... ok
DEBUG - test_dual_stack_network (__main__.TestContainer.test_dual_stack_network) ... ok
DEBUG - test_ipv4_network (__main__.TestContainer.test_ipv4_network) ... ok
DEBUG - test_ipv6_network (__main__.TestContainer.test_ipv6_network) ... ok
DEBUG - test_log_driver (__main__.TestContainer.test_log_driver) ... ok
DEBUG - test_name_server (__main__.TestContainer.test_name_server) ... ok
DEBUG - test_network_mtu (__main__.TestContainer.test_network_mtu) ... ok
DEBUG - test_no_name_server (__main__.TestContainer.test_no_name_server) ... ok
DEBUG - test_uid_gid (__main__.TestContainer.test_uid_gid) ... ok

@sever-sever
Copy link
Member

Smoketest still fail

vyos@r14:~$ /usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py
test_01_node_exporter (__main__.TestMonitoringPrometheus.test_01_node_exporter) ... ERROR
test_02_frr_exporter (__main__.TestMonitoringPrometheus.test_02_frr_exporter) ... ERROR
test_03_blackbox_exporter (__main__.TestMonitoringPrometheus.test_03_blackbox_exporter) ... ERROR
test_04_blackbox_exporter_with_config (__main__.TestMonitoringPrometheus.test_04_blackbox_exporter_with_config) ... ERROR
tearDownClass (__main__.TestMonitoringPrometheus) ... ERROR

======================================================================
ERROR: test_01_node_exporter (__main__.TestMonitoringPrometheus.test_01_node_exporter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 53, in tearDown
    self.cli_commit()
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 103, in cli_commit
    out = self._session.commit()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 300, in commit
    out = self.__run_command([COMMIT])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 230, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: [ service monitoring prometheus ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 145, in run_script
    script.generate(c)
  File "/usr/libexec/vyos//conf_mode/service_monitoring_prometheus.py", line 118, in generate
    monitoring.update({'node_exporter_stop_required': {}})
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'update'

delete [ service monitoring prometheus ] failed
Commit failed


======================================================================
ERROR: test_02_frr_exporter (__main__.TestMonitoringPrometheus.test_02_frr_exporter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 53, in tearDown
    self.cli_commit()
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 103, in cli_commit
    out = self._session.commit()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 300, in commit
    out = self.__run_command([COMMIT])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 230, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: [ service monitoring prometheus ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 145, in run_script
    script.generate(c)
  File "/usr/libexec/vyos//conf_mode/service_monitoring_prometheus.py", line 124, in generate
    monitoring.update({'frr_exporter_stop_required': {}})
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'update'

delete [ service monitoring prometheus ] failed
Commit failed


======================================================================
ERROR: test_03_blackbox_exporter (__main__.TestMonitoringPrometheus.test_03_blackbox_exporter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 53, in tearDown
    self.cli_commit()
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 103, in cli_commit
    out = self._session.commit()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 300, in commit
    out = self.__run_command([COMMIT])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 230, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: [ service monitoring prometheus ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 145, in run_script
    script.generate(c)
  File "/usr/libexec/vyos//conf_mode/service_monitoring_prometheus.py", line 130, in generate
    monitoring.update({'blackbox_exporter_stop_required': {}})
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'update'

delete [ service monitoring prometheus ] failed
Commit failed


======================================================================
ERROR: test_04_blackbox_exporter_with_config (__main__.TestMonitoringPrometheus.test_04_blackbox_exporter_with_config)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 53, in tearDown
    self.cli_commit()
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 103, in cli_commit
    out = self._session.commit()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 300, in commit
    out = self.__run_command([COMMIT])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 230, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: [ service monitoring prometheus ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 145, in run_script
    script.generate(c)
  File "/usr/libexec/vyos//conf_mode/service_monitoring_prometheus.py", line 130, in generate
    monitoring.update({'blackbox_exporter_stop_required': {}})
    ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'update'

delete [ service monitoring prometheus ] failed
Commit failed


======================================================================
ERROR: tearDownClass (__main__.TestMonitoringPrometheus)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 73, in tearDownClass
    cls._session.commit()
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 300, in commit
    out = self.__run_command([COMMIT])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 230, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: [ service monitoring prometheus ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/services/vyos-configd", line 146, in run_script
    script.apply(c)
  File "/usr/libexec/vyos//conf_mode/service_monitoring_prometheus.py", line 179, in apply
    if 'node_exporter_stop_required' in monitoring:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

delete [ service monitoring prometheus ] failed
[[]] failed
Commit failed


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/libexec/vyos/tests/smoke/cli/test_service_monitoring_prometheus.py", line 49, in tearDownClass
    super(TestMonitoringPrometheus, cls).tearDownClass()
  File "/usr/libexec/vyos/tests/smoke/cli/base_vyostest_shim.py", line 76, in tearDownClass
    cls.fail(cls)
  File "/usr/lib/python3.11/unittest/case.py", line 703, in fail
    raise self.failureException(msg)
AssertionError: None

----------------------------------------------------------------------
Ran 4 tests in 19.943s

FAILED (errors=5)
vyos@r14:~$ 


@@ -115,16 +115,19 @@ def generate(monitoring):
# Delete systemd files
if os.path.isfile(node_exporter_service_file):
os.unlink(node_exporter_service_file)
monitoring.update({'node_exporter_stop_required': {}})
Copy link
Member

Choose a reason for hiding this comment

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

The update dictionary should be in the get_config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bp/circinus Create automatic backport for circinus current
Development

Successfully merging this pull request may close these issues.

2 participants