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

fix(artifacts): Expected Artifacts should be trigger specific #4322

Merged
merged 4 commits into from
Nov 7, 2022

Conversation

jervi
Copy link
Contributor

@jervi jervi commented Nov 3, 2022

When setting up multiple triggers with different expected artifacts, triggering the pipeline fails if any defined expected artifact is missing, even if it is defined on another trigger. This fix filters the list of expected artifacts to make sure only the artifacts that are relevant for the current trigger is evaluated.

Example:

If you create two triggers like this, with different artifact constraints:
image

This would result in a pipeline config like this:

{
  "expectedArtifacts": [
    {
      "defaultArtifact": {
        "customKind": true,
        "id": "3c55a698-aa57-4f38-9326-a99511b8e7b0"
      },
      "displayName": "my-artifact",
      "id": "89709fb4-4ad1-4267-ba14-77befa93b58d",
      "matchArtifact": {
        "artifactAccount": "custom-artifact",
        "customKind": true,
        "id": "dfa2e113-eb4f-4d20-adec-db0756ec4f44",
        "name": "s3://my-bucket/myfile",
        "type": "s3/object"
      },
      "useDefaultArtifact": false,
      "usePriorArtifact": false
    },
    {
      "defaultArtifact": {
        "customKind": true,
        "id": "26023c36-8257-4adb-a764-485e5ddb8462"
      },
      "displayName": "another-artifact",
      "id": "5d35f6ed-1336-4bc6-8c46-2c18df238163",
      "matchArtifact": {
        "artifactAccount": "custom-artifact",
        "customKind": true,
        "id": "0ea9e8b6-94e1-4df6-9004-88efade8cf67",
        "type": "custom/object"
      },
      "useDefaultArtifact": false,
      "usePriorArtifact": false
    }
  ],
  "keepWaitingPipelines": false,
  "limitConcurrent": true,
  "schema": "1",
  "spelEvaluator": "v4",
  "stages": [ ... ],
  "triggers": [
    {
      "enabled": true,
      "expectedArtifactIds": [
        "89709fb4-4ad1-4267-ba14-77befa93b58d"
      ],
      "pubsubSystem": "amazon",
      "subscriptionName": "pulse-routing-configurations-dev",
      "type": "pubsub"
    },
    {
      "application": "jervi",
      "enabled": true,
      "expectedArtifactIds": [
        "5d35f6ed-1336-4bc6-8c46-2c18df238163"
      ],
      "pipeline": "cee145ad-21b5-42a8-9894-b34d3f1cfed8",
      "status": [
        "successful"
      ],
      "type": "pipeline"
    }
  ]
}

Before the fix, the defined triggers would not trigger unless all the defined artifacts were present. Here I have tried to start the pipeline using the pipeline trigger, but it won't start because it can't find the artifact that is defined for the pubsub trigger:
image

As you can see in the original PR for this feature, it actually used to filter the expected artifacts correctly.

@spinnakerbot
Copy link
Contributor

The following commits need their title changed:

  • d576f48: bug(artifacts): Expected Artifacts are trigger specific

Please format your commit title into the form:

<type>(<scope>): <subject>, e.g. fix(kubernetes): address NPE in status check

This allows us to easily generate changelogs & determine semantic version numbers when cutting releases. You can read more about commit conventions here.

When setting up multiple triggers with different expected artifacts, triggering the pipeline fails if _any_ defined expected artifact is missing, even if it is defined on another trigger. This fix filters the list of expected artifacts to make sure only the artifacts that are relevant for the current trigger is evaluated.
@jervi jervi force-pushed the trigger_specific_expected_artifacts branch from d576f48 to 4d166ca Compare November 3, 2022 14:22
@jervi jervi changed the title bug(artifacts): Expected Artifacts should be trigger specific fix(artifacts): Expected Artifacts should be trigger specific Nov 3, 2022
@dbyron-sf
Copy link
Contributor

There's a test a failure...but also, I could use some help making more sense of this. It feels right, but some examples would help. Like, what does pipeline json with multiple triggers look like? From what I can tell of the tests in this PR, I see one with one trigger, and one with none.

@jervi
Copy link
Contributor Author

jervi commented Nov 3, 2022

Yeah, sorry, I was fixing the tests but had to run to pick up kids. I'll get them fixed ASAP.
I'll add some examples as well (I was already working on it).

Signed-off-by: Jørgen Jervidalo <jorgen.jervidalo@schibsted.com>
…some tests that failed

Signed-off-by: Jørgen Jervidalo <jorgen.jervidalo@schibsted.com>
@jervi
Copy link
Contributor Author

jervi commented Nov 3, 2022

More test cases added, and I have updated the PR description with more information.

This last commit also includes a fix that is specific to Pipeline triggers only - this trigger is using another code path than the other triggers (DependentPipelineStarter vs. OperationsController) which didn't set the expectedArtifactIds field at all. The fix will figure out the correct trigger from the triggers array in the pipeline config, and copy it to the trigger field in the execution context.

Signed-off-by: Jørgen Jervidalo <jorgen.jervidalo@schibsted.com>
@dbyron-sf
Copy link
Contributor

This looks good. I'm a little concerned about people who may be depending on the current behavior -- that a pipeline only triggers when all of its expected artifacts are present. What do you think about putting the new behavior behind a feature flag?

@jervi
Copy link
Contributor Author

jervi commented Nov 4, 2022

To be honest, I think they then depend on a bug and needs to update their pipelines instead. The fix is easy; just add the expected artifact constraints to all triggers.
Since this PR just reverts the Spinnaker behavior to the earlier, correct state, I don't think it should be put behind a feature flag.

@dbyron-sf
Copy link
Contributor

OK, fair enough. Could you add a release note for this at least? https://github.com/spinnaker/spinnaker.io/blob/master/content/en/docs/releases/next-release-preview/index.md

@dbyron-sf
Copy link
Contributor

Thanks for the release note!

@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Nov 7, 2022
@mergify mergify bot added the auto merged Merged automatically by a bot label Nov 7, 2022
@mergify mergify bot merged commit 17f9633 into spinnaker:master Nov 7, 2022
dbyron-sf added a commit to spinnaker/spinnaker.io that referenced this pull request Nov 7, 2022
* Add release docs for artifact constraints bugfix

See spinnaker/orca#4322

* Update content/en/docs/releases/next-release-preview/index.md

Co-authored-by: David Byron <82477955+dbyron-sf@users.noreply.github.com>

Co-authored-by: David Byron <82477955+dbyron-sf@users.noreply.github.com>
@jervi jervi deleted the trigger_specific_expected_artifacts branch November 9, 2022 09:36
jervi added a commit to jervi/orca that referenced this pull request Feb 17, 2023
It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This PR will fix this by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`.
jervi added a commit to jervi/orca that referenced this pull request Feb 21, 2023
It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This PR will fix this by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`, and it will bind artifacts defined inline in stages (so that you can match artifacts using regex and not only SpEL).
jervi added a commit to jervi/orca that referenced this pull request Feb 21, 2023
It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This PR will fix this by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`, and it will bind artifacts defined inline in stages (so that you can match artifacts using regex and not only SpEL).
jervi added a commit to jervi/orca that referenced this pull request Feb 21, 2023
It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains tests that demonstrate the issue.
jervi added a commit to jervi/orca that referenced this pull request Feb 21, 2023
It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains implementation code to fix the tests added in the previous commit. It will fix the issue by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`, and it will bind artifacts defined inline in stages (so that you can match artifacts using regex and not only SpEL).
mergify bot pushed a commit that referenced this pull request Feb 23, 2023
)

* test(artifacts): Be more lenient when filtering expected artifacts

It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in #4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains tests that demonstrate the issue.

* fix(artifacts): Be more lenient when filtering expected artifacts

It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in #4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains implementation code to fix the tests added in the previous commit. It will fix the issue by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`, and it will bind artifacts defined inline in stages (so that you can match artifacts using regex and not only SpEL).
yugaa22 pushed a commit to OpsMx/orca-oes that referenced this pull request Jun 26, 2023
…innaker#4397)

* test(artifacts): Be more lenient when filtering expected artifacts

It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains tests that demonstrate the issue.

* fix(artifacts): Be more lenient when filtering expected artifacts

It is currently hard/impossible to resolve artifacts in pipelines that doesn't have any triggers defined by themselves, and are triggered by a pipeline stage in another pipeline. Previously it was possible to get it to work by editing the json of the pipeline or in the UI by adding artifacts in a temp trigger and then removing it (this would keep the expected artifacts around).
When I introduced trigger specific artifact constraints in spinnaker#4322, I made it a lot harder (if not impossible) to do this because no triggers are used and thus all expected artifacts are filtered out.

This commit contains implementation code to fix the tests added in the previous commit. It will fix the issue by copying expected artifacts from the parent execution (only if triggered by a pipeline stage), thus avoiding the whole situation altogether. It will also not filter away any expected artifacts where `useDefaultArtifact` or `usePriorArtifact` is set to `true`, and it will bind artifacts defined inline in stages (so that you can match artifacts using regex and not only SpEL).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for merge target-release/1.30
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants