Skip to content

[Bug]: Unstable sorting for triggers in pipelines? #155

Open
@lyricnz

Description

@lyricnz

What happened?

When applying the same pipeline definition (or with unrelated change), the order of the "triggers" within the pipeline swaps "at random", implying some kind of unstable sort. For example, we have two triggers "nonprod" and "infradev" and the tf-plan shows these being swapped:

      ~ spec {                                                                                                                                                          
            # (10 unchanged attributes hidden)                                                                                                                          
                                                                                                                                                                        
          ~ trigger {                                                                                                                                                   
              ~ modified_files_glob              = "nonprod/accounts/**" -> "infradev/accounts/**"                                                                      
              ~ name                             = "nonprod_config_change" -> "infradev_config_change"                                                                  
              ~ variables                        = {                                                                                                                    
                  ~ "ENV_NAME" = "nonprod" -> "infradev"                                                                                                                
                }                                                                                                                                                       
                # (15 unchanged attributes hidden)                                                                                                                      
                                                                                                                                                                        
              ~ runtime_environment {                                                                                                                                   
                  ~ name                       = "inClusterContext/cf-rt-mainnp-jft00u4fo7t4o205" -> "inClusterContext/cf-rt-nonprod-fnuwz2oh1ubv4mjd"                  
                    # (4 unchanged attributes hidden)                                                                                                                   
                }                                                                                                                                                       
            }                                                                                                                                                           
          ~ trigger {                                                                                                                                                   
              ~ modified_files_glob              = "infradev/accounts/**" -> "nonprod/accounts/**"                                                                      
              ~ name                             = "infradev_config_change" -> "nonprod_config_change"                                                                  
              ~ variables                        = {                                                                                                                    
                  ~ "ENV_NAME" = "infradev" -> "nonprod"                                                                                                                
                }                                                                                                                                                       
                # (15 unchanged attributes hidden)                                                                                                                      
                                                                                                                                                                        
              ~ runtime_environment {                                                                                                                                   
                  ~ name                       = "inClusterContext/cf-rt-nonprod-fnuwz2oh1ubv4mjd" -> "inClusterContext/cf-rt-mainnp-jft00u4fo7t4o205"                  
                    # (4 unchanged attributes hidden)                                                                                                                   
                }                                                                                                                                                       
            }                                                                                                                                                           
                                                                                                                                                                        
            # (2 unchanged blocks hidden)                                                                                                                               
        }                                                                                                                                                               

Version

codefresh-io/codefresh v0.11.0

Relevant Terraform Configuration

resource "codefresh_pipeline" "config" {
  name      = "${codefresh_project.cloudsnooze.name}/config"
  tags      = ["config"]
  is_public = true

  spec {
    concurrency = 1

    runtime_environment {
      name   = local.runtime_nonprod
      memory = "4000Mi"
    }

    contexts = [local.secrets_context]

    # The spec_template block refers to the pipeline workflow YAML used
    spec_template {
      repo     = "${local.ghe_org}/${local.ghe_repo_config}"
      path     = "./codefresh.yml"
      revision = "develop" # branch
      context  = local.ghe_codefresh_integration_context
    }

    # Trigger the pipeline when commits to /$envname are made.
    # The pipeline itseld will only notify+deploy when branch=develop
    # We create one trigger per environment and set variables based on this.
    trigger {
      type     = "git"
      provider = "github"
      context  = local.ghe_codefresh_integration_context
      repo     = "${local.ghe_org}/${local.ghe_repo_config}"
      # branch_regex       = "/^((develop)$).*/gi"
      # branch_regex_input = "multiselect"
      events = [
        "push.heads"
      ]
      modified_files_glob = "infradev/accounts/**"
      name                = "infradev_config_change"
      disabled            = false
      variables = {
        ENV_NAME = "infradev"
      }
      runtime_environment {
        name   = local.runtime_infradev
        memory = "2000Mi"
      }
    }

    trigger {
      type     = "git"
      provider = "github"
      context  = local.ghe_codefresh_integration_context
      repo     = "${local.ghe_org}/${local.ghe_repo_config}"
      # branch_regex       = "/^((develop)$).*/gi"
      # branch_regex_input = "multiselect"
      events = [
        "push.heads"
      ]
      modified_files_glob = "nonprod/accounts/**"
      name                = "nonprod_config_change"
      disabled            = false
      variables = {
        ENV_NAME = "nonprod"
      }
      runtime_environment {
        name   = local.runtime_nonprod
        memory = "2000Mi"
      }
    }

    # Pipeline variables to include that can be referenced in the pipeline workflow YAML
    variables = {
      NOTIFICATION_EMAIL = "[email protected]"
    }
  }

}

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions