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

When created from template, CheckPrecondition doesn't evaluate expression correctly after upstream stages get restarted #6933

Open
slououou opened this issue Mar 8, 2024 · 2 comments
Labels

Comments

@slououou
Copy link

slououou commented Mar 8, 2024

Issue Summary:

In pipeline created from template, CheckPrecondition doesn't evaluate expression correctly after upstream stages get restarted

Cloud Provider(s):

Kubernetes

Environment:

1.32.3

Feature Area:

Pipeline Expressions

Description:

We found that, if pipeline is created through template, the evalution expression of CheckPrecondition stages in that pipeline doesn't work correctly after the upstream stage restarted.

Steps to Reproduce:

  1. create a pipeline with a jenkins stage (ignore this stage failure) and a check precondition stage, example as below JSON configuration:
{
  "keepWaitingPipelines": false,
  "limitConcurrent": true,
  "schema": "1",
  "spelEvaluator": "v4",
  "stages": [
    {
      "completeOtherBranchesThenFail": false,
      "continuePipeline": true,
      "failPipeline": false,
      "job": "restart-test",
      "master": "my-jenkins",
      "name": "stage-1",
      "parameters": {},
      "refId": "1",
      "requisiteStageRefIds": [],
      "type": "jenkins"
    },
    {
      "name": "Check Preconditions",
      "preconditions": [
        {
          "context": {
            "expression": "\"${ ((#stage('stage-1')['status'].toString()  == 'SUCCEEDED') or (#stage('stage-1')['status'].toString()  == 'SKIPPED')) }\""
          },
          "failPipeline": true,
          "type": "expression"
        }
      ],
      "refId": "2",
      "requisiteStageRefIds": [
        "1"
      ],
      "type": "checkPreconditions"
    }
  ]
}
  1. export this pipeline as a template
  2. create another pipeline through that template, example as below JSON configuration:
{
  "exclude": [],
  "keepWaitingPipelines": false,
  "limitConcurrent": true,
  "notifications": [],
  "parameterConfig": [],
  "schema": "v2",
  "stages": [],
  "template": {
    "artifactAccount": "front50ArtifactCredentials",
    "reference": "spinnaker://6b09493f-f467-4f48-a5cb-87547e7edfdb:latest",
    "type": "front50/pipelineTemplate"
  },
  "triggers": [],
  "type": "templatedPipeline",
  "variables": {}
}
  1. configure the jenkins job to give a failure output, then start an execution of the pipeline created from template. The stage-1 and Check Preconditions will both fail.
  2. configure the jenkins job to give a success output, then restart stage-1 in last execution. stage-1 will succeed, while Check Preconditions still fails.

Additional Details:

Related issue: #6829 and #6675. It is fixed with a change of reading pipeline configuration in gate. Is it possible that it does not cover the situation of pipeline created from template?

@slououou
Copy link
Author

slououou commented Mar 8, 2024

rjalander Is pipeline created by template covered in your last fix in https://github.com/spinnaker/gate/pull/1560/files ?

@spinnakerbot
Copy link

This issue hasn't been updated in 45 days, so we are tagging it as 'stale'. If you want to remove this label, comment:

@spinnakerbot remove-label stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants