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

feat: allow specifying calibnet and/or mainnet snapshot for the daily… #438

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

samuelarogbonlo
Copy link
Contributor

@samuelarogbonlo samuelarogbonlo commented May 3, 2024

Summary of changes
Changes introduced in this pull request:

  • allow specifying calibnet and/or mainnet snapshot for the daily snapshot

Reference issue to close (if applicable)

Closes #376

Other information and links

… snapshot

Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
@samuelarogbonlo samuelarogbonlo requested a review from a team as a code owner May 3, 2024 10:22
@samuelarogbonlo samuelarogbonlo requested review from hanabi1224 and aatifsyed and removed request for a team May 3, 2024 10:22
Copy link

github-actions bot commented May 3, 2024

Forest: snapshot-service-2 Infrastructure Plan: success

Show Plan
data.external.sources_tar: Reading...
data.local_file.init: Reading...
data.local_file.init: Read complete after 0s [id=4d486acceed8550de7daf88b21a982282ecd276c]
data.digitalocean_ssh_keys.keys: Reading...
data.digitalocean_project.forest_project: Reading...
data.external.sources_tar: Read complete after 0s [id=-]
data.local_file.sources: Reading...
module.monitoring[0].newrelic_alert_policy.alert: Refreshing state... [id=1349725]
module.monitoring[0].newrelic_notification_channel.slack-channel[0]: Refreshing state... [id=349ca4f8-787a-4782-9c6e-8d532f41a002]
data.local_file.sources: Read complete after 0s [id=ead79a551c85277c20d8688bd02827f7e2fd4015]
data.digitalocean_ssh_keys.keys: Read complete after 1s [id=ssh_keys/8656000852680004208]
digitalocean_droplet.forest: Refreshing state... [id=417950396]
digitalocean_firewall.forest-firewall: Refreshing state... [id=4a79c6cd-e2a0-49f1-8f12-e4ee6d46dfa3]
data.digitalocean_project.forest_project: Read complete after 2s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
module.monitoring[0].newrelic_nrql_alert_condition.disk_space: Refreshing state... [id=1349725:6421439]
module.monitoring[0].newrelic_workflow.alerting-workflow-slack[0]: Refreshing state... [id=4a82f1e1-b154-4932-b97a-121adeea3ddf]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2024-05-10T10:19:32Z" -> (known after apply)
      ~ disk                 = 320 -> (known after apply)
      ~ id                   = "417950396" -> (known after apply)
      ~ ipv4_address         = "144.126.220.249" -> (known after apply)
      ~ ipv4_address_private = "10.124.0.2" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "prod-forest-snapshot-2"
      ~ price_hourly         = 0.14286 -> (known after apply)
      ~ price_monthly        = 96 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
            "prod",
        ]
      ~ urn                  = "do:droplet:417950396" -> (known after apply)
      ~ user_data            = (sensitive value) # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "d8fa19e6-fef4-479e-a36a-d83fdba66322" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 417950396,
        ] -> (known after apply)
        id              = "4a79c6cd-e2a0-49f1-8f12-e4ee6d46dfa3"
        name            = "prod-forest-snapshot-2"
        tags            = []
        # (3 unchanged attributes hidden)

        # (7 unchanged blocks hidden)
    }

  # digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:417950396",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - "144.126.220.249",
      + (known after apply),
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: /home/runner/work/forest-iac/forest-iac/tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "/home/runner/work/forest-iac/forest-iac/tfplan"

Copy link

github-actions bot commented May 3, 2024

Forest: snapshot-service Infrastructure Plan: success

Show Plan
data.local_file.init: Reading...
data.local_file.init: Read complete after 0s [id=4d486acceed8550de7daf88b21a982282ecd276c]
data.digitalocean_project.forest_project: Reading...
data.digitalocean_ssh_keys.keys: Reading...
data.external.sources_tar: Reading...
module.monitoring[0].newrelic_alert_policy.alert: Refreshing state... [id=1349724]
module.monitoring[0].newrelic_notification_channel.slack-channel[0]: Refreshing state... [id=7837be74-ec17-471e-867a-592c169c57a8]
data.external.sources_tar: Read complete after 0s [id=-]
data.local_file.sources: Reading...
data.local_file.sources: Read complete after 0s [id=ead79a551c85277c20d8688bd02827f7e2fd4015]
data.digitalocean_ssh_keys.keys: Read complete after 0s [id=ssh_keys/8656000852680004208]
digitalocean_droplet.forest: Refreshing state... [id=417950391]
digitalocean_firewall.forest-firewall: Refreshing state... [id=263cfc76-df47-4e0b-9aa1-1df0644e9076]
module.monitoring[0].newrelic_nrql_alert_condition.disk_space: Refreshing state... [id=1349724:6421438]
module.monitoring[0].newrelic_workflow.alerting-workflow-slack[0]: Refreshing state... [id=7db462a6-6380-4672-81ed-6a01c30fa65c]
data.digitalocean_project.forest_project: Read complete after 1s [id=da5e6601-7fd9-4d02-951e-390f7feb3411]
digitalocean_project_resources.connect_forest_project: Refreshing state... [id=da5e6601-7fd9-4d02-951e-390f7feb3411]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # digitalocean_droplet.forest must be replaced
-/+ resource "digitalocean_droplet" "forest" {
      ~ created_at           = "2024-05-10T10:19:31Z" -> (known after apply)
      ~ disk                 = 200 -> (known after apply)
      ~ id                   = "417950391" -> (known after apply)
      ~ ipv4_address         = "165.22.90.19" -> (known after apply)
      ~ ipv4_address_private = "10.135.0.4" -> (known after apply)
      + ipv6_address         = (known after apply)
      ~ locked               = false -> (known after apply)
      ~ memory               = 16384 -> (known after apply)
        name                 = "prod-forest-snapshot"
      ~ price_hourly         = 0.125 -> (known after apply)
      ~ price_monthly        = 84 -> (known after apply)
      ~ private_networking   = true -> (known after apply)
      ~ status               = "active" -> (known after apply)
        tags                 = [
            "iac",
            "prod",
        ]
      ~ urn                  = "do:droplet:417950391" -> (known after apply)
      ~ user_data            = (sensitive value) # forces replacement
      ~ vcpus                = 4 -> (known after apply)
      ~ volume_ids           = [] -> (known after apply)
      ~ vpc_uuid             = "46a525ac-fd37-47ea-bb10-95c1db0055f7" -> (known after apply)
        # (9 unchanged attributes hidden)
    }

  # digitalocean_firewall.forest-firewall will be updated in-place
  ~ resource "digitalocean_firewall" "forest-firewall" {
      ~ droplet_ids     = [
          - 417950391,
        ] -> (known after apply)
        id              = "263cfc76-df47-4e0b-9aa1-1df0644e9076"
        name            = "prod-forest-snapshot"
        tags            = []
        # (3 unchanged attributes hidden)

        # (7 unchanged blocks hidden)
    }

  # digitalocean_project_resources.connect_forest_project will be updated in-place
  ~ resource "digitalocean_project_resources" "connect_forest_project" {
        id        = "da5e6601-7fd9-4d02-951e-390f7feb3411"
      ~ resources = [
          - "do:droplet:417950391",
        ] -> (known after apply)
        # (1 unchanged attribute hidden)
    }

Plan: 1 to add, 2 to change, 1 to destroy.

Changes to Outputs:
  ~ ip = [
      - "165.22.90.19",
      + (known after apply),
    ]

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: /home/runner/work/forest-iac/forest-iac/tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "/home/runner/work/forest-iac/forest-iac/tfplan"

Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
@samuelarogbonlo samuelarogbonlo requested review from LesnyRumcajs and lemmih and removed request for LesnyRumcajs May 3, 2024 10:33
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
samuelarogbonlo and others added 6 commits May 6, 2024 11:31
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
Signed-off-by: samuelarogbonlo <sbayo971@gmail.com>
@samuelarogbonlo
Copy link
Contributor Author

ping @LesnyRumcajs

default = ["mainnet", "calibnet"]

validation {
condition = alltrue([for val in var.snapshot_type : contains(["mainnet", "calibnet"], val)])
Copy link
Member

Choose a reason for hiding this comment

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

Can we also check that the list is not empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LesnyRumcajs. done, please re-approve.

Comment on lines +24 to +40
echo "$SNAPSHOT_TYPE"

# Setup cron job
IFS=',' read -ra ADDR <<< "$SNAPSHOT_TYPE"
for type in "${ADDR[@]}"; do
case "$type" in
mainnet)
mv mainnet_cron_job /etc/cron.hourly/
;;
calibnet)
mv calibnet_cron_job /etc/cron.hourly/
;;
*)
echo "Error: Invalid network type '$type'"
;;
esac
done
Copy link
Member

Choose a reason for hiding this comment

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

It can be a follow-up, but we can generate the cron scripts now, instead of copying pre-defined ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure sure.

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.

Allow specifying calibnet and/or mainnet snapshot for the daily snapshot
3 participants