Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Fix Anubis Setup Destroy #768

Merged
merged 6 commits into from
Aug 23, 2019
Merged

Fix Anubis Setup Destroy #768

merged 6 commits into from
Aug 23, 2019

Conversation

Chancebair
Copy link
Contributor

  • Adds a sync-infra target
  • Fixes pipeline destroy by manually revoking security group association
  • Undeploys the bai-bff loadbalancer

ci/anubis-driver.py Outdated Show resolved Hide resolved
):
group_id = subprocess.check_output(["terraform", "output", "blackbox_vpc_default_group_id"]).strip()
source_group = subprocess.check_output(["terraform", "output", "blackbox_public_group_id"]).strip()
return_code = subprocess.call(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate why this is necessary? We should not use the aws cli in any case because any resource that exists in this account, was created by some kind of stateful automation. The removal should then happen through the same automation, as otherwise we're corrupting the state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Terraform isn't smart enough to disassociate dependent rules before deleting security groups, therefore it will just hang on "deleting security group" when the console prompts that there are dependent references of that security group elsewhere

Copy link
Contributor

Choose a reason for hiding this comment

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

Who created and associated these security groups?

Copy link
Contributor Author

@Chancebair Chancebair Aug 23, 2019

Choose a reason for hiding this comment

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

Terraform

Copy link
Contributor

Choose a reason for hiding this comment

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

@marcoabreu I get where you are coming from... we should walk the same path forward and we do backward. This shows that an out-of-band actor is inserted in the reverse path. It turns out that this is somewhat avoidable as there is not this affordance directly in TF.
So this is unfortunately the way we need to go. @Chancebair Please document this caveat so that posterity is aware of this decision point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commented the hack in the script

Copy link
Contributor

@marcoabreu marcoabreu Aug 23, 2019

Choose a reason for hiding this comment

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

Which resource specifically has these groups assigned so that we run into that bug? Is it an instance, an ELB or something else? Also, it would be great if you could point me to the line where this "buggy" reference is being created in the first place.

ci/anubis-driver.py Show resolved Hide resolved
ci/anubis-driver.py Outdated Show resolved Hide resolved
destroy_pipeline(region)
undeploy_services()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the right order of execution? I'd expect undeploy services to happen first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pipeline and the services are mutually exclusive, it doesn't matter

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

print(f"=> Calling `./baictl sync infra --aws-region={region}` in baictl to get kubeconfig")

if os.path.exists(os.path.join(os.path.dirname(__file__), "../baictl/drivers/aws/cluster/.terraform")):
return_code = subprocess.call(["rm", "-rf", "drivers/aws/cluster/.terraform"], cwd="../baictl")
Copy link
Contributor

Choose a reason for hiding this comment

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

os.path.join(os.path.dirname(file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What?

Copy link
Contributor

Choose a reason for hiding this comment

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

You still have relative references based on the users CWD in your code.

]
)
devnull = open(os.devnull, "w")
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not convinced that this is the right thing to do. I rather feel like we're working around an issue here, so I'd like to see this elaborated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@marcoabreu
Your objection is reasonable and noted - Now, could you, please offer an alternative solution that can be implemented within a reasonable time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still trying to understand which resource specifically has this security group assigned. So far, the situation is not very transparent. As soon as I have all the data, I'm happy to assist with a solution. But so far, I'm still at the information-gathering stage.

Copy link
Contributor

@gavinmbell gavinmbell left a comment

Choose a reason for hiding this comment

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

Let's not make perfect the enemy of progress....
But please make a not of the caveat being introduced here and add it to the installation documentation.
trenches

👍

ci/anubis-driver.py Outdated Show resolved Hide resolved
ci/anubis-driver.py Outdated Show resolved Hide resolved


def undeploy_services():
parent_dir = os.path.join(os.path.dirname(__file__), "..")
Copy link
Contributor

Choose a reason for hiding this comment

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

What about guys, who are not deployable?

puller/kafka-utils/metrics-pusher?

Do they have stubs, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently its broken on #688 so I can't get any further to test

service_dirs = [
f
for f in os.listdir(parent_dir)
if os.path.isdir(os.path.join(parent_dir, f)) and os.path.exists(os.path.join(parent_dir, f) + "/Makefile")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't repeat expressions, plz.
Extract variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This references the for loop iterator, so can't be broken out

@@ -228,7 +259,6 @@ def main():
# Create pipeline which creates infrastructure and deploys services
print(f"=> Calling `terraform plan --out=terraform.plan`")
return_code = subprocess.call(["terraform", "plan", "--out=terraform.plan"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Not in this PR.
Please ensure, that terraform python API doesn't satisfy our needs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried the terraform-python package and it was garbage

@Chancebair Chancebair merged commit c81cdb0 into master Aug 23, 2019
@Chancebair Chancebair deleted the chanbair-fix-destroy branch August 29, 2019 12:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants