这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Merged
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
24 changes: 19 additions & 5 deletions src/main/java/com/netflix/simianarmy/janitor/AbstractJanitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,16 @@ public void cleanupResources() {
markedResource.getId(), markedResource.getResourceType().name()));
if (!leashed) {
try {
cleanup(markedResource);
markedResource.setActualTerminationTime(now);
markedResource.setState(Resource.CleanupState.JANITOR_TERMINATED);
resourceTracker.addOrUpdate(markedResource);
if (recorder != null) {
Event evt = recorder.newEvent(Type.JANITOR, EventTypes.CLEANUP_RESOURCE, region,
markedResource.getId());
addFieldsAndTagsToEvent(markedResource, evt);
recorder.recordEvent(evt);
}
cleanup(markedResource);
markedResource.setActualTerminationTime(now);
markedResource.setState(Resource.CleanupState.JANITOR_TERMINATED);
resourceTracker.addOrUpdate(markedResource);
} catch (Exception e) {
LOGGER.error(String.format("Failed to clean up the resource %s of type %s.",
markedResource.getId(), markedResource.getResourceType().name()), e);
Expand All @@ -330,7 +331,20 @@ public void cleanupResources() {
}
}

/** Determines if the input resource can be cleaned. The Janitor calls this method
/**
* Adds selected resource fields and all the tags from the given resource as additional fields on the event.
* @param resource the resource with the the source data
* @param event the event that will hold the source data as additional fields
*/
private void addFieldsAndTagsToEvent(Resource resource, Event event) {
for(String key : resource.getAllTagKeys()) {
event.addField(key, resource.getTag(key));
}
event.addField("ResourceDescription", resource.getDescription());
event.addField("ResourceType", resource.getResourceType().toString());
}

/** Determines if the input resource can be cleaned. The Janitor calls this method
* before cleaning up a resource and only cleans the resource when the method returns
* true. A resource is considered to be OK to clean if
* 1) it is marked as cleanup candidates
Expand Down