Skip to content
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

More changes in support of multiple orchestrations #32

Open
wants to merge 10 commits into
base: kmp_datastore_use_account_wrr_ecs_exp2
Choose a base branch
from

Conversation

netsettler
Copy link
Collaborator

This is work in progress.

PLEASE IGNORE THE FOLLOWING, which I'll be cleaning up more:

  • Large blocks of commented out code.
  • Random print statements and pdb settings. (I think I removed them but I'll re-check before trying to make this final.)

Copy link
Member

@willronchetti willronchetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes aside from some small things I think you're already working to clean up generally look great. One thing to look into though is why the security group rules for the application security group are being dropped. We saw in your test account that the security group is missing rules, though it is not obvious from the code changes why.

Comment on lines +44 to +56
class SingletonManager():

def __init__(self, singleton_class, *singleton_args, **singleton_kwargs):
self._singleton = None
self._singleton_class = singleton_class
self._singleton_args = singleton_args
self._singleton_kwargs = singleton_kwargs

@property
def singleton(self):
if not self._singleton:
self._singleton = self._singleton_class(*self._singleton_args or (), **self._singleton_kwargs or {})
return self._singleton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go in utils?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably but not today. I'll make a note for the future.

app_utils_obj = AppUtils()

# app_utils_obj = AppUtils()
app_utils_manager = SingletonManager(AppUtils)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the concern multiple initialization? I think chalice prevents that from happening, but admit I'm not sure. We have not had issues with this in the past though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. We can look at that later. Seems harmless if it's done elsewhere too.



########################
# Misc utility functions
########################


def compute_valid_deploy_stages():
return list(Deploy.CONFIG_BASE['stages'].keys()) + ['test']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test is not a deploy stage I'm aware of.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's allowed somewhere, and not due to me. We should hunt this down sometime. I'm going to leave this.

source ~/.aws_test/test_creds.sh
poetry run cli provision --trial --output_file out/foursight-dev-tmp/ --stage dev foursight --alpha --upload_change_set
source custom/aws_creds/test_creds.sh
poetry run cli provision --output_file out/foursight-dev-tmp/ --stage dev foursight --upload_change_set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note on dev vs. prod stage is probably useful here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a "to do" note in the doc.

Comment on lines +124 to +130
secrets = self._load_config(self.SECRETS_FILE)
if True:
if not secrets.get(Secrets.S3_ENCRYPT_KEY): # if missing or empty, try to default from file
secrets[Secrets.S3_ENCRYPT_KEY] = ConfigManager.get_s3_encrypt_key_from_file()
else:
print(f"WARNING: {Secrets.S3_ENCRYPT_KEY} is not in {self.SECRETS_FILE},"
f" and the file {self.S3_ENCRYPT_KEY_FILE} does not exist.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if True is this intended?

Comment on lines +128 to +131
ignorable(indexer)
template.add_resource(self.ecs_ingester_task())
ingester = template.add_resource(self.ecs_ingester_service())
ignorable(ingester)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These variables are from old code and can just be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in sources to be uploaded shortl.

Comment on lines +340 to +342
# VERY IMPORTANT - this environment variable determines which identity in the secrets manager
# to use. If this secret does not exist, things will not start up correctly - this is ok in
# the short term, but shortly after orchestration the secret value should be set.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be updated to indicate that ECS may not come online at all if the secret is not filled out fully.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

@@ -680,15 +696,17 @@ def ecs_deployment_task(self, cpus='256', mem='512', identity=None, initial=Fals
LogConfiguration=LogConfiguration(
LogDriver='awslogs',
Options={
'awslogs-group': self.LOGGING_EXPORTS.import_value(C4LoggingExports.CGAP_APPLICATION_LOG_GROUP),
'awslogs-group':
self.LOGGING_EXPORTS.import_value(C4LoggingExports.CGAP_APPLICATION_LOG_GROUP),
'awslogs-region': Ref(AWS_REGION),
'awslogs-stream-prefix': 'cgap-deployment'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prefix should probably be cgap-initial-deployment so that it can be distinguished easily from other deployment logs.

Comment on lines 340 to +342
"arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role",
# Maybe?
# "arn:aws:iam::aws:policy/aws-service-role/AmazonECSServiceRolePolicy"
# Maybe?
# "arn:aws:iam::aws:policy/aws-service-role/AmazonECSServiceRolePolicy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ECS role policy is the desired one and we don't require the EC2 perms either IRC.

Comment on lines +17 to +22
SUBNETS = {
'PrivateSubnetA': {'name': 'PrivateSubnetA', 'cidr_block': '10.0.0.0/18', 'az': 'us-east-1a', 'kind': 'private'},
'PublicSubnetA': {'name': 'PublicSubnetA', 'cidr_block': '10.0.64.0/18', 'az': 'us-east-1a', 'kind': 'public'},
'PrivateSubnetB': {'name': 'PrivateSubnetB', 'cidr_block': '10.0.128.0/18', 'az': 'us-east-1b', 'kind': 'private'},
'PublicSubnetB': {'name': 'PublicSubnetB', 'cidr_block': '10.0.192.0/18', 'az': 'us-east-1b', 'kind': 'public'},
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might consider allowing some of this to come from settings, especially AZ's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants