Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Changed
* Drop Python 3.6 testing in CircleCI. #6080
Contributed by (@philipphomberger Schwarz IT KG)
* Refactor `tools/launchdev.sh` to use `tmux` instead of `screen`. #6186 (by @nzlosh and @cognifloyd)
* Fic misc DeprecationWarnings to prepare for python 3.10 support. #6188 #6190 (by @nzlosh)

Added
~~~~~
Expand Down
2 changes: 1 addition & 1 deletion st2actions/st2actions/policies/concurrency_by_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def apply_before(self, target):

# Warn users that the coordination service is not configured.
if not coordination.configured():
LOG.warn(
LOG.warning(
"Coordination service is not configured. Policy enforcement is best effort."
)

Expand Down
2 changes: 1 addition & 1 deletion st2actions/st2actions/scheduler/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _handle_execution(self, execution_queue_item_db):
if action_has_policies_require_lock:
# Warn users that the coordination service is not configured.
if not coordination_service.configured():
LOG.warn(
LOG.warning(
"[%s] Coordination backend is not configured. "
"Policy enforcement is best effort.",
action_execution_id,
Expand Down
4 changes: 2 additions & 2 deletions st2api/st2api/controllers/v1/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def _create_shadow_trigger(triggertype_db):
# Not aborting as this is convenience.
return
except StackStormDBObjectConflictError as e:
LOG.warn(
LOG.warning(
'Trigger creation of "%s" failed with uniqueness conflict. Exception: %s',
trigger,
six.text_type(e),
Expand All @@ -221,7 +221,7 @@ def _delete_shadow_trigger(triggertype_db):
)
trigger_db = TriggerService.get_trigger_db_by_ref(triggertype_ref.ref)
if not trigger_db:
LOG.warn(
LOG.warning(
"No shadow trigger found for %s. Will skip delete.", triggertype_db
)
return
Expand Down
12 changes: 6 additions & 6 deletions st2client/st2client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_client(self, args, debug=False):
cache_token=cache_token,
)
except requests.exceptions.ConnectionError as e:
self.LOG.warn(
self.LOG.warning(
"Auth API server is not available, skipping authentication."
)
self.LOG.exception(e)
Expand Down Expand Up @@ -280,7 +280,7 @@ def _get_cached_auth_token(self, client, username, password):
"cached token meaning they may be slower."
% (cached_token_path, os.getlogin())
)
self.LOG.warn(message)
self.LOG.warning(message)
return None

if not os.path.isfile(cached_token_path):
Expand All @@ -293,7 +293,7 @@ def _get_cached_auth_token(self, client, username, password):
"access to this file). Subsequent requests won't use a cached token "
"meaning they may be slower." % (cached_token_path, os.getlogin())
)
self.LOG.warn(message)
self.LOG.warning(message)
return None

# Safety check for too permissive permissions
Expand All @@ -307,7 +307,7 @@ def _get_cached_auth_token(self, client, username, password):
"restrict the permissions and make sure only your own user can read "
"from or write to the file." % (file_st_mode, cached_token_path)
)
self.LOG.warn(message)
self.LOG.warning(message)

with open(cached_token_path) as fp:
data = fp.read()
Expand Down Expand Up @@ -359,7 +359,7 @@ def _cache_auth_token(self, token_obj):
"cached token meaning they may be slower."
% (cached_token_path, os.getlogin())
)
self.LOG.warn(message)
self.LOG.warning(message)
return None

if os.path.isfile(cached_token_path) and not os.access(
Expand All @@ -372,7 +372,7 @@ def _cache_auth_token(self, token_obj):
"cached token meaning they may be slower."
% (cached_token_path, os.getlogin())
)
self.LOG.warn(message)
self.LOG.warning(message)
return None

token = token_obj.token
Expand Down
4 changes: 2 additions & 2 deletions st2client/st2client/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def parse(self):
if self.validate_config_permissions:
# Make sure the directory permissions == 0o770
if bool(os.stat(config_dir_path).st_mode & 0o7):
self.LOG.warn(
self.LOG.warning(
"The StackStorm configuration directory permissions are "
"insecure (too permissive): others have access."
)
Expand All @@ -130,7 +130,7 @@ def parse(self):

# Make sure the file permissions == 0o660
if bool(os.stat(self.config_file_path).st_mode & 0o7):
self.LOG.warn(
self.LOG.warning(
"The StackStorm configuration file permissions are "
"insecure: others have access."
)
Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/formatters/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# official StackStorm packages.
# Only time it may not be available is if the user is doing custom install from source or
# similar.
logging.getLogger(__name__).warn(
logging.getLogger(__name__).warning(
"libYAML C bindings are not available. This means YAML "
"parsing and serialization will be significantly slower. You are "
"strongly recommended to install libyaml (libyaml-dev package "
Expand Down
2 changes: 1 addition & 1 deletion st2client/st2client/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def _check_locale_and_print_warning(self):

if preferred_encoding and preferred_encoding.lower() != "utf-8":
msg = NON_UTF8_LOCALE % (default_locale or "unknown", preferred_encoding)
LOGGER.warn(msg)
LOGGER.warning(msg)


def setup_logging(argv):
Expand Down
1 change: 1 addition & 0 deletions st2client/tests/unit/test_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def test_weird_but_correct_permissions_emit_no_warnings(self):
self.assertTrue(os.path.exists(self.TEMP_CONFIG_DIR))
self.assertEqual(os.stat(self.TEMP_CONFIG_DIR).st_mode & 0o7777, 0o2770)

@unittest.skipIf(os.getuid() == 0, reason="Test must be run as non-root user.")
def test_warn_on_bad_config_permissions(self):
# Setup the config directory
os.chmod(self.TEMP_CONFIG_DIR, 0o0755)
Expand Down
32 changes: 17 additions & 15 deletions st2client/tests/unit/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_non_unicode_encoding_locale_warning_is_printed(self, mock_logger):
shell = Shell()
shell.run(argv=["trigger", "list"])

call_args = mock_logger.warn.call_args[0][0]
call_args = mock_logger.warning.call_args[0][0]
self.assertIn(
"Locale en_US with encoding iso which is not UTF-8 is used.", call_args
)
Expand All @@ -502,7 +502,7 @@ def test_failed_to_get_locale_encoding_warning_is_printed(self, mock_logger):
shell = Shell()
shell.run(argv=["trigger", "list"])

call_args = mock_logger.warn.call_args[0][0]
call_args = mock_logger.warning.call_args[0][0]
self.assertTrue(
"Locale unknown with encoding unknown which is not UTF-8 is used."
in call_args
Expand Down Expand Up @@ -542,13 +542,13 @@ def test_dont_warn_multiple_times(self):
# Test without token.
shell.run(["--config-file", mock_config_path, "action", "list"])

self.assertEqual(shell.LOG.warn.call_count, 2)
self.assertEqual(shell.LOG.warning.call_count, 2)
self.assertEqual(
shell.LOG.warn.call_args_list[0][0][0][:63],
shell.LOG.warning.call_args_list[0][0][0][:63],
"The StackStorm configuration directory permissions are insecure",
)
self.assertEqual(
shell.LOG.warn.call_args_list[1][0][0][:58],
shell.LOG.warning.call_args_list[1][0][0][:58],
"The StackStorm configuration file permissions are insecure",
)

Expand Down Expand Up @@ -617,6 +617,7 @@ def _write_mock_config(self):
with open(self._mock_config_path, "w") as fp:
fp.write(MOCK_CONFIG)

@unittest.skipIf(os.getuid() == 0, reason="Test must be run as non-root user.")
def test_get_cached_auth_token_invalid_permissions(self):
shell = Shell()
client = Client()
Expand All @@ -637,8 +638,8 @@ def test_get_cached_auth_token_invalid_permissions(self):
)

self.assertEqual(result, None)
self.assertEqual(shell.LOG.warn.call_count, 1)
log_message = shell.LOG.warn.call_args[0][0]
self.assertEqual(shell.LOG.warning.call_count, 1)
log_message = shell.LOG.warning.call_args[0][0]

expected_msg = (
"Unable to retrieve cached token from .*? read access to the parent "
Expand All @@ -656,8 +657,8 @@ def test_get_cached_auth_token_invalid_permissions(self):
)
self.assertEqual(result, None)

self.assertEqual(shell.LOG.warn.call_count, 1)
log_message = shell.LOG.warn.call_args[0][0]
self.assertEqual(shell.LOG.warning.call_count, 1)
log_message = shell.LOG.warning.call_args[0][0]

expected_msg = (
"Unable to retrieve cached token from .*? read access to this file"
Expand All @@ -674,12 +675,13 @@ def test_get_cached_auth_token_invalid_permissions(self):
)
self.assertEqual(result, "yayvalid")

self.assertEqual(shell.LOG.warn.call_count, 1)
log_message = shell.LOG.warn.call_args[0][0]
self.assertEqual(shell.LOG.warning.call_count, 1)
log_message = shell.LOG.warning.call_args[0][0]

expected_msg = "Permissions .*? for cached token file .*? are too permissive.*"
self.assertRegex(log_message, expected_msg)

@unittest.skipIf(os.getuid() == 0, reason="Test must be run as non-root user.")
def test_cache_auth_token_invalid_permissions(self):
shell = Shell()
username = "testu"
Expand All @@ -700,8 +702,8 @@ def test_cache_auth_token_invalid_permissions(self):
shell.LOG = mock.Mock()
shell._cache_auth_token(token_obj=token_db)

self.assertEqual(shell.LOG.warn.call_count, 1)
log_message = shell.LOG.warn.call_args[0][0]
self.assertEqual(shell.LOG.warning.call_count, 1)
log_message = shell.LOG.warning.call_args[0][0]

expected_msg = (
"Unable to write token to .*? doesn't have write access to the parent "
Expand All @@ -716,8 +718,8 @@ def test_cache_auth_token_invalid_permissions(self):
shell.LOG = mock.Mock()
shell._cache_auth_token(token_obj=token_db)

self.assertEqual(shell.LOG.warn.call_count, 1)
log_message = shell.LOG.warn.call_args[0][0]
self.assertEqual(shell.LOG.warning.call_count, 1)
log_message = shell.LOG.warning.call_args[0][0]

expected_msg = (
"Unable to write token to .*? doesn't have write access to this file"
Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/constants/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# official StackStorm packages.
# Only time it may not be available is if the user is doing custom install from source or
# similar.
logging.getLogger(__name__).warn(
logging.getLogger(__name__).warning(
"libYAML C bindings are not available. This means YAML "
"parsing and serialization will be significantly slower. You are "
"strongly recommended to install libyaml (libyaml-dev package "
Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/logging/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def reopen_log_files(handlers):
if "cannot release" in six.text_type(e):
# Release failed which most likely indicates that acquire failed
# and lock was never acquired
LOG.warn("Failed to release lock", exc_info=True)
LOG.warning("Failed to release lock", exc_info=True)
else:
raise e

Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/persistence/db_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _retry_if_connection_error(error):
# start of error msg.
is_connection_error = isinstance(error, mongoengine.connection.ConnectionFailure)
if is_connection_error:
LOG.warn("Retry on ConnectionError - %s", error)
LOG.warning("Retry on ConnectionError - %s", error)
return is_connection_error


Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/services/coordination.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def get_coordinator(start_heart=True, use_cache=True):
global COORDINATOR

if not configured():
LOG.warn(
LOG.warning(
"Coordination backend is not configured. Code paths which use coordination "
"service will use best effort approach and race conditions are possible."
)
Expand Down
4 changes: 2 additions & 2 deletions st2common/st2common/services/trigger_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def dispatch_with_context(
throw_on_inexistent_trigger=True,
)
except (ValidationError, ValueError, Exception) as e:
self._logger.warn(
self._logger.warning(
'Failed to validate payload (%s) for trigger "%s": %s'
% (str(payload), trigger, six.text_type(e))
)
Expand All @@ -111,7 +111,7 @@ def dispatch_with_context(
if throw_on_validation_error:
raise ValueError(msg)

self._logger.warn(msg)
self._logger.warning(msg)
return None

self._logger.debug("Dispatching trigger %s with payload %s.", trigger, payload)
Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/util/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_base_public_api_url():
if cfg.CONF.auth.api_url:
api_url = get_url_without_trailing_slash(cfg.CONF.auth.api_url)
else:
LOG.warn('"auth.api_url" configuration option is not configured')
LOG.warning('"auth.api_url" configuration option is not configured')
api_url = "http://%s:%s" % (cfg.CONF.api.host, cfg.CONF.api.port)

return api_url
Expand Down
2 changes: 1 addition & 1 deletion st2reactor/st2reactor/container/sensor_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def run(self):
self._class_name,
six.text_type(e),
)
self._logger.warn(msg, exc_info=True)
self._logger.warning(msg, exc_info=True)
raise Exception(msg)

def stop(self):
Expand Down