-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove duplicate EC2 cleanup jobs #1151
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,25 +20,10 @@ | |
"iterationsize": 100, | ||
"iterative": true | ||
}, | ||
{ | ||
"query": "MATCH (:AWSAccount{id: $AWS_ID})-[:RESOURCE]->(:EC2Instance)-[r:PART_OF_SUBNET]->(:EC2Subnet) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is covered by autocleanups in models.aws.ec2.subnets. |
||
"iterationsize": 100, | ||
"iterative": true | ||
}, | ||
{ | ||
"query": "MATCH (:AWSAccount{id: $AWS_ID})-[:RESOURCE]->(:LoadBalancer)-[r:PART_OF_SUBNET]->(:EC2Subnet) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r)", | ||
"iterationsize": 100, | ||
"iterative": true | ||
}, | ||
{ | ||
"query": "MATCH (:AWSAccount{id: $AWS_ID})-[:RESOURCE]->(n:NetworkInterface) WHERE n.lastupdated <> $UPDATE_TAG WITH n LIMIT $LIMIT_SIZE DETACH DELETE (n)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is covered by autocleanups in models.aws.ec2.networkinterfaces. |
||
"iterative": true, | ||
"iterationsize": 100 | ||
}, | ||
{ | ||
"query": "MATCH (:AWSAccount{id: $AWS_ID})-[r:RESOURCE]->(:NetworkInterface) WHERE r.lastupdated <> $UPDATE_TAG WITH r LIMIT $LIMIT_SIZE DELETE (r)", | ||
"iterative": true, | ||
"iterationsize": 100 | ||
} | ||
], | ||
"name": "cleanup NetworkInterface" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,11 +308,6 @@ def cleanup(neo4j_session: neo4j.Session, common_job_parameters: Dict[str, Any]) | |
logger.debug("Running EC2 instance cleanup") | ||
GraphJob.from_node_schema(EC2ReservationSchema(), common_job_parameters).run(neo4j_session) | ||
GraphJob.from_node_schema(EC2InstanceSchema(), common_job_parameters).run(neo4j_session) | ||
GraphJob.from_node_schema(EC2SubnetSchema(), common_job_parameters).run(neo4j_session) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are all moved from here to their respective modules. Specifically,
|
||
GraphJob.from_node_schema(EC2SecurityGroupSchema(), common_job_parameters).run(neo4j_session) | ||
GraphJob.from_node_schema(EC2KeyPairSchema(), common_job_parameters).run(neo4j_session) | ||
GraphJob.from_node_schema(EC2NetworkInterfaceSchema(), common_job_parameters).run(neo4j_session) | ||
GraphJob.from_node_schema(EBSVolumeSchema(), common_job_parameters).run(neo4j_session) | ||
|
||
|
||
@timeit | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
import neo4j | ||
|
||
from .util import get_botocore_config | ||
from cartography.graph.job import GraphJob | ||
from cartography.models.aws.ec2.securitygroups import EC2SecurityGroupSchema | ||
from cartography.util import aws_handle_regions | ||
from cartography.util import run_cleanup_job | ||
from cartography.util import timeit | ||
|
@@ -146,6 +148,7 @@ def cleanup_ec2_security_groupinfo(neo4j_session: neo4j.Session, common_job_para | |
neo4j_session, | ||
common_job_parameters, | ||
) | ||
GraphJob.from_node_schema(EC2SecurityGroupSchema(), common_job_parameters).run(neo4j_session) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still need to keep both, for now, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this is intentional because the other resources cleaned up in aws_import_ec2_security_groupinfo_cleanup.json have not been refactored to the new model yet. |
||
|
||
|
||
@timeit | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is covered by autocleanups in models.aws.ec2.securitygroups. Additionally the autocleanups also handle a previously unhandled case where we need to cleanup stale rels between SGs and instances.