Skip to content

fix: disable unnecessary fetch_materials option for pipeline-complete branches#89

Merged
mchen-sentry merged 2 commits intomainfrom
mingchen/di-1685-gocd-static-agent-is-blocking-for-pipeline-complete
Mar 5, 2026
Merged

fix: disable unnecessary fetch_materials option for pipeline-complete branches#89
mchen-sentry merged 2 commits intomainfrom
mingchen/di-1685-gocd-static-agent-is-blocking-for-pipeline-complete

Conversation

@mchen-sentry
Copy link
Member

@mchen-sentry mchen-sentry commented Mar 5, 2026

fetch_materials is enabled by default in GoCD and enforces that the agent must first fetch Git materials (git fetch on the repo if existing, otherwise clone), before proceeding.

This operation should not be enabled in the pipeline-complete stage as it's unnecessary and introduces additional overhead.

Currently, it's blocking pipelines from completing as our static agent used for the pipeline-complete stage is going OOM due to cloning too many large repos.

See thread: https://sentry.slack.com/archives/CTJL7358X/p1772738303953669

@linear-code
Copy link

linear-code bot commented Mar 5, 2026

@mchen-sentry mchen-sentry requested review from a team and joshuarli March 5, 2026 21:13
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Orphaned golden files with no matching fixture
    • Removed the two orphaned rollback-final-stage-override golden files so only fixture-backed goldens remain.

Create PR

Or push these changes by commenting:

@cursor push 0e07865eab
Preview (0e07865eab)
diff --git a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden
deleted file mode 100644
--- a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_output-files.golden
+++ /dev/null
@@ -1,484 +1,0 @@
-{
-   "deploy-example-customer-1.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-customer-1": {
-            "display_order": 5,
-            "group": "example",
-            "materials": {
-               "deploy-example-us-pipeline-complete": {
-                  "pipeline": "deploy-example-us",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=customer-1"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-customer-2.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-customer-2": {
-            "display_order": 6,
-            "group": "example",
-            "materials": {
-               "deploy-example-customer-1-pipeline-complete": {
-                  "pipeline": "deploy-example-customer-1",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=customer-2"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-customer-4.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-customer-4": {
-            "display_order": 7,
-            "group": "example",
-            "materials": {
-               "deploy-example-customer-2-pipeline-complete": {
-                  "pipeline": "deploy-example-customer-2",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=customer-4"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-customer-7.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-customer-7": {
-            "display_order": 8,
-            "group": "example",
-            "materials": {
-               "deploy-example-customer-4-pipeline-complete": {
-                  "pipeline": "deploy-example-customer-4",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=customer-7"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-de.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-de": {
-            "display_order": 3,
-            "group": "example",
-            "materials": {
-               "deploy-example-s4s2-pipeline-complete": {
-                  "pipeline": "deploy-example-s4s2",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=de"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-s4s.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-s4s": {
-            "display_order": 9,
-            "group": "example",
-            "materials": {
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=s4s"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-s4s2.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-s4s2": {
-            "display_order": 2,
-            "group": "example",
-            "materials": {
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=s4s2"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "deploy-example-us.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "deploy-example-us": {
-            "display_order": 4,
-            "group": "example",
-            "materials": {
-               "deploy-example-de-pipeline-complete": {
-                  "pipeline": "deploy-example-de",
-                  "stage": "pipeline-complete"
-               },
-               "example_repo": {
-                  "branch": "master",
-                  "destination": "example",
-                  "git": "git@github.com:getsentry/example.git"
-               }
-            },
-            "stages": [
-               {
-                  "deploy": {
-                     "jobs": {
-                        "deploy": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "./deploy.sh --region=us"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "pipeline-complete": {
-                     "fetch_materials": false,
-                     "jobs": {
-                        "pipeline-complete": {
-                           "tasks": [
-                              {
-                                 "exec": {
-                                    "command": true
-                                 }
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   },
-   "rollback-example.yaml": {
-      "format_version": 10,
-      "pipelines": {
-         "rollback-example": {
-            "display_order": 1,
-            "environment_variables": {
-               "ALL_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7",
-               "GOCD_ACCESS_TOKEN": "{{SECRET:[devinfra][gocd_access_token]}}",
-               "REGION_PIPELINE_FLAGS": "--pipeline=deploy-example-s4s2 --pipeline=deploy-example-de --pipeline=deploy-example-us --pipeline=deploy-example-customer-1 --pipeline=deploy-example-customer-2 --pipeline=deploy-example-customer-4 --pipeline=deploy-example-customer-7",
-               "ROLLBACK_MATERIAL_NAME": "example_repo",
-               "ROLLBACK_STAGE": "deploy",
-               "TRIGGERED_BY": ""
-            },
-            "group": "example",
-            "lock_behavior": "unlockWhenFinished",
-            "materials": {
-               "deploy-example-customer-7-deploy": {
-                  "pipeline": "deploy-example-customer-7",
-                  "stage": "deploy"
-               }
-            },
-            "stages": [
-               {
-                  "pause_pipelines": {
-                     "approval": {
-                        "type": "manual"
-                     },
-                     "jobs": {
-                        "rollback": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n  set -- $ALL_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline is being rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n  pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Pause all pipelines in the pipedream\ngocd-pause-and-cancel-pipelines \\\n  --pause-message=\"$pause_message\" \\\n  \"$@\"\n"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "start_rollback": {
-                     "jobs": {
-                        "rollback": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "##!/bin/bash\n\n## Note: $REGION_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${REGION_PIPELINE_FLAGS:-}\" ]]; then\n  set -- $REGION_PIPELINE_FLAGS\nfi\n\n## The user that triggered the rollback\nTRIGGERED_BY=\"${TRIGGERED_BY:-}\"\n\npause_message='This pipeline was rolled back, please check with team before un-pausing.'\n\n## Include triggered by in the pause message if it is not empty\nif [ -n \"$TRIGGERED_BY\" ]; then\n  pause_message=\"$pause_message Triggered by: $TRIGGERED_BY\"\nfi\n\n## Get sha from the given pipeline run to deploy to all pipedream pipelines.\nsha=$(gocd-sha-for-pipeline --material-name=\"${ROLLBACK_MATERIAL_NAME}\")\n\necho \"📑 Rolling back to sha: ${sha}\"\n\ngocd-emergency-deploy \\\n  --material-name=\"${ROLLBACK_MATERIAL_NAME}\" \\\n  --commit-sha=\"${sha}\" \\\n  --deploy-stage=\"${ROLLBACK_STAGE}\" \\\n  --pause-message=\"$pause_message\" \\\n  \"$@\"\n"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               },
-               {
-                  "incident_resolved": {
-                     "approval": {
-                        "type": "manual"
-                     },
-                     "jobs": {
-                        "rollback": {
-                           "elastic_profile_id": "example",
-                           "tasks": [
-                              {
-                                 "script": "##!/bin/bash\n\n## Note: $ALL_PIPELINE_FLAGS has no quoting, for word expansion\n## shellcheck disable=SC2086\nif [[ \"${ALL_PIPELINE_FLAGS:-}\" ]]; then\n  set -- $ALL_PIPELINE_FLAGS\nfi\n\n## Unpause and unlock all pipelines in the pipedream\ngocd-unpause-and-unlock-pipelines \\\n  \"$@\"\n"
-                              }
-                           ]
-                        }
-                     }
-                  }
-               }
-            ]
-         }
-      }
-   }
-}
\ No newline at end of file

diff --git a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden b/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden
deleted file mode 100644
--- a/test/testdata/goldens/pipedream/rollback-final-stage-override.jsonnet_single-file.golden
+++ /dev/null
@@ -1,442 +1,0 @@
-{
-   "format_version": 10,
-   "pipelines": {
-      "deploy-example-customer-1": {
-         "display_order": 5,
-         "group": "example",
-         "materials": {
-            "deploy-example-us-pipeline-complete": {
-               "pipeline": "deploy-example-us",
-               "stage": "pipeline-complete"
-            },
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=customer-1"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-customer-2": {
-         "display_order": 6,
-         "group": "example",
-         "materials": {
-            "deploy-example-customer-1-pipeline-complete": {
-               "pipeline": "deploy-example-customer-1",
-               "stage": "pipeline-complete"
-            },
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=customer-2"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-customer-4": {
-         "display_order": 7,
-         "group": "example",
-         "materials": {
-            "deploy-example-customer-2-pipeline-complete": {
-               "pipeline": "deploy-example-customer-2",
-               "stage": "pipeline-complete"
-            },
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=customer-4"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-customer-7": {
-         "display_order": 8,
-         "group": "example",
-         "materials": {
-            "deploy-example-customer-4-pipeline-complete": {
-               "pipeline": "deploy-example-customer-4",
-               "stage": "pipeline-complete"
-            },
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=customer-7"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-de": {
-         "display_order": 3,
-         "group": "example",
-         "materials": {
-            "deploy-example-s4s2-pipeline-complete": {
-               "pipeline": "deploy-example-s4s2",
-               "stage": "pipeline-complete"
-            },
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=de"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-s4s": {
-         "display_order": 9,
-         "group": "example",
-         "materials": {
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=s4s"
-                           }
-                        ]
-                     }
-                  }
-               }
-            },
-            {
-               "pipeline-complete": {
-                  "fetch_materials": false,
-                  "jobs": {
-                     "pipeline-complete": {
-                        "tasks": [
-                           {
-                              "exec": {
-                                 "command": true
-                              }
-                           }
-                        ]
-                     }
-                  }
-               }
-            }
-         ]
-      },
-      "deploy-example-s4s2": {
-         "display_order": 2,
-         "group": "example",
-         "materials": {
-            "example_repo": {
-               "branch": "master",
-               "destination": "example",
-               "git": "git@github.com:getsentry/example.git"
-            }
-         },
-         "stages": [
-            {
-               "deploy": {
-                  "jobs": {
-                     "deploy": {
-                        "elastic_profile_id": "example",
-                        "tasks": [
-                           {
-                              "script": "./deploy.sh --region=s4s2"
-                           }
-                        ]
-                     }
-                  }
... diff truncated: showing 800 of 939 lines
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

@mchen-sentry mchen-sentry merged commit 56cc4d9 into main Mar 5, 2026
6 checks passed
@mchen-sentry mchen-sentry deleted the mingchen/di-1685-gocd-static-agent-is-blocking-for-pipeline-complete branch March 5, 2026 21:23
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.

2 participants