You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AMA] Improve the uninstall of AMA by removing files for clean uninstall situation (#2087)
* cleanup of files for a clean uninstall situation. uninstall command is unaffected
* wrong commit
* refactoring to support current operations and have the update operation cache files for install later on
* cleanup
* preserving log files into cache. may need to look into rpm vs dpkg due to difference in uninstall command
* Removed events folder for extension logs. Removes /opt/microsoft/azuremonitoragent for rpm. Caches logs in /var/opt/microsoft/azuremonitoragent/log
* cleanup
* fixed path
* added caching of tenants
* more robust file and directory collection for uninstall
* Config files such as tenants are cached, removing changes related to this.
* Changed patternt o be use context from a marker file
* add comments and update docstring
* fixed logging for debug and edited comments
* updated doc on update()
* quick change to bundlefilename
* added logging and tested for python 2 and 3 compat
* spacing
* code cleanup and changes based on feedback
* minor cleanup and moved call to get_uninstall_context()
* spacing
* updated comments and logging
* remove extra period
* cleanup code, style changes
* cleanup
* added constant for AMA data path
---------
Co-authored-by: Dylan Bunarto <[email protected]>
f.write(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) # Timestamp for debugging
1252
+
hutil_log_info("Marked uninstall context as 'update'")
1253
+
exceptExceptionasex:
1254
+
hutil_log_error("Failed to set uninstall context: {0}\n The uninstall operation will not behave as expected with the uninstall context file missing, defaulting to an uninstall that removes {1}.".format(ex, AmaDataPath))
1255
+
1256
+
return0, "Update succeeded"
1257
+
1258
+
def_get_uninstall_context():
1259
+
"""
1260
+
Determine the context of this uninstall operation
1261
+
1262
+
Returns the context as a string:
1263
+
'complete' - if this is a clean uninstall
1264
+
'update' - if this is an update operation
1265
+
Also returns as 'complete' if it fails to read the context file.
hutil_log_info("Uninstall context file does not exist, defaulting to 'complete'")
1276
+
exceptExceptionasex:
1277
+
hutil_log_error("Failed to read uninstall context file: {0}\n The uninstall operation will not behave as expected with the uninstall context file missing, defaulting to an uninstall that removes {1}.".format(ex, AmaDataPath))
1278
+
1279
+
return'complete'
1280
+
1281
+
def_cleanup_uninstall_context():
1282
+
"""
1283
+
Clean up uninstall context marker
1284
+
"""
1285
+
1286
+
try:
1287
+
ifos.path.exists(AmaUninstallContextFile):
1288
+
os.remove(AmaUninstallContextFile)
1289
+
hutil_log_info("Removed uninstall context file")
1290
+
else:
1291
+
hutil_log_info("Uninstall context file does not exist, nothing to remove")
1292
+
exceptExceptionasex:
1293
+
hutil_log_error("Failed to cleanup uninstall context: {0}\n This may result in unintended behavior as described.\nIf the marker file exists and cannot be removed, uninstall will continue to keep the {1} path, leading users to have to remove it manually.".format(ex, AmaDataPath))
0 commit comments