spinnaker icon indicating copy to clipboard operation
spinnaker copied to clipboard

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

Open slououou opened this issue 1 year ago • 6 comments

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: https://github.com/spinnaker/spinnaker/issues/6829 and https://github.com/spinnaker/spinnaker/issues/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 avatar Mar 08 '24 08:03 slououou

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

slououou avatar Mar 08 '24 09:03 slououou

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

spinnakerbot avatar Apr 22 '24 09:04 spinnakerbot

This issue is tagged as 'stale' and hasn't been updated in 45 days, so we are tagging it as 'to-be-closed'. It will be closed in 45 days unless updates are made. If you want to remove this label, comment:

@spinnakerbot remove-label to-be-closed

spinnakerbot avatar Jun 06 '24 09:06 spinnakerbot

This issue is tagged as 'stale' and hasn't been updated in 45 days, so we are tagging it as 'to-be-closed'. It will be closed in 45 days unless updates are made. If you want to remove this label, comment:

@spinnakerbot remove-label to-be-closed

spinnakerbot avatar Jul 21 '24 12:07 spinnakerbot

Just checking - seems like this issue was resolved in v1.31 ? We're encountering something similar on v1.30.1.

dcchambers avatar Aug 20 '24 17:08 dcchambers

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

spinnakerbot avatar Oct 04 '24 18:10 spinnakerbot

This issue is tagged as 'stale' and hasn't been updated in 45 days, so we are tagging it as 'to-be-closed'. It will be closed in 45 days unless updates are made. If you want to remove this label, comment:

@spinnakerbot remove-label to-be-closed

spinnakerbot avatar Nov 18 '24 18:11 spinnakerbot

This issue is tagged as 'stale' and hasn't been updated in 45 days, so we are tagging it as 'to-be-closed'. It will be closed in 45 days unless updates are made. If you want to remove this label, comment:

@spinnakerbot remove-label to-be-closed

spinnakerbot avatar Jan 03 '25 00:01 spinnakerbot

This issue is tagged as 'to-be-closed' and hasn't been updated in 45 days, so we are closing it. You can always reopen this issue if needed.

spinnakerbot avatar Feb 17 '25 00:02 spinnakerbot