Fix up logger .warn() calls to use .warning() instead

This is a usage that was deprecated in Python 3.0.
This commit is contained in:
Jeff Bradberry
2022-01-31 13:17:45 -05:00
parent a3a216f91f
commit b852baaa39
28 changed files with 65 additions and 65 deletions

View File

@@ -104,7 +104,7 @@ class LoggedLoginView(auth_views.LoginView):
return ret return ret
else: else:
if 'username' in self.request.POST: if 'username' in self.request.POST:
logger.warn(smart_str(u"Login failed for user {} from {}".format(self.request.POST.get('username'), request.META.get('REMOTE_ADDR', None)))) logger.warning(smart_str(u"Login failed for user {} from {}".format(self.request.POST.get('username'), request.META.get('REMOTE_ADDR', None))))
ret.status_code = 401 ret.status_code = 401
return ret return ret

View File

@@ -5078,7 +5078,7 @@ class ActivityStreamSerializer(BaseSerializer):
try: try:
return json.loads(obj.changes) return json.loads(obj.changes)
except Exception: except Exception:
logger.warn("Error deserializing activity stream json changes") logger.warning("Error deserializing activity stream json changes")
return {} return {}
def get_object_association(self, obj): def get_object_association(self, obj):

View File

@@ -89,7 +89,7 @@ class BroadcastWebsocketStatsManager:
await asyncio.sleep(settings.BROADCAST_WEBSOCKET_STATS_POLL_RATE_SECONDS) await asyncio.sleep(settings.BROADCAST_WEBSOCKET_STATS_POLL_RATE_SECONDS)
except Exception as e: except Exception as e:
logger.warn(e) logger.warning(e)
await asyncio.sleep(settings.BROADCAST_WEBSOCKET_STATS_POLL_RATE_SECONDS) await asyncio.sleep(settings.BROADCAST_WEBSOCKET_STATS_POLL_RATE_SECONDS)
self.start() self.start()

View File

@@ -65,7 +65,7 @@ class WebsocketSecretAuthHelper:
nonce_parsed = int(nonce_parsed) nonce_parsed = int(nonce_parsed)
nonce_diff = now - nonce_parsed nonce_diff = now - nonce_parsed
if abs(nonce_diff) > nonce_tolerance: if abs(nonce_diff) > nonce_tolerance:
logger.warn(f"Potential replay attack or machine(s) time out of sync by {nonce_diff} seconds.") logger.warning(f"Potential replay attack or machine(s) time out of sync by {nonce_diff} seconds.")
raise ValueError(f"Potential replay attack or machine(s) time out of sync by {nonce_diff} seconds.") raise ValueError(f"Potential replay attack or machine(s) time out of sync by {nonce_diff} seconds.")
return True return True
@@ -85,7 +85,7 @@ class BroadcastConsumer(AsyncJsonWebsocketConsumer):
try: try:
WebsocketSecretAuthHelper.is_authorized(self.scope) WebsocketSecretAuthHelper.is_authorized(self.scope)
except Exception: except Exception:
logger.warn(f"client '{self.channel_name}' failed to authorize against the broadcast endpoint.") logger.warning(f"client '{self.channel_name}' failed to authorize against the broadcast endpoint.")
await self.close() await self.close()
return return

View File

@@ -42,7 +42,7 @@ class Control(object):
return f"reply_to_{str(uuid.uuid4()).replace('-','_')}" return f"reply_to_{str(uuid.uuid4()).replace('-','_')}"
def control_with_reply(self, command, timeout=5): def control_with_reply(self, command, timeout=5):
logger.warn('checking {} {} for {}'.format(self.service, command, self.queuename)) logger.warning('checking {} {} for {}'.format(self.service, command, self.queuename))
reply_queue = Control.generate_reply_queue_name() reply_queue = Control.generate_reply_queue_name()
self.result = None self.result = None

View File

@@ -19,13 +19,13 @@ class Scheduler(Scheduler):
def run(): def run():
ppid = os.getppid() ppid = os.getppid()
logger.warn('periodic beat started') logger.warning('periodic beat started')
while True: while True:
if os.getppid() != ppid: if os.getppid() != ppid:
# if the parent PID changes, this process has been orphaned # if the parent PID changes, this process has been orphaned
# via e.g., segfault or sigkill, we should exit too # via e.g., segfault or sigkill, we should exit too
pid = os.getpid() pid = os.getpid()
logger.warn(f'periodic beat exiting gracefully pid:{pid}') logger.warning(f'periodic beat exiting gracefully pid:{pid}')
raise SystemExit() raise SystemExit()
try: try:
for conn in connections.all(): for conn in connections.all():

View File

@@ -142,7 +142,7 @@ class PoolWorker(object):
# when this occurs, it's _fine_ to ignore this KeyError because # when this occurs, it's _fine_ to ignore this KeyError because
# the purpose of self.managed_tasks is to just track internal # the purpose of self.managed_tasks is to just track internal
# state of which events are *currently* being processed. # state of which events are *currently* being processed.
logger.warn('Event UUID {} appears to be have been duplicated.'.format(uuid)) logger.warning('Event UUID {} appears to be have been duplicated.'.format(uuid))
@property @property
def current_task(self): def current_task(self):
@@ -291,8 +291,8 @@ class WorkerPool(object):
pass pass
except Exception: except Exception:
tb = traceback.format_exc() tb = traceback.format_exc()
logger.warn("could not write to queue %s" % preferred_queue) logger.warning("could not write to queue %s" % preferred_queue)
logger.warn("detail: {}".format(tb)) logger.warning("detail: {}".format(tb))
write_attempt_order.append(preferred_queue) write_attempt_order.append(preferred_queue)
logger.error("could not write payload to any queue, attempted order: {}".format(write_attempt_order)) logger.error("could not write payload to any queue, attempted order: {}".format(write_attempt_order))
return None return None

View File

@@ -60,7 +60,7 @@ class AWXConsumerBase(object):
return f'listening on {self.queues}' return f'listening on {self.queues}'
def control(self, body): def control(self, body):
logger.warn(f'Received control signal:\n{body}') logger.warning(f'Received control signal:\n{body}')
control = body.get('control') control = body.get('control')
if control in ('status', 'running'): if control in ('status', 'running'):
reply_queue = body['reply_to'] reply_queue = body['reply_to']
@@ -118,7 +118,7 @@ class AWXConsumerBase(object):
def stop(self, signum, frame): def stop(self, signum, frame):
self.should_stop = True self.should_stop = True
logger.warn('received {}, stopping'.format(signame(signum))) logger.warning('received {}, stopping'.format(signame(signum)))
self.worker.on_stop() self.worker.on_stop()
raise SystemExit() raise SystemExit()
@@ -153,7 +153,7 @@ class AWXConsumerPG(AWXConsumerBase):
if self.should_stop: if self.should_stop:
return return
except psycopg2.InterfaceError: except psycopg2.InterfaceError:
logger.warn("Stale Postgres message bus connection, reconnecting") logger.warning("Stale Postgres message bus connection, reconnecting")
continue continue

View File

@@ -79,13 +79,13 @@ class AnsibleInventoryLoader(object):
ee = get_default_execution_environment() ee = get_default_execution_environment()
if settings.IS_K8S: if settings.IS_K8S:
logger.warn('This command is not able to run on kubernetes-based deployment. This action should be done using the API.') logger.warning('This command is not able to run on kubernetes-based deployment. This action should be done using the API.')
sys.exit(1) sys.exit(1)
if ee.credential: if ee.credential:
process = subprocess.run(['podman', 'image', 'exists', ee.image], capture_output=True) process = subprocess.run(['podman', 'image', 'exists', ee.image], capture_output=True)
if process.returncode != 0: if process.returncode != 0:
logger.warn( logger.warning(
f'The default execution environment (id={ee.id}, name={ee.name}, image={ee.image}) is not available on this node. ' f'The default execution environment (id={ee.id}, name={ee.name}, image={ee.image}) is not available on this node. '
'The image needs to be available locally before using this command, due to registry authentication. ' 'The image needs to be available locally before using this command, due to registry authentication. '
'To pull this image, either run a job on this node or manually pull the image.' 'To pull this image, either run a job on this node or manually pull the image.'

View File

@@ -247,7 +247,7 @@ class InstanceGroupManager(models.Manager):
if t.controller_node: if t.controller_node:
control_groups = instance_ig_mapping.get(t.controller_node, []) control_groups = instance_ig_mapping.get(t.controller_node, [])
if not control_groups: if not control_groups:
logger.warn(f"No instance group found for {t.controller_node}, capacity consumed may be innaccurate.") logger.warning(f"No instance group found for {t.controller_node}, capacity consumed may be innaccurate.")
if t.status == 'waiting' or (not t.execution_node and not t.is_container_group_task): if t.status == 'waiting' or (not t.execution_node and not t.is_container_group_task):
# Subtract capacity from any peer groups that share instances # Subtract capacity from any peer groups that share instances

View File

@@ -15,10 +15,10 @@ def forwards(apps, schema_editor):
r = InventoryUpdate.objects.filter(source='tower').update(source='controller') r = InventoryUpdate.objects.filter(source='tower').update(source='controller')
if r: if r:
logger.warn(f'Renamed {r} tower inventory updates to controller') logger.warning(f'Renamed {r} tower inventory updates to controller')
InventorySource.objects.filter(source='tower').update(source='controller') InventorySource.objects.filter(source='tower').update(source='controller')
if r: if r:
logger.warn(f'Renamed {r} tower inventory sources to controller') logger.warning(f'Renamed {r} tower inventory sources to controller')
CredentialType = apps.get_model('main', 'CredentialType') CredentialType = apps.get_model('main', 'CredentialType')
@@ -32,7 +32,7 @@ def forwards(apps, schema_editor):
registry_type = ManagedCredentialType.registry.get('controller') registry_type = ManagedCredentialType.registry.get('controller')
if not registry_type: if not registry_type:
raise RuntimeError('Excpected to find controller credential, this may need to be edited in the future!') raise RuntimeError('Excpected to find controller credential, this may need to be edited in the future!')
logger.warn('Renaming the Ansible Tower credential type for existing install') logger.warning('Renaming the Ansible Tower credential type for existing install')
tower_type.name = registry_type.name # sensitive to translations tower_type.name = registry_type.name # sensitive to translations
tower_type.namespace = 'controller' # if not done, will error setup_tower_managed_defaults tower_type.namespace = 'controller' # if not done, will error setup_tower_managed_defaults
tower_type.save(update_fields=['name', 'namespace']) tower_type.save(update_fields=['name', 'namespace'])
@@ -46,10 +46,10 @@ def backwards(apps, schema_editor):
r = InventoryUpdate.objects.filter(source='controller').update(source='tower') r = InventoryUpdate.objects.filter(source='controller').update(source='tower')
if r: if r:
logger.warn(f'Renamed {r} controller inventory updates to tower') logger.warning(f'Renamed {r} controller inventory updates to tower')
r = InventorySource.objects.filter(source='controller').update(source='tower') r = InventorySource.objects.filter(source='controller').update(source='tower')
if r: if r:
logger.warn(f'Renamed {r} controller inventory sources to tower') logger.warning(f'Renamed {r} controller inventory sources to tower')
CredentialType = apps.get_model('main', 'CredentialType') CredentialType = apps.get_model('main', 'CredentialType')

View File

@@ -14,4 +14,4 @@ def delete_hg_scm(apps, schema_editor):
update_ct = Project.objects.filter(scm_type='hg').update(scm_type='') update_ct = Project.objects.filter(scm_type='hg').update(scm_type='')
if update_ct: if update_ct:
logger.warn('Changed {} mercurial projects to manual, deprecation period ended'.format(update_ct)) logger.warning('Changed {} mercurial projects to manual, deprecation period ended'.format(update_ct))

View File

@@ -35,7 +35,7 @@ def _get_instance_id_for_upgrade(host, new_id):
return None return None
if len(new_id) > 255: if len(new_id) > 255:
# this should never happen # this should never happen
logger.warn('Computed instance id "{}"" for host {}-{} is too long'.format(new_id_value, host.name, host.pk)) logger.warning('Computed instance id "{}"" for host {}-{} is too long'.format(new_id_value, host.name, host.pk))
return None return None
return new_id_value return new_id_value
@@ -47,7 +47,7 @@ def set_new_instance_id(apps, source, new_id):
id_from_settings = getattr(settings, '{}_INSTANCE_ID_VAR'.format(source.upper())) id_from_settings = getattr(settings, '{}_INSTANCE_ID_VAR'.format(source.upper()))
if id_from_settings != new_id: if id_from_settings != new_id:
# User applied an instance ID themselves, so nope on out of there # User applied an instance ID themselves, so nope on out of there
logger.warn('You have an instance ID set for {}, not migrating'.format(source)) logger.warning('You have an instance ID set for {}, not migrating'.format(source))
return return
logger.debug('Migrating inventory instance_id for {} to {}'.format(source, new_id)) logger.debug('Migrating inventory instance_id for {} to {}'.format(source, new_id))
Host = apps.get_model('main', 'Host') Host = apps.get_model('main', 'Host')

View File

@@ -247,7 +247,7 @@ class Instance(HasPolicyEditsMixin, BaseModel):
if uuid is not None and self.uuid != uuid: if uuid is not None and self.uuid != uuid:
if self.uuid is not None: if self.uuid is not None:
logger.warn(f'Self-reported uuid of {self.hostname} changed from {self.uuid} to {uuid}') logger.warning(f'Self-reported uuid of {self.hostname} changed from {self.uuid} to {uuid}')
self.uuid = uuid self.uuid = uuid
update_fields.append('uuid') update_fields.append('uuid')

View File

@@ -515,7 +515,7 @@ class JobNotificationMixin(object):
try: try:
notification_templates = self.get_notification_templates() notification_templates = self.get_notification_templates()
except Exception: except Exception:
logger.warn("No notification template defined for emitting notification") logger.warning("No notification template defined for emitting notification")
return return
if not notification_templates: if not notification_templates:

View File

@@ -103,7 +103,7 @@ class Schedule(PrimordialModel, LaunchTimeConfig):
for zone in all_zones: for zone in all_zones:
if fname.endswith(zone): if fname.endswith(zone):
return zone return zone
logger.warn('Could not detect valid zoneinfo for {}'.format(self.rrule)) logger.warning('Could not detect valid zoneinfo for {}'.format(self.rrule))
return '' return ''
@property @property

View File

@@ -357,7 +357,7 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique, ExecutionEn
validated_kwargs = kwargs.copy() validated_kwargs = kwargs.copy()
if unallowed_fields: if unallowed_fields:
if parent_field_name is None: if parent_field_name is None:
logger.warn('Fields {} are not allowed as overrides to spawn from {}.'.format(', '.join(unallowed_fields), self)) logger.warning('Fields {} are not allowed as overrides to spawn from {}.'.format(', '.join(unallowed_fields), self))
for f in unallowed_fields: for f in unallowed_fields:
validated_kwargs.pop(f) validated_kwargs.pop(f)
@@ -1205,7 +1205,7 @@ class UnifiedJob(
try: try:
extra_data_dict = parse_yaml_or_json(extra_data, silent_failure=False) extra_data_dict = parse_yaml_or_json(extra_data, silent_failure=False)
except Exception as e: except Exception as e:
logger.warn("Exception deserializing extra vars: " + str(e)) logger.warning("Exception deserializing extra vars: " + str(e))
evars = self.extra_vars_dict evars = self.extra_vars_dict
evars.update(extra_data_dict) evars.update(extra_data_dict)
self.update_fields(extra_vars=json.dumps(evars)) self.update_fields(extra_vars=json.dumps(evars))

View File

@@ -21,7 +21,7 @@ class AWXProtocolTypeRouter(ProtocolTypeRouter):
logger.debug(f"cleaning up Redis key {k}") logger.debug(f"cleaning up Redis key {k}")
r.delete(k) r.delete(k)
except redis.exceptions.RedisError as e: except redis.exceptions.RedisError as e:
logger.warn("encountered an error communicating with redis.") logger.warning("encountered an error communicating with redis.")
raise e raise e
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)

View File

@@ -574,7 +574,7 @@ class TaskManager:
timeout_message = _("The approval node {name} ({pk}) has expired after {timeout} seconds.").format( timeout_message = _("The approval node {name} ({pk}) has expired after {timeout} seconds.").format(
name=task.name, pk=task.pk, timeout=task.timeout name=task.name, pk=task.pk, timeout=task.timeout
) )
logger.warn(timeout_message) logger.warning(timeout_message)
task.timed_out = True task.timed_out = True
task.status = 'failed' task.status = 'failed'
task.send_approval_notification('timed_out') task.send_approval_notification('timed_out')

View File

@@ -154,7 +154,7 @@ class RunnerCallback:
if self.instance.cancel_flag or self.instance.status == 'canceled': if self.instance.cancel_flag or self.instance.status == 'canceled':
cancel_wait = (now() - self.instance.modified).seconds if self.instance.modified else 0 cancel_wait = (now() - self.instance.modified).seconds if self.instance.modified else 0
if cancel_wait > 5: if cancel_wait > 5:
logger.warn('Request to cancel {} took {} seconds to complete.'.format(self.instance.log_format, cancel_wait)) logger.warning('Request to cancel {} took {} seconds to complete.'.format(self.instance.log_format, cancel_wait))
return True return True
return False return False

View File

@@ -169,7 +169,7 @@ class BaseTask(object):
# mount_option validation via performed via API, but since this can be overriden via settings.py # mount_option validation via performed via API, but since this can be overriden via settings.py
if mount_option not in CONTAINER_VOLUMES_MOUNT_TYPES: if mount_option not in CONTAINER_VOLUMES_MOUNT_TYPES:
mount_option = 'z' mount_option = 'z'
logger.warn(f'The path {this_path} has volume mount type {mount_option} which is not supported. Using "z" instead.') logger.warning(f'The path {this_path} has volume mount type {mount_option} which is not supported. Using "z" instead.')
params['container_volume_mounts'].append(f'{src}:{dest}:{mount_option}') params['container_volume_mounts'].append(f'{src}:{dest}:{mount_option}')
elif this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER - 1: elif this_path.count(':') == MAX_ISOLATED_PATH_COLON_DELIMITER - 1:

View File

@@ -164,7 +164,7 @@ def run_until_complete(node, timing_data=None, **kwargs):
if settings.RECEPTOR_RELEASE_WORK: if settings.RECEPTOR_RELEASE_WORK:
res = receptor_ctl.simple_command(f"work release {unit_id}") res = receptor_ctl.simple_command(f"work release {unit_id}")
if res != {'released': unit_id}: if res != {'released': unit_id}:
logger.warn(f'Could not confirm release of receptor work unit id {unit_id} from {node}, data: {res}') logger.warning(f'Could not confirm release of receptor work unit id {unit_id} from {node}, data: {res}')
receptor_ctl.close() receptor_ctl.close()
@@ -358,9 +358,9 @@ class AWXReceptorJob:
logger.exception(f'An error was encountered while getting status for work unit {self.unit_id}') logger.exception(f'An error was encountered while getting status for work unit {self.unit_id}')
if 'exceeded quota' in detail: if 'exceeded quota' in detail:
logger.warn(detail) logger.warning(detail)
log_name = self.task.instance.log_format log_name = self.task.instance.log_format
logger.warn(f"Could not launch pod for {log_name}. Exceeded quota.") logger.warning(f"Could not launch pod for {log_name}. Exceeded quota.")
self.task.update_model(self.task.instance.pk, status='pending') self.task.update_model(self.task.instance.pk, status='pending')
return return
# If ansible-runner ran, but an error occured at runtime, the traceback information # If ansible-runner ran, but an error occured at runtime, the traceback information
@@ -380,7 +380,7 @@ class AWXReceptorJob:
self.task.instance.result_traceback = detail self.task.instance.result_traceback = detail
self.task.instance.save(update_fields=['result_traceback']) self.task.instance.save(update_fields=['result_traceback'])
else: else:
logger.warn(f'No result details or output from {self.task.instance.log_format}, status:\n{state_name}') logger.warning(f'No result details or output from {self.task.instance.log_format}, status:\n{state_name}')
except Exception: except Exception:
raise RuntimeError(detail) raise RuntimeError(detail)

View File

@@ -374,15 +374,15 @@ def cluster_node_health_check(node):
Used for the health check endpoint, refreshes the status of the instance, but must be ran on target node Used for the health check endpoint, refreshes the status of the instance, but must be ran on target node
""" """
if node == '': if node == '':
logger.warn('Local health check incorrectly called with blank string') logger.warning('Local health check incorrectly called with blank string')
return return
elif node != settings.CLUSTER_HOST_ID: elif node != settings.CLUSTER_HOST_ID:
logger.warn(f'Local health check for {node} incorrectly sent to {settings.CLUSTER_HOST_ID}') logger.warning(f'Local health check for {node} incorrectly sent to {settings.CLUSTER_HOST_ID}')
return return
try: try:
this_inst = Instance.objects.me() this_inst = Instance.objects.me()
except Instance.DoesNotExist: except Instance.DoesNotExist:
logger.warn(f'Instance record for {node} missing, could not check capacity.') logger.warning(f'Instance record for {node} missing, could not check capacity.')
return return
this_inst.local_health_check() this_inst.local_health_check()
@@ -390,12 +390,12 @@ def cluster_node_health_check(node):
@task(queue=get_local_queuename) @task(queue=get_local_queuename)
def execution_node_health_check(node): def execution_node_health_check(node):
if node == '': if node == '':
logger.warn('Remote health check incorrectly called with blank string') logger.warning('Remote health check incorrectly called with blank string')
return return
try: try:
instance = Instance.objects.get(hostname=node) instance = Instance.objects.get(hostname=node)
except Instance.DoesNotExist: except Instance.DoesNotExist:
logger.warn(f'Instance record for {node} missing, could not check capacity.') logger.warning(f'Instance record for {node} missing, could not check capacity.')
return return
if instance.node_type != 'execution': if instance.node_type != 'execution':
@@ -416,7 +416,7 @@ def execution_node_health_check(node):
if data['errors']: if data['errors']:
formatted_error = "\n".join(data["errors"]) formatted_error = "\n".join(data["errors"])
if prior_capacity: if prior_capacity:
logger.warn(f'Health check marking execution node {node} as lost, errors:\n{formatted_error}') logger.warning(f'Health check marking execution node {node} as lost, errors:\n{formatted_error}')
else: else:
logger.info(f'Failed to find capacity of new or lost execution node {node}, errors:\n{formatted_error}') logger.info(f'Failed to find capacity of new or lost execution node {node}, errors:\n{formatted_error}')
else: else:
@@ -441,7 +441,7 @@ def inspect_execution_nodes(instance_list):
if hostname in node_lookup: if hostname in node_lookup:
instance = node_lookup[hostname] instance = node_lookup[hostname]
else: else:
logger.warn(f"Unrecognized node advertising on mesh: {hostname}") logger.warning(f"Unrecognized node advertising on mesh: {hostname}")
continue continue
# Control-plane nodes are dealt with via local_health_check instead. # Control-plane nodes are dealt with via local_health_check instead.
@@ -466,7 +466,7 @@ def inspect_execution_nodes(instance_list):
# if the instance *was* lost, but has appeared again, # if the instance *was* lost, but has appeared again,
# attempt to re-establish the initial capacity and version # attempt to re-establish the initial capacity and version
# check # check
logger.warn(f'Execution node attempting to rejoin as instance {hostname}.') logger.warning(f'Execution node attempting to rejoin as instance {hostname}.')
execution_node_health_check.apply_async([hostname]) execution_node_health_check.apply_async([hostname])
elif instance.capacity == 0 and instance.enabled: elif instance.capacity == 0 and instance.enabled:
# nodes with proven connection but need remediation run health checks are reduced frequency # nodes with proven connection but need remediation run health checks are reduced frequency
@@ -640,7 +640,7 @@ def awx_periodic_scheduler():
template = schedule.unified_job_template template = schedule.unified_job_template
schedule.update_computed_fields() # To update next_run timestamp. schedule.update_computed_fields() # To update next_run timestamp.
if template.cache_timeout_blocked: if template.cache_timeout_blocked:
logger.warn("Cache timeout is in the future, bypassing schedule for template %s" % str(template.id)) logger.warning("Cache timeout is in the future, bypassing schedule for template %s" % str(template.id))
continue continue
try: try:
job_kwargs = schedule.get_job_kwargs() job_kwargs = schedule.get_job_kwargs()
@@ -694,7 +694,7 @@ def handle_work_error(task_id, *args, **kwargs):
instance = UnifiedJob.get_instance_by_type(each_task['type'], each_task['id']) instance = UnifiedJob.get_instance_by_type(each_task['type'], each_task['id'])
if not instance: if not instance:
# Unknown task type # Unknown task type
logger.warn("Unknown task type: {}".format(each_task['type'])) logger.warning("Unknown task type: {}".format(each_task['type']))
continue continue
except ObjectDoesNotExist: except ObjectDoesNotExist:
logger.warning('Missing {} `{}` in error callback.'.format(each_task['type'], each_task['id'])) logger.warning('Missing {} `{}` in error callback.'.format(each_task['type'], each_task['id']))
@@ -741,7 +741,7 @@ def handle_success_and_failure_notifications(job_id):
time.sleep(1) time.sleep(1)
uj = UnifiedJob.objects.get(pk=job_id) uj = UnifiedJob.objects.get(pk=job_id)
logger.warn(f"Failed to even try to send notifications for job '{uj}' due to job not being in finished state.") logger.warning(f"Failed to even try to send notifications for job '{uj}' due to job not being in finished state.")
@task(queue=get_local_queuename) @task(queue=get_local_queuename)

View File

@@ -1947,7 +1947,7 @@ def test_notification_job_not_finished(logging_getLogger, mocker):
with mocker.patch('awx.main.models.UnifiedJob.objects.get', uj): with mocker.patch('awx.main.models.UnifiedJob.objects.get', uj):
system.handle_success_and_failure_notifications(1) system.handle_success_and_failure_notifications(1)
assert logger.warn.called_with(f"Failed to even try to send notifications for job '{uj}' due to job not being in finished state.") assert logger.warning.called_with(f"Failed to even try to send notifications for job '{uj}' due to job not being in finished state.")
def test_notification_job_finished(mocker): def test_notification_job_finished(mocker):

View File

@@ -40,5 +40,5 @@ def supervisor_service_command(command, service='*', communicate=True):
def stop_local_services(communicate=True): def stop_local_services(communicate=True):
logger.warn('Stopping services on this node in response to user action') logger.warning('Stopping services on this node in response to user action')
supervisor_service_command(command='stop', communicate=communicate) supervisor_service_command(command='stop', communicate=communicate)

View File

@@ -92,7 +92,7 @@ class WebsocketTask:
if attempt > 0: if attempt > 0:
await asyncio.sleep(settings.BROADCAST_WEBSOCKET_RECONNECT_RETRY_RATE_SECONDS) await asyncio.sleep(settings.BROADCAST_WEBSOCKET_RECONNECT_RETRY_RATE_SECONDS)
except asyncio.CancelledError: except asyncio.CancelledError:
logger.warn(f"Connection from {self.name} to {self.remote_host} cancelled") logger.warning(f"Connection from {self.name} to {self.remote_host} cancelled")
raise raise
uri = f"{self.protocol}://{self.remote_host}:{self.remote_port}/websocket/{self.endpoint}/" uri = f"{self.protocol}://{self.remote_host}:{self.remote_port}/websocket/{self.endpoint}/"
@@ -109,18 +109,18 @@ class WebsocketTask:
except asyncio.CancelledError: except asyncio.CancelledError:
# TODO: Check if connected and disconnect # TODO: Check if connected and disconnect
# Possibly use run_until_complete() if disconnect is async # Possibly use run_until_complete() if disconnect is async
logger.warn(f"Connection from {self.name} to {self.remote_host} cancelled.") logger.warning(f"Connection from {self.name} to {self.remote_host} cancelled.")
self.stats.record_connection_lost() self.stats.record_connection_lost()
raise raise
except client_exceptions.ClientConnectorError as e: except client_exceptions.ClientConnectorError as e:
logger.warn(f"Connection from {self.name} to {self.remote_host} failed: '{e}'.") logger.warning(f"Connection from {self.name} to {self.remote_host} failed: '{e}'.")
except asyncio.TimeoutError: except asyncio.TimeoutError:
logger.warn(f"Connection from {self.name} to {self.remote_host} timed out.") logger.warning(f"Connection from {self.name} to {self.remote_host} timed out.")
except Exception as e: except Exception as e:
# Early on, this is our canary. I'm not sure what exceptions we can really encounter. # Early on, this is our canary. I'm not sure what exceptions we can really encounter.
logger.warn(f"Connection from {self.name} to {self.remote_host} failed for unknown reason: '{e}'.") logger.warning(f"Connection from {self.name} to {self.remote_host} failed for unknown reason: '{e}'.")
else: else:
logger.warn(f"Connection from {self.name} to {self.remote_host} list.") logger.warning(f"Connection from {self.name} to {self.remote_host} list.")
self.stats.record_connection_lost() self.stats.record_connection_lost()
self.start(attempt=attempt + 1) self.start(attempt=attempt + 1)
@@ -146,7 +146,7 @@ class BroadcastWebsocketTask(WebsocketTask):
logmsg = "Failed to decode broadcast message" logmsg = "Failed to decode broadcast message"
if logger.isEnabledFor(logging.DEBUG): if logger.isEnabledFor(logging.DEBUG):
logmsg = "{} {}".format(logmsg, payload) logmsg = "{} {}".format(logmsg, payload)
logger.warn(logmsg) logger.warning(logmsg)
continue continue
(group, message) = unwrap_broadcast_msg(payload) (group, message) = unwrap_broadcast_msg(payload)
if group == "metrics": if group == "metrics":
@@ -185,9 +185,9 @@ class BroadcastWebsocketManager(object):
new_remote_hosts.add(hostname) new_remote_hosts.add(hostname)
if deleted_remote_hosts: if deleted_remote_hosts:
logger.warn(f"Removing {deleted_remote_hosts} from websocket broadcast list") logger.warning(f"Removing {deleted_remote_hosts} from websocket broadcast list")
if new_remote_hosts: if new_remote_hosts:
logger.warn(f"Adding {new_remote_hosts} to websocket broadcast list") logger.warning(f"Adding {new_remote_hosts} to websocket broadcast list")
for h in deleted_remote_hosts: for h in deleted_remote_hosts:
self.broadcast_tasks[h].cancel() self.broadcast_tasks[h].cancel()

View File

@@ -179,7 +179,7 @@ def _get_or_set_enterprise_user(username, password, provider):
created = True created = True
if created or user.is_in_enterprise_category(provider): if created or user.is_in_enterprise_category(provider):
return user return user
logger.warn("Enterprise user %s already defined in Tower." % username) logger.warning("Enterprise user %s already defined in Tower." % username)
class RADIUSBackend(BaseRADIUSBackend): class RADIUSBackend(BaseRADIUSBackend):
@@ -257,7 +257,7 @@ class TowerSAMLIdentityProvider(BaseSAMLIdentityProvider):
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
value = value[0] value = value[0]
if conf_key in ('attr_first_name', 'attr_last_name', 'attr_username', 'attr_email') and value is None: if conf_key in ('attr_first_name', 'attr_last_name', 'attr_username', 'attr_email') and value is None:
logger.warn( logger.warning(
"Could not map user detail '%s' from SAML attribute '%s'; " "update SOCIAL_AUTH_SAML_ENABLED_IDPS['%s']['%s'] with the correct SAML attribute.", "Could not map user detail '%s' from SAML attribute '%s'; " "update SOCIAL_AUTH_SAML_ENABLED_IDPS['%s']['%s'] with the correct SAML attribute.",
conf_key[5:], conf_key[5:],
key, key,
@@ -370,7 +370,7 @@ def on_populate_user(sender, **kwargs):
if field_len > max_len: if field_len > max_len:
setattr(user, field, getattr(user, field)[:max_len]) setattr(user, field, getattr(user, field)[:max_len])
force_user_update = True force_user_update = True
logger.warn('LDAP user {} has {} > max {} characters'.format(user.username, field, max_len)) logger.warning('LDAP user {} has {} > max {} characters'.format(user.username, field, max_len))
# Update organization membership based on group memberships. # Update organization membership based on group memberships.
org_map = getattr(backend.settings, 'ORGANIZATION_MAP', {}) org_map = getattr(backend.settings, 'ORGANIZATION_MAP', {})

View File

@@ -11,7 +11,7 @@ def test_fetch_user_if_exist(existing_tacacsplus_user):
with mock.patch('awx.sso.backends.logger') as mocked_logger: with mock.patch('awx.sso.backends.logger') as mocked_logger:
new_user = _get_or_set_enterprise_user("foo", "password", "tacacs+") new_user = _get_or_set_enterprise_user("foo", "password", "tacacs+")
mocked_logger.debug.assert_not_called() mocked_logger.debug.assert_not_called()
mocked_logger.warn.assert_not_called() mocked_logger.warning.assert_not_called()
assert new_user == existing_tacacsplus_user assert new_user == existing_tacacsplus_user
@@ -33,5 +33,5 @@ def test_created_user_has_no_usable_password():
def test_non_enterprise_user_does_not_get_pass(existing_normal_user): def test_non_enterprise_user_does_not_get_pass(existing_normal_user):
with mock.patch('awx.sso.backends.logger') as mocked_logger: with mock.patch('awx.sso.backends.logger') as mocked_logger:
new_user = _get_or_set_enterprise_user("alice", "password", "tacacs+") new_user = _get_or_set_enterprise_user("alice", "password", "tacacs+")
mocked_logger.warn.assert_called_once_with(u'Enterprise user alice already defined in Tower.') mocked_logger.warning.assert_called_once_with(u'Enterprise user alice already defined in Tower.')
assert new_user is None assert new_user is None