Skip to content

Commit e92b1fe

Browse files
authored
AMBARI-26563: Replace deprecated logger.warn() with logger.warning() (#4095)
1 parent b5f05a2 commit e92b1fe

36 files changed

Lines changed: 113 additions & 113 deletions

ambari-agent/src/main/python/ambari_agent/AlertStatusReporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run(self):
5353
Run an endless loop which reports all the alert statuses got from collector
5454
"""
5555
if self.alert_reports_interval == 0:
56-
logger.warn(
56+
logger.warning(
5757
"AlertStatusReporter is turned off. Some functionality might not work correctly."
5858
)
5959
return
@@ -142,7 +142,7 @@ def get_changed_alerts(self, alerts):
142142
):
143143
changed_alerts.append(alert)
144144
else:
145-
logger.warn(
145+
logger.warning(
146146
"Cannot find alert definition for alert='{0}', alert_state='{1}'.".format(
147147
alert_name, alert_state
148148
)

ambari-agent/src/main/python/ambari_agent/AmbariConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def get_resolved_config(cls, home_dir=""):
162162
raise Exception(f"No config found at {configPath}, use default")
163163

164164
except Exception as err:
165-
logger.warn(err)
165+
logger.warning(err)
166166
setattr(cls, "_conf_cache", config)
167167
return config
168168

ambari-agent/src/main/python/ambari_agent/CommandStatusReporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run(self):
3737
Run an endless loop which reports all the commands results (IN_PROGRESS, FAILED, COMPLETE) every self.command_reports_interval seconds.
3838
"""
3939
if self.command_reports_interval == 0:
40-
logger.warn(
40+
logger.warning(
4141
"CommandStatusReporter is turned off. Some functionality might not work correctly."
4242
)
4343
return

ambari-agent/src/main/python/ambari_agent/ComponentStatusExecutor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def run(self):
5656
Run an endless loop which executes all status commands every 'status_commands_run_interval' seconds.
5757
"""
5858
if self.status_commands_run_interval == 0:
59-
self.logger.warn(
59+
self.logger.warning(
6060
"ComponentStatusExecutor is turned off. Some functionality might not work correctly."
6161
)
6262
return

ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def cancel_command(self, task_id, reason):
147147
log_process_information(logger)
148148
shell.kill_process_with_children(pid)
149149
else:
150-
logger.warn(f"Unable to find process associated with taskId = {task_id}")
150+
logger.warning(f"Unable to find process associated with taskId = {task_id}")
151151

152152
def get_py_executor(self, forced_command_name):
153153
"""

ambari-agent/src/main/python/ambari_agent/DataCleaner.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, config):
4444
self.file_max_age = config.get("agent", "data_cleanup_max_age", 86400)
4545
self.file_max_age = int(self.file_max_age) if self.file_max_age else None
4646
if self.file_max_age is None or self.file_max_age < 86400: # keep for at least 24h
47-
logger.warn(
47+
logger.warning(
4848
"The minimum value allowed for data_cleanup_max_age is 1 "
4949
"day. Setting data_cleanup_max_age to 86400."
5050
)
@@ -57,7 +57,7 @@ def __init__(self, config):
5757
if (
5858
self.cleanup_interval is None or self.cleanup_interval < 3600
5959
): # wait at least 1 hour between runs
60-
logger.warn(
60+
logger.warning(
6161
"The minimum value allowed for data_cleanup_interval is 1 "
6262
"hour. Setting data_cleanup_interval to 3600."
6363
)
@@ -70,7 +70,7 @@ def __init__(self, config):
7070
if (
7171
self.cleanup_max_size_MB is None or self.cleanup_max_size_MB > 10000
7272
): # no more than 10 GBs
73-
logger.warn(
73+
logger.warning(
7474
"The maximum value allowed for cleanup_max_size_MB is 10000 MB (10 GB). "
7575
"Setting cleanup_max_size_MB to 10000."
7676
)
@@ -132,7 +132,7 @@ def cleanup(self):
132132
pass
133133
else:
134134
# Did not reach below cap.
135-
logger.warn(
135+
logger.warning(
136136
"DataCleaner deleted an additional %d files, currently log files occupy %d bytes."
137137
% (count, total_size_bytes)
138138
)

ambari-agent/src/main/python/ambari_agent/Facter.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def resolve_ambari_config(self):
7474
raise Exception("No config found, use default")
7575

7676
except Exception as err:
77-
log.warn(err)
77+
log.warning(err)
7878
return config
7979

8080
# Return first ip adress
@@ -200,7 +200,7 @@ def getSystemResourceOverrides(self):
200200
for key, value in data.items():
201201
systemResources[key] = data[key]
202202
except:
203-
log.warn(
203+
log.warning(
204204
f"Cannot read values from json files in {systemResourceDir}. it won't be used for gathering system resources."
205205
)
206206
else:
@@ -308,7 +308,7 @@ def getUptimeSeconds(self):
308308
)
309309
return int(result)
310310
except:
311-
log.warn("Can not get SwapFree")
311+
log.warning("Can not get SwapFree")
312312
return 0
313313

314314
# Return memoryfree
@@ -323,7 +323,7 @@ def getMemoryFree(self):
323323
)
324324
return result
325325
except:
326-
log.warn("Can not get MemoryFree")
326+
log.warning("Can not get MemoryFree")
327327
return 0
328328

329329
# Return memorytotal
@@ -338,7 +338,7 @@ def getMemoryTotal(self):
338338
)
339339
return result
340340
except:
341-
log.warn("Can not get MemoryTotal")
341+
log.warning("Can not get MemoryTotal")
342342
return 0
343343

344344
# Return swapfree
@@ -353,7 +353,7 @@ def getSwapFree(self):
353353
)
354354
return result
355355
except:
356-
log.warn("Can not get SwapFree")
356+
log.warning("Can not get SwapFree")
357357
return 0
358358

359359
# Return swapsize
@@ -368,7 +368,7 @@ def getSwapSize(self):
368368
)
369369
return result
370370
except:
371-
log.warn("Can not get SwapFree")
371+
log.warning("Can not get SwapFree")
372372
return 0
373373

374374
# Return memorysize
@@ -383,7 +383,7 @@ def getMemorySize(self):
383383
)
384384
return result
385385
except:
386-
log.warn("Can not get MemorySize")
386+
log.warning("Can not get MemorySize")
387387
return 0
388388

389389
def facterInfo(self):
@@ -437,7 +437,7 @@ def setDataIfConfigShortOutput():
437437
return_code, stdout, stderr = run_os_command(FacterLinux.GET_IFCONFIG_SHORT_CMD)
438438
return stdout
439439
except OSError:
440-
log.warn(f"Can't execute {FacterLinux.GET_IFCONFIG_SHORT_CMD}")
440+
log.warning(f"Can't execute {FacterLinux.GET_IFCONFIG_SHORT_CMD}")
441441
return ""
442442

443443
# Returns the output of `ip link` command
@@ -447,7 +447,7 @@ def setDataIpLinkOutput():
447447
return_code, stdout, stderr = run_os_command(FacterLinux.GET_IP_LINK_CMD)
448448
return stdout
449449
except OSError:
450-
log.warn(f"Can't execute {FacterLinux.GET_IP_LINK_CMD}")
450+
log.warning(f"Can't execute {FacterLinux.GET_IP_LINK_CMD}")
451451
return ""
452452

453453
@staticmethod
@@ -456,7 +456,7 @@ def setDataUpTimeOutput():
456456
return_code, stdout, stderr = run_os_command(FacterLinux.GET_UPTIME_CMD)
457457
return stdout
458458
except OSError:
459-
log.warn(f"Can't execute {FacterLinux.GET_UPTIME_CMD}")
459+
log.warning(f"Can't execute {FacterLinux.GET_UPTIME_CMD}")
460460
return ""
461461

462462
@staticmethod
@@ -465,7 +465,7 @@ def setMemInfoOutput():
465465
return_code, stdout, stderr = run_os_command(FacterLinux.GET_MEMINFO_CMD)
466466
return stdout
467467
except OSError:
468-
log.warn(f"Can't execute {FacterLinux.GET_MEMINFO_CMD}")
468+
log.warning(f"Can't execute {FacterLinux.GET_MEMINFO_CMD}")
469469
return ""
470470

471471
# Returns the FQDN of the host
@@ -479,7 +479,7 @@ def isSeLinux(self):
479479
if se_status:
480480
return True
481481
except OSError:
482-
log.warn(f"Could not run {FacterLinux.GET_SE_LINUX_ST_CMD}: OK")
482+
log.warning(f"Could not run {FacterLinux.GET_SE_LINUX_ST_CMD}: OK")
483483
return False
484484

485485
def return_first_words_from_list(self, list):
@@ -549,7 +549,7 @@ def get_ip_address_by_ifname(self, ifname):
549549
)[20:24]
550550
)
551551
except Exception as err:
552-
log.warn(f"Can't get the IP address for {ifname}")
552+
log.warning(f"Can't get the IP address for {ifname}")
553553

554554
return ip_address_by_ifname
555555

@@ -566,7 +566,7 @@ def getInterfaces(self):
566566
if result != "":
567567
return result
568568
# If the host has neither `ifocnfig` command nor `ip` command, then return "OS NOT SUPPORTED"
569-
log.warn(
569+
log.warning(
570570
f"Can't get a network interfaces list from {self.DATA_IFCONFIG_SHORT_OUTPUT}"
571571
)
572572
return "OS NOT SUPPORTED"
@@ -578,7 +578,7 @@ def getUptimeSeconds(self):
578578
self.data_return_first(FacterLinux.DIGITS_REGEXP, self.DATA_UPTIME_OUTPUT)
579579
)
580580
except ValueError:
581-
log.warn(f"Can't get an uptime value from {self.DATA_UPTIME_OUTPUT}")
581+
log.warning(f"Can't get an uptime value from {self.DATA_UPTIME_OUTPUT}")
582582
return 0
583583

584584
# Return memoryfree
@@ -589,7 +589,7 @@ def getMemoryFree(self):
589589
self.data_return_first(FacterLinux.FREEMEM_REGEXP, self.DATA_MEMINFO_OUTPUT)
590590
)
591591
except ValueError:
592-
log.warn(f"Can't get free memory size from {self.DATA_MEMINFO_OUTPUT}")
592+
log.warning(f"Can't get free memory size from {self.DATA_MEMINFO_OUTPUT}")
593593
return 0
594594

595595
# Return memorytotal
@@ -599,7 +599,7 @@ def getMemoryTotal(self):
599599
self.data_return_first(FacterLinux.TOTALMEM_REGEXP, self.DATA_MEMINFO_OUTPUT)
600600
)
601601
except ValueError:
602-
log.warn(f"Can't get total memory size from {self.DATA_MEMINFO_OUTPUT}")
602+
log.warning(f"Can't get total memory size from {self.DATA_MEMINFO_OUTPUT}")
603603
return 0
604604

605605
# Return swapfree
@@ -610,7 +610,7 @@ def getSwapFree(self):
610610
self.data_return_first(FacterLinux.SWAPFREE_REGEXP, self.DATA_MEMINFO_OUTPUT)
611611
)
612612
except ValueError:
613-
log.warn(f"Can't get free swap memory size from {self.DATA_MEMINFO_OUTPUT}")
613+
log.warning(f"Can't get free swap memory size from {self.DATA_MEMINFO_OUTPUT}")
614614
return 0
615615

616616
# Return swapsize
@@ -621,7 +621,7 @@ def getSwapSize(self):
621621
self.data_return_first(FacterLinux.SWAPTOTAL_REGEXP, self.DATA_MEMINFO_OUTPUT)
622622
)
623623
except ValueError:
624-
log.warn(f"Can't get total swap memory size from {self.DATA_MEMINFO_OUTPUT}")
624+
log.warning(f"Can't get total swap memory size from {self.DATA_MEMINFO_OUTPUT}")
625625
return 0
626626

627627
# Return memorysize
@@ -632,7 +632,7 @@ def getMemorySize(self):
632632
self.data_return_first(FacterLinux.TOTALMEM_REGEXP, self.DATA_MEMINFO_OUTPUT)
633633
)
634634
except ValueError:
635-
log.warn(f"Can't get memory size from {self.DATA_MEMINFO_OUTPUT}")
635+
log.warning(f"Can't get memory size from {self.DATA_MEMINFO_OUTPUT}")
636636
return 0
637637

638638
def facterInfo(self):

ambari-agent/src/main/python/ambari_agent/FileCache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def provide_directory(self, cache_path, subdirectory, server_url_prefix):
212212
self.write_hash_sum(full_path, remote_hash)
213213
logger.info(f"Updated directory {full_path}")
214214
else:
215-
logger.warn(
215+
logger.warning(
216216
"Skipping empty archive: {0}. "
217217
"Expected archive was not found. Cached copy will be used.".format(
218218
download_url
@@ -224,7 +224,7 @@ def provide_directory(self, cache_path, subdirectory, server_url_prefix):
224224
except CachingException as e:
225225
if self.tolerate_download_failures:
226226
# ignore
227-
logger.warn(
227+
logger.warning(
228228
"Error occurred during cache update. "
229229
"Error tolerate setting is set to true, so"
230230
" ignoring this error and continuing with current cache. "

ambari-agent/src/main/python/ambari_agent/Hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def osdisks(self):
184184
)
185185
dfdata = out
186186
except Exception as ex:
187-
logger.warn("Checking disk usage failed: " + str(ex))
187+
logger.warning("Checking disk usage failed: " + str(ex))
188188
dfdata = ""
189189

190190
result_mounts = []

ambari-agent/src/main/python/ambari_agent/HeartbeatThread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def presend_hook(correlation_id):
330330
)
331331
except ConnectionIsAlreadyClosed:
332332
# this happens when trying to connect to broken connection. Happens if ambari-server is restarted.
333-
logger.warn(f"Connection failed while trying to connect to {destination}")
333+
logger.warning(f"Connection failed while trying to connect to {destination}")
334334
raise
335335

336336
try:

0 commit comments

Comments
 (0)