Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
This repository was archived by the owner on Mar 4, 2021. It is now read-only.

Make Janitor Monkey ignore Stopped Instances/Resources #310

Open

Description

@truongvinhtien

Hi,
I am new to SimianArmy, and my company required me to set the Janitor Monkey to shutting down the resources instead of terminating them so they can keep the data. I just merely edited some pieces of code in the AWSClient.java and InstanceJanitor.java so that it can stop the instance, and somehow it worked.
In the AWSClient.java:

@Override
    public void terminateInstance(String instanceId) {
        Validate.notEmpty(instanceId);
        LOGGER.info(String.format("Stopping instance %s in region %s.", instanceId, region));
        try {
            ec2Client().stopInstances(new StopInstancesRequest(Arrays.asList(instanceId)));
        } catch (AmazonServiceException e) {
            if (e.getErrorCode().equals("InvalidInstanceID.NotFound")) {
                throw new NotFoundException("AWS instance " + instanceId + " not found", e);
            }
            throw e;
        }
    }   

In the InstanceJanitor.java

@Override
    protected void cleanup(Resource resource) {
        LOGGER.info(String.format("Stopping instance %s", resource.getId()));
        awsClient.terminateInstance(resource.getId());
    }

I wonder if there is any proper way to apply this method for all the resource types. Moreover, when I ran the Janitor Monkey again it also remarked the stopped instances for cleaning up. Can I implement the JM to ignore the stopped/inactive resources?

Many thanks.

Activity

  1. arpansolanki commented on Jan 23, 2018

    @arpansolanki

    Check InstanceJanitorCrawler.java
    You will have to modify it to only crawl running instances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions