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

Feature: Create a random hash to a node name #85

Closed
4 tasks done
samuelstolicny opened this issue Oct 7, 2021 · 8 comments · Fixed by #107
Closed
4 tasks done

Feature: Create a random hash to a node name #85

samuelstolicny opened this issue Oct 7, 2021 · 8 comments · Fixed by #107
Assignees
Labels
feature New feature good first issue Good for newcomers groomed Task that everybody agrees to pass the gatekeeper mvp In scope of the MVP stage

Comments

@samuelstolicny
Copy link
Contributor

samuelstolicny commented Oct 7, 2021

Motivation:

Some providers require name uniqueness (for example GCP) for virtual machines and some other resources. In order to avoid this problem, we should generate a unique random hash for every config file.

Description:

Random hash should be generated before or as part of the applyTerraform() function
Hash should be config file unique.

Exit criteria:

  • Find out which resources need to be unique
  • Generate and add random hash to every firewall
  • Generate and add random hash to every node
  • Generate and add random hash to every ssh_key (Hetzner)
@samuelstolicny samuelstolicny added good first issue Good for newcomers feature New feature labels Oct 7, 2021
@bernardhalas
Copy link
Member

Consider this approach for all providers (not just GCP).

@bernardhalas bernardhalas added the groomed Task that everybody agrees to pass the gatekeeper label Oct 11, 2021
@jaskeerat789
Copy link
Contributor

https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go

We can use this for generating strings of length n to append it to the node name. We can also look into the uuid but as discussed in the grooming, the length of these uuid(32 byte) will be a bit too long for our use case.

@jaskeerat789 jaskeerat789 self-assigned this Oct 12, 2021
@bernardhalas bernardhalas added the mvp In scope of the MVP stage label Oct 26, 2021
@samuelstolicny
Copy link
Contributor Author

samuelstolicny commented Oct 27, 2021

The firewall name should be also unique.

Error: name is already used (uniqueness_error)
│
│   with hcloud_firewall.defaultfirewall,
│   on hetzner.tf line 10, in resource "hcloud_firewall" "defaultfirewall":
│   10: resource "hcloud_firewall" "defaultfirewall" {

I am adding two new exit criteria to this task:

  • Find out which resources need to be unique (maybe network name in GCP)
  • Generate and add random hash to every firewall

@jaskeerat789 you will need to add these new hashes into our golang templates. If you need help with that feel free to call me.

@jaskeerat789
Copy link
Contributor

The firewall name should be also unique.

Error: name is already used (uniqueness_error)
│
│   with hcloud_firewall.defaultfirewall,
│   on hetzner.tf line 10, in resource "hcloud_firewall" "defaultfirewall":
│   10: resource "hcloud_firewall" "defaultfirewall" {

I am adding two new exit criteria to this task:

  • Find out which resources need to be unique (maybe network name in GCP)
  • Generate and add random hash to every firewall

@jaskeerat789 you will need to add these new hashes into our golang templates. If you need help with that feel free to call me.

Cool, I'll resume from Monday, will let you know if I need any help. Thanks for the update.

@jaskeerat789 jaskeerat789 linked a pull request Nov 5, 2021 that will close this issue
@samuelstolicny
Copy link
Contributor Author

@jaskeerat789 Found another resource that needs to be unique: ssh key name on Hetzner

terraformer   | │ Error: SSH key name is already used (uniqueness_error)
terraformer   | │ 
terraformer   | │   with hcloud_ssh_key.platform,
terraformer   | │   on hetzner.tf line 56, in resource "hcloud_ssh_key" "platform":
terraformer   | │   56: resource "hcloud_ssh_key" "platform" {

@jaskeerat789
Copy link
Contributor

I think its is better to add the hash to all resources because it can be easy to debug things if the resources don't have same name even though uniqueness is not required. What are your thoughts ? @bernardhalas @samuelstolicny @borkaz

@samuelstolicny
Copy link
Contributor Author

I think its is better to add the hash to all resources because it can be easy to debug things if the resources don't have same name even though uniqueness is not required. What are your thoughts ? @bernardhalas @samuelstolicny @borkaz

I agree

@samuelstolicny
Copy link
Contributor Author

All conditions were met and the feature was successfully implemented in #107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature good first issue Good for newcomers groomed Task that everybody agrees to pass the gatekeeper mvp In scope of the MVP stage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants