Skip to content

Conversation

leopoldo94
Copy link
Contributor

@leopoldo94 leopoldo94 commented Sep 22, 2025

Implementation of the activation's sync to legacy function

Resolves IOPAE-2118

@leopoldo94 leopoldo94 requested a review from a team as a code owner September 22, 2025 13:46
Copy link

changeset-bot bot commented Sep 22, 2025

🦋 Changeset detected

Latest commit: 0243bdf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
io-services-cms-webapp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

Copy link
Contributor

Tip

✅ All Terraform module locks are up to date

No module changes detected - everything is in sync!

📋 Pre-commit Output Log
[INFO] Initializing environment for https://github.com/pagopa/dx.
[INFO] Initializing environment for https://github.com/antonbabenko/pre-commit-terraform.
Lock Terraform Registry modules..........................................Passed

Generated on Mon Sep 22 13:47:41 UTC 2025
Run lock_modules on folder: infra/resources/prod/

Copy link
Contributor

📖 Terraform Plan (infra/resources/prod) - success

Show Plan
  # module.function_app.azurerm_monitor_autoscale_setting.app_be_fn will be updated in-place
  ~ resource "azurerm_monitor_autoscale_setting" "app_be_fn" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Insights/autoScaleSettings/io-p-itn-svc-app-be-func-01-autoscale"
        name                = "io-p-itn-svc-app-be-func-01-autoscale"
        tags                = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Enti & Servizi"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (4 unchanged attributes hidden)

      ~ profile {
          ~ name = "evening" -> jsonencode(
                {
                  + for  = "evening"
                  + name = "default"
                }
            )

          ~ capacity {
              ~ default = 5 -> 4
                # (2 unchanged attributes hidden)
            }

          ~ recurrence {
              ~ hours    = [
                  ~ 19 -> 22,
                ]
              ~ minutes  = [
                  ~ 30 -> 59,
                ]
                # (2 unchanged attributes hidden)
            }

            # (5 unchanged blocks hidden)
        }
      ~ profile {
          ~ name = "night" -> jsonencode(
                {
                  + for  = "night"
                  + name = "default"
                }
            )

          ~ capacity {
              ~ default = 3 -> 4
                # (2 unchanged attributes hidden)
            }

          ~ recurrence {
              ~ hours    = [
                  ~ 23 -> 5,
                ]
                # (3 unchanged attributes hidden)
            }

            # (5 unchanged blocks hidden)
        }
      ~ profile {
          ~ name = jsonencode(
                {
                  - for  = "evening"
                  - name = "default"
                }
            ) -> "evening"

          ~ capacity {
              ~ default = 8 -> 5
              ~ minimum = 8 -> 3
                # (1 unchanged attribute hidden)
            }

          ~ recurrence {
              ~ hours    = [
                  ~ 22 -> 19,
                ]
              ~ minutes  = [
                  ~ 59 -> 30,
                ]
                # (2 unchanged attributes hidden)
            }

          ~ rule {
              ~ metric_trigger {
                  ~ statistic                = "Max" -> "Average"
                  ~ threshold                = 2000 -> 3000
                  ~ time_aggregation         = "Maximum" -> "Average"
                    # (7 unchanged attributes hidden)
                }
              ~ scale_action {
                  ~ cooldown  = "PT5M" -> "PT1M"
                  ~ value     = 3 -> 2
                    # (2 unchanged attributes hidden)
                }
            }
          ~ rule {
              ~ metric_trigger {
                  ~ statistic                = "Max" -> "Average"
                  ~ threshold                = 35 -> 60
                  ~ time_aggregation         = "Maximum" -> "Average"
                  ~ time_window              = "PT1M" -> "PT5M"
                    # (6 unchanged attributes hidden)
                }
              ~ scale_action {
                  ~ value     = 3 -> 2
                    # (3 unchanged attributes hidden)
                }
            }
          ~ rule {
              ~ metric_trigger {
                  ~ threshold                = 1000 -> 2000
                    # (9 unchanged attributes hidden)
                }

                # (1 unchanged block hidden)
            }

            # (2 unchanged blocks hidden)
        }
      ~ profile {
          ~ name = jsonencode(
                {
                  - for  = "night"
                  - name = "default"
                }
            ) -> "night"

          ~ capacity {
              ~ default = 8 -> 3
              ~ minimum = 8 -> 3
                # (1 unchanged attribute hidden)
            }

          ~ recurrence {
              ~ hours    = [
                  ~ 5 -> 23,
                ]
                # (3 unchanged attributes hidden)
            }

          ~ rule {
              ~ metric_trigger {
                  ~ statistic                = "Max" -> "Average"
                  ~ threshold                = 2000 -> 3000
                  ~ time_aggregation         = "Maximum" -> "Average"
                    # (7 unchanged attributes hidden)
                }
              ~ scale_action {
                  ~ cooldown  = "PT5M" -> "PT1M"
                  ~ value     = 3 -> 2
                    # (2 unchanged attributes hidden)
                }
            }
          ~ rule {
              ~ metric_trigger {
                  ~ statistic                = "Max" -> "Average"
                  ~ threshold                = 35 -> 60
                  ~ time_aggregation         = "Maximum" -> "Average"
                  ~ time_window              = "PT1M" -> "PT5M"
                    # (6 unchanged attributes hidden)
                }
              ~ scale_action {
                  ~ value     = 3 -> 2
                    # (3 unchanged attributes hidden)
                }
            }
          ~ rule {
              ~ metric_trigger {
                  ~ threshold                = 1000 -> 2000
                    # (9 unchanged attributes hidden)
                }

                # (1 unchanged block hidden)
            }

            # (2 unchanged blocks hidden)
        }
    }

  # module.cms_function_app.module.cms_fn.azurerm_linux_function_app.this will be updated in-place
  ~ resource "azurerm_linux_function_app" "this" {
      ~ app_settings                                   = {
          + "AzureWebJobs.ActivationsSyncToLegacy.Disabled"                                                    = "1"
            # (133 unchanged elements hidden)
        }
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Web/sites/io-p-itn-svc-cms-func-01"
        name                                           = "io-p-itn-svc-cms-func-01"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Enti & Servizi"
            "ModuleName"                                     = "azure_function_app"
            "ModuleSource"                                   = "DX"
            "ModuleVersion"                                  = "2.0.2"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (33 unchanged attributes hidden)

      ~ sticky_settings {
          ~ app_setting_names       = [
                # (33 unchanged elements hidden)
                "AzureWebJobs.ActivationsSyncFromLegacy.Disabled",
              + "AzureWebJobs.ActivationsSyncToLegacy.Disabled",
            ]
            # (1 unchanged attribute hidden)
        }

        # (2 unchanged blocks hidden)
    }

  # module.cms_function_app.module.cms_fn.azurerm_linux_function_app_slot.this[0] will be updated in-place
  ~ resource "azurerm_linux_function_app_slot" "this" {
      ~ app_settings                                   = {
          + "AzureWebJobs.ActivationsSyncToLegacy.Disabled"                                                    = "1"
            # (133 unchanged elements hidden)
        }
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Web/sites/io-p-itn-svc-cms-func-01/slots/staging"
        name                                           = "staging"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Enti & Servizi"
            "ModuleName"                                     = "azure_function_app"
            "ModuleSource"                                   = "DX"
            "ModuleVersion"                                  = "2.0.2"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (31 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.cms_function_app.module.cms_storage_account.azurerm_monitor_metric_alert.storage_account_health_check[0] will be updated in-place
  ~ resource "azurerm_monitor_metric_alert" "storage_account_health_check" {
        id                       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Insights/metricAlerts/[iopitnsvccmsst01] Low Availability"
        name                     = "[iopitnsvccmsst01] Low Availability"
      ~ tags                     = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Enti & Servizi"
            "ModuleName"     = "azure_storage_account"
            "ModuleSource"   = "DX"
          ~ "ModuleVersion"  = "1.0.0" -> "1.0.1"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (10 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.cms_function_app.module.cms_storage_account.azurerm_private_endpoint.this["blob"] will be updated in-place
  ~ resource "azurerm_private_endpoint" "this" {
        id                            = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Network/privateEndpoints/io-p-itn-svc-cms-blob-pep-01"
        name                          = "io-p-itn-svc-cms-blob-pep-01"
      ~ tags                          = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Enti & Servizi"
            "ModuleName"     = "azure_storage_account"
            "ModuleSource"   = "DX"
          ~ "ModuleVersion"  = "1.0.0" -> "1.0.1"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (7 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.cms_function_app.module.cms_storage_account.azurerm_private_endpoint.this["queue"] will be updated in-place
  ~ resource "azurerm_private_endpoint" "this" {
        id                            = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Network/privateEndpoints/io-p-itn-svc-cms-queue-pep-01"
        name                          = "io-p-itn-svc-cms-queue-pep-01"
      ~ tags                          = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Enti & Servizi"
            "ModuleName"     = "azure_storage_account"
            "ModuleSource"   = "DX"
          ~ "ModuleVersion"  = "1.0.0" -> "1.0.1"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (7 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

  # module.cms_function_app.module.cms_storage_account.azurerm_storage_account.this will be updated in-place
  ~ resource "azurerm_storage_account" "this" {
        id                                 = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Storage/storageAccounts/iopitnsvccmsst01"
        name                               = "iopitnsvccmsst01"
      ~ tags                               = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Enti & Servizi"
            "ModuleName"     = "azure_storage_account"
            "ModuleSource"   = "DX"
          ~ "ModuleVersion"  = "1.0.0" -> "1.0.1"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (97 unchanged attributes hidden)

        # (5 unchanged blocks hidden)
    }

  # module.function_app.module.app_be_fn.azurerm_linux_function_app_slot.this[0] will be updated in-place
  ~ resource "azurerm_linux_function_app_slot" "this" {
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-svc-rg-01/providers/Microsoft.Web/sites/io-p-itn-svc-app-be-func-01/slots/staging"
        name                                           = "staging"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Enti & Servizi"
            "ModuleName"                                     = "azure_function_app"
            "ModuleSource"                                   = "DX"
            "ModuleVersion"                                  = "0.3.1"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-services-cms/infra/prod/italynorth"
        }
        # (32 unchanged attributes hidden)

      ~ site_config {
          ~ health_check_eviction_time_in_min             = 0 -> 2
            # (33 unchanged attributes hidden)

            # (1 unchanged block hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.postgres.module.pgres_snet.azurerm_subnet.this will be updated in-place
  ~ resource "azurerm_subnet" "this" {
        id                                            = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-common-rg-01/providers/Microsoft.Network/virtualNetworks/io-p-itn-common-vnet-01/subnets/io-p-itn-svc-pgres-snet-01"
        name                                          = "io-p-itn-svc-pgres-snet-01"
      ~ service_endpoints                             = [
          - "Microsoft.Storage",
        ]
        # (7 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 9 to change, 0 to destroy.

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for App Backend (./apps/app-backend)

Status Category Percentage Covered / Total
🔵 Lines 81.59% 687 / 842
🔵 Statements 81.59% 687 / 842
🔵 Functions 75% 33 / 44
🔵 Branches 94.11% 128 / 136
File CoverageNo changed files found.
Generated in workflow #3693

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for Backoffice Frontend (./apps/backoffice)

Status Category Percentage Covered / Total
🔵 Lines 14.9% 1647 / 11049
🔵 Statements 14.9% 1647 / 11049
🔵 Functions 28.32% 83 / 293
🔵 Branches 64.91% 185 / 285
File CoverageNo changed files found.
Generated in workflow #3693

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for Backoffice Backend (./apps/backoffice)

Status Category Percentage Covered / Total
🔵 Lines 66.17% 3511 / 5306
🔵 Statements 66.17% 3511 / 5306
🔵 Functions 64.93% 150 / 231
🔵 Branches 83.9% 641 / 764
File CoverageNo changed files found.
Generated in workflow #3693

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for Webapp (./apps/io-services-cms-webapp)

Status Category Percentage Covered / Total
🔵 Lines 87.23% 6172 / 7075
🔵 Statements 87.23% 6172 / 7075
🔵 Functions 90.28% 288 / 319
🔵 Branches 91.27% 963 / 1055
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
apps/io-services-cms-webapp/src/watchers/on-activations-change.ts 91.17% 71.42% 100% 91.17% 31, 33, 36, 78-79, 81
Generated in workflow #3693

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for External Clients (./packages/external-clients)

Status Category Percentage Covered / Total
🔵 Lines 84.38% 643 / 762
🔵 Statements 84.38% 643 / 762
🔵 Functions 79.16% 38 / 48
🔵 Branches 95.14% 98 / 103
File CoverageNo changed files found.
Generated in workflow #3693

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for Models (./packages/io-services-cms-models)

Status Category Percentage Covered / Total
🔵 Lines 81.17% 1337 / 1647
🔵 Statements 81.17% 1337 / 1647
🔵 Functions 66.31% 63 / 95
🔵 Branches 97.25% 177 / 182
File CoverageNo changed files found.
Generated in workflow #3693

return ActivationStatusEnum.PENDING;
default:
// Should never happen if validation is correct
return ActivationStatusEnum.INACTIVE;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): use typechecker to be sure you have handled all cases.

Furthermore, consider whether in this “impossible” case it is correct to return a default value (are you sure INACTIVE is the correct default value?) or to throw an error. (throw new Error("Invalid status");)

Suggested change
return ActivationStatusEnum.INACTIVE;
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-case-declarations
const _: never = status;
return ActivationStatusEnum.INACTIVE;

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants