-
Notifications
You must be signed in to change notification settings - Fork 807
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
Conversation
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 |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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
?
@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 |
There was a problem hiding this comment.
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.
e2bc704
to
33864c5
Compare
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>
33864c5
to
710bf4c
Compare
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 🚀 |
@Mergifyio backport release-1.30.x release-1.31.x release-1.32.x |
✅ Backports have been created
|
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)
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)
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)
…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>
…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>
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
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
byviewing 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