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

Replace Airnode's short address with deployment ID #1577

Merged
merged 4 commits into from
Dec 8, 2022

Conversation

amarthadan
Copy link
Contributor

Close #1486

@amarthadan amarthadan requested a review from a team December 1, 2022 12:54
@amarthadan amarthadan self-assigned this Dec 1, 2022
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

👍 code LGTM, left a few suggestions (and didn't test on cloud providers)

.createHash('sha256')
.update([...cloudProviderHashElements(cloudProvider), airnodeAddress, stage, airnodeVersion, timestamp].join(''))
.digest('hex')
.substring(0, 8);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe have a constant for the digest length?

@@ -354,7 +349,7 @@ describe('terraformAirnodeApply', () => {
);
expect(exec).toHaveBeenNthCalledWith(
2,
`terraform apply -var="aws_region=us-east-1" -var="airnode_address_short=a30ca71" -var="stage=dev" -var="configuration_file=${configPath}" -var="secrets_file=${secretsPath}" -var="handler_dir=${handlerDir}" -var="disable_concurrency_reservation=false" -var="airnode_wallet_private_key=0xd627c727db73ed7067cbc1e15295f7004b83c01d243aa90711d549cda6bd5bca" -input=false -no-color -var="max_concurrency=100" -var="http_gateway_enabled=true" -var="http_max_concurrency=20" -var="http_signed_data_gateway_enabled=true" -var="http_signed_data_max_concurrency=20" -auto-approve`,
`terraform apply -var="aws_region=us-east-1" -var="deployment_id=aws40207f25" -var="configuration_file=${configPath}" -var="secrets_file=${secretsPath}" -var="handler_dir=${handlerDir}" -var="disable_concurrency_reservation=false" -var="airnode_wallet_private_key=0xd627c727db73ed7067cbc1e15295f7004b83c01d243aa90711d549cda6bd5bca" -input=false -no-color -var="max_concurrency=100" -var="http_gateway_enabled=true" -var="http_max_concurrency=20" -var="http_signed_data_gateway_enabled=true" -var="http_signed_data_max_concurrency=20" -auto-approve`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know I was a bit sad when I had to edit this line, but I didn't want to change it at that time... WDYT if we split it by the parameters. E.g.:

[`terraform apply`, `-var="aws_region=us-east-1"`, `-var="deployment_id=aws40207f25"`, `-var="configuration_file=${configPath}"`...].join(' ')

name_prefix = "${var.infrastructure_name}-${var.airnode_address_short}-${var.stage}"
# deployment_id - 11 characters
# dash between - 1 character
name_prefix = "${var.infrastructure_name}-${var.deployment_id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we make the deployment ID a bit longer? The 8 characters length seems to me unreasoanbly low.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? Are you worried about collisions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, and I do not see a reason why not make it longer when the character limit allows it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One reason would be so that the outputs of list and info deployer commands won't be that wide. But I'll take a look. Maybe 12 or even 16 would be doable.

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'll keep the 8-character deployment IDs for now. The rows from the list and info commands are around 120 characters long now and I don't want to increase that more. Also, the probability of a collision is still quite low. From a quick googling the problem is not with the hash function creating a collision but rather running into a collision purely based on limited possibilities from the pool of strings of that length and composition (https://stackoverflow.com/a/30565118). But even that, gives us about 65k possible hashes for 8-character long substrings (https://www.bluebill.net/hash_collisions.html). No one account will have that.

@amarthadan amarthadan merged commit ff0a98b into master Dec 8, 2022
@amarthadan amarthadan deleted the remove-airnode-short-address branch December 8, 2022 12:33
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.

Replace Airnode short address and stage with deployment ID in names for cloud resources
2 participants