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): Parent and child pipeline artifact resolution #4575

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

xibz
Copy link
Contributor

@xibz xibz commented Oct 26, 2023

This fix allows us to revert #4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline should be able to
resolve incoming artifacts properly. Right now that does not happen
because expectedArtifactIds is needed in the trigger section,
otherwise no resolution will occur.

This change fixes the parent payload to include expectedArtifactIds by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

@nemesisOsorio

Also, we can probably still utilize some of #4570 and still revert the changes that were introduced due to not properly handling the root cause

Comment on lines +143 to +156
expectedArtifactIds.addAll(pipelineConfig.get("expectedArtifacts", []).collectMany {
def expectedArtifact = objectMapper.convertValue(it, ExpectedArtifact)
return trigger.artifacts.findAll {
// The idea here is we are only interested in matching against incoming
// artifacts. So if the expected artifact does not match on any incoming
// artifact, we will simply not add the expected artifact ID to the
// array. This is very similar to how echo works.
def artifact = objectMapper.convertValue(it, Artifact)
return expectedArtifact.matches(artifact)
}.collect {
return expectedArtifact.id
}
} as String[])
trigger.expectedArtifactIds = expectedArtifactIds
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to wrap this code under the condition when the trigger is from a pipeline stage? Maybe add it under line 130 where it checks if (parentPipelineStageId != null) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

After reviewing this, we shouldn't move this code because if an expected artifact is added to the pipeline json without an artifact constraint in a trigger, it will not be able to resolve it.

Copy link
Contributor

@sergio-quintero sergio-quintero left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@nemesisOsorio nemesisOsorio left a comment

Choose a reason for hiding this comment

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

can we please backport this all the way down to 1.30?

@nemesisOsorio
Copy link
Member

@jervi can you please take a look?

@@ -133,6 +136,25 @@ class DependentPipelineStarter implements ApplicationContextAware {
// This is required for template source with jinja expressions
trigger.artifacts = pipelineConfig.receivedArtifacts

// expectedArtifacts for triggers are defined at the top level of the
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to follow this, I started above with:

    def expectedArtifactIds = pipelineConfig.get("triggers", []).findAll {
      it.type == "pipeline" && it.pipeline == parentPipeline.pipelineConfigId
    } collectMany {
      it.expectedArtifactIds ?: []
    }

I'd love some help connecting what that block does to here.

@xibz xibz force-pushed the more-artifact-resolution branch 2 times, most recently from e2bc704 to 33864c5 Compare October 30, 2023 20:31
@xibz xibz changed the title fix(artifacts): Parent and child pipeline artifact resolution (#1495) fix(artifacts): Parent and child pipeline artifact resolution Oct 30, 2023
This fix allows us to revert spinnaker#4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
@xibz xibz force-pushed the more-artifact-resolution branch from 33864c5 to 710bf4c Compare October 30, 2023 20:54
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Oct 30, 2023
@mergify mergify bot added the auto merged Merged automatically by a bot label Oct 30, 2023
@mergify mergify bot merged commit 2e3c5f0 into spinnaker:master Oct 30, 2023
4 checks passed
@jervi
Copy link
Contributor

jervi commented Oct 31, 2023

Sorry, I'm late to the game! I think this looks good as part of a much overdue refresh of the artifact handling in Spinnaker. Thank you for spending time on this, @xibz and @nemesisOsorio 🚀

@link108 link108 added the backport-candidate Add to PRs to designate release branch patch candidates. label Oct 31, 2023
@link108
Copy link
Member

link108 commented Oct 31, 2023

@Mergifyio backport release-1.30.x release-1.31.x release-1.32.x

Copy link
Contributor

mergify bot commented Oct 31, 2023

backport release-1.30.x release-1.31.x release-1.32.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 31, 2023
This fix allows us to revert #4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
(cherry picked from commit 2e3c5f0)
mergify bot pushed a commit that referenced this pull request Oct 31, 2023
This fix allows us to revert #4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
(cherry picked from commit 2e3c5f0)
mergify bot pushed a commit that referenced this pull request Oct 31, 2023
This fix allows us to revert #4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
(cherry picked from commit 2e3c5f0)
Pranav-b-7 pushed a commit to Pranav-b-7/orca that referenced this pull request Nov 2, 2023
…ker#4575)

This fix allows us to revert spinnaker#4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
Pranav-b-7 pushed a commit to Pranav-b-7/orca that referenced this pull request Nov 2, 2023
…ker#4575)

This fix allows us to revert spinnaker#4397
since that makes retrieving bound artifacts actually more strict for
most use cases. So this commit addresses the root cause that that PR was
trying to implement.

When a parent pipeline triggers a child pipeline, the child pipeline
should be able to resolve incoming artifacts properly. Right now that
does not happen because `expectedArtifactIds` is needed in the trigger
section, otherwise no resolution will occur.

This change fixes the parent payload to include `expectedArtifactIds` by
viewing the child pipeline's top level expected artifacts and finding
the intersection between expected artifacts and artifacts to be sent.
With that intersection we can grab the expected artifact ids and
properly set the the necessary field to allow for child pipelines to
ingest the artifact.

Signed-off-by: benjamin-j-powell <bjp@apple.com>
Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
link108 pushed a commit that referenced this pull request Nov 6, 2023
#4575) (#4583)

Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
Co-authored-by: xibz <impactbchang@gmail.com>
fix allows us to revert #4397
link108 pushed a commit that referenced this pull request Nov 6, 2023
#4575) (#4582)

Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
Co-authored-by: xibz <impactbchang@gmail.com>
fix allows us to revert #4397
link108 pushed a commit that referenced this pull request Nov 6, 2023
#4575) (#4581)

Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
Co-authored-by: xibz <impactbchang@gmail.com>
fix allows us to revert #4397
nemesisOsorio pushed a commit to OpsMx/orca-oes that referenced this pull request May 20, 2024
spinnaker#4575) (spinnaker#4581)

Co-authored-by: Benevolent Benjamin Powell <benjamin_j_powell@apple.com>
Co-authored-by: xibz <impactbchang@gmail.com>
fix allows us to revert spinnaker#4397
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 backport-candidate Add to PRs to designate release branch patch candidates. ready to merge Approved and ready for merge target-release/1.33
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants