Skip to content

Conversation

@dacbd
Copy link
Contributor

@dacbd dacbd commented Jan 3, 2022

@DavidGOrtega DavidGOrtega changed the title Closes #343 Fix runner termination in AWS with non cloud regions Jan 3, 2022
@dacbd
Copy link
Contributor Author

dacbd commented Jan 3, 2022

@DavidGOrtega this should take care of it, I have to set up an AWS acc to really give it whirl if you can try it out against how you were able to reproduce the original error as well?

@dacbd dacbd marked this pull request as ready for review January 3, 2022 23:30
@DavidGOrtega
Copy link
Contributor

I will try it

)

var (
SynthRegions = map[string]map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about this... I prefer to have the GetRegions implementation per provider. Or should go in the machine... if we were using the machine...

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 moved it here because I think there was actually a bug in the subnet-id code after you guys fixed the last one.

See previous:

	region := GetRegion(d.Get("region").(string))
	availabilityZone := GetAvailabilityZone(region)

The get avail func would always get a stripped region and never detect an availability-zone, now it needs to first reference the synth-regions map to eliminate those as a false positive.

Since it need to be referenced in multiple places I went ahead and broke it out / consolidated that helper func across all providers.

@dacbd
Copy link
Contributor Author

dacbd commented Jan 4, 2022

after beating my personal AWS account's 2FA (had to dig up an old phone 🔒 ) I tested with the original command from discord and the instance self terminated successfully:

./bin/cml.js runner \
    --labels=cml-runner \
    --idle-timeout=60 \
    --reuse \
    --cloud aws \
    --cloud-type=t2.micro \
    --cloud-spot true \
    --cloud-region us-west

@DavidGOrtega
Copy link
Contributor

Thanks @dacbd. How did you manage to setup this version of the provider in the cloud instance?
The ways I have found are:

  • Create your own provider in terraform's registry
  • use a local provider -> setup a large idle_timeout (10mins) -> connect SSH -> make my terraform provider

Obviously the first one is easier but the registry is buggy and sometimes the provider breaks and can not be updated and cant be deleted. I have a bunch of them already

@dacbd
Copy link
Contributor Author

dacbd commented Jan 4, 2022

@DavidGOrtega you know I didn't actually put much thought into it and now that you mention is I'm not 100% sure it worked properly(using the right one), (but it kinda, since it self-terminated). I modified the cml terraform.js to use a local one and added a git clone/checkout then make && make install into a startup script...

Were you able to test it with the latest commit successfully? -- I've put more thought in testing custom cml versions #255 😉

@DavidGOrtega
Copy link
Contributor

@dacbd still testing it... Right now I have an issue but it should not be because of this PR think...
With region us-west-1 goes fine, with us-west it does not... it propagates the tf file with region us-west-1 and then I have an error about roles... a very nice riddle since as I say using us-west-1 is working always

No EC2 imds role found

@dacbd
Copy link
Contributor Author

dacbd commented Jan 4, 2022

I'll try a few more as well

"eu-north": "europe-north1-a",
"eu-west": "europe-west1-d",
},
"az": {
Copy link
Contributor

Choose a reason for hiding this comment

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

@dacbd cloud in machine and runner is azure not az

@0x2b3bfa0 we should have maintained the consistency

I do not feel confident to release this without having tested every cloud.
Please @dacbd try to fix it just only for AWS vendor without reaching a wider scope

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean roll back utils.Get region

Copy link
Member

Choose a reason for hiding this comment

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

@0x2b3bfa0 we should have maintained the consistency

We do, to some extent.

} else if cloud == "azure" || cloud == "az" {

Copy link
Contributor

Choose a reason for hiding this comment

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

@0x2b3bfa0 we should have maintained the consistency

We do, to some extent.

} else if cloud == "azure" || cloud == "az" {

We should support then az in the machine and runner

Copy link
Member

Choose a reason for hiding this comment

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

We do support az in both the machine and runner resources. At least, before merging this pull request.

Copy link
Contributor

Choose a reason for hiding this comment

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

One should be an alias of the other to avoid issues like this one

Copy link
Member

Choose a reason for hiding this comment

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

Do you mean replacing the value intead of accepting both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, an alias

@casperdcl casperdcl added cloud-aws Amazon Web Services p0-critical Max priority (ASAP) resource-runner iterative_runner TF resource labels Jan 4, 2022
@dacbd
Copy link
Contributor Author

dacbd commented Jan 4, 2022

@DavidGOrtega Something like this okay or do you want it more fully reverted back?

@dacbd dacbd marked this pull request as draft January 4, 2022 17:13
@dacbd
Copy link
Contributor Author

dacbd commented Jan 4, 2022

I've had good terminations with:

us-west
us-west-1
us-west-1c
us-west-1b

@dacbd dacbd marked this pull request as ready for review January 4, 2022 17:22
@dacbd dacbd requested a review from DavidGOrtega January 4, 2022 17:22
)

var (
AWSSynthRegions = map[string]map[string]string{
Copy link
Member

@0x2b3bfa0 0x2b3bfa0 Jan 4, 2022

Choose a reason for hiding this comment

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

Given that it's only for AWS, wouldn't it be enough to use a simple map[string]string? Else, should it be named SynthRegions instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed probably I would keep it in the AWS provider instead of utils

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 Author

Choose a reason for hiding this comment

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

I can roll it back more, I left it in to inflict my feelings that these region mappings should all be defined in one place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably makes sense to have it in the provider following the same pattern as the others. Also as @0x2b3bfa0 pointed out there is not need to use a matrix

Copy link
Contributor

@DavidGOrtega DavidGOrtega left a comment

Choose a reason for hiding this comment

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

👍

@DavidGOrtega
Copy link
Contributor

🙏 thanks @dacbd !!! ❤️

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

Labels

cloud-aws Amazon Web Services p0-critical Max priority (ASAP) resource-runner iterative_runner TF resource

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runner does not destroy if we set a synthetic region in AWS

4 participants