-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add controller flag to turn off built-in resolution #4168
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,11 +132,21 @@ type Reconciler struct { | |
cloudEventClient cloudevent.CEClient | ||
metrics *pipelinerunmetrics.Recorder | ||
pvcHandler volumeclaim.PvcHandler | ||
|
||
// disableResolution is a flag to the reconciler that it should | ||
// not be performing resolution of pipelineRefs. | ||
// TODO(sbwsg): Once we've agreed on a way forward for TEP-0060 | ||
// this can be removed in favor of whatever that chosen solution | ||
// is. | ||
disableResolution bool | ||
} | ||
|
||
var ( | ||
// Check that our Reconciler implements pipelinerunreconciler.Interface | ||
_ pipelinerunreconciler.Interface = (*Reconciler)(nil) | ||
|
||
// Indicates pipelinerun resolution hasn't occurred yet. | ||
errResourceNotResolved = fmt.Errorf("pipeline ref has not been resolved") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: 🤔 I thought this was something golangci-lint would complain about, sorry I didn't notice before. Also cc @n3wscott in case there's something useful in the controller framework we can use here to simplify any of the logic. None of the things that come to mind for me seem quite right. |
||
) | ||
|
||
// ReconcileKind compares the actual state with the desired, and attempts to | ||
|
@@ -232,6 +242,13 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, pr *v1beta1.PipelineRun) | |
logger.Errorf("Reconcile error: %v", err.Error()) | ||
} | ||
|
||
if c.disableResolution && err == errResourceNotResolved { | ||
// This is not an error: an out-of-band process can | ||
// still resolve the PipelineRun, at which point | ||
// reconciliation can continue as normal. | ||
err = nil | ||
} | ||
|
||
if err = c.finishReconcileUpdateEmitEvents(ctx, pr, before, err); err != nil { | ||
return err | ||
} | ||
|
@@ -336,6 +353,10 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1beta1.PipelineRun, get | |
return nil | ||
} | ||
|
||
if c.disableResolution && pr.Status.PipelineSpec == nil { | ||
return errResourceNotResolved | ||
} | ||
|
||
pipelineMeta, pipelineSpec, err := resources.GetPipelineData(ctx, pr, getPipelineFunc) | ||
if err != nil { | ||
logger.Errorf("Failed to determine Pipeline spec to use for pipelinerun %s: %v", pr.Name, err) | ||
|
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.
Seems inconsistent with
pipeline.Images
for these to specialize between the two controllers, since the pipeline run controller only uses a subset of thepipeline.Images
struct, but the same "options" struct is passed to both controllers.My personal preference would be to rename/generalize the
Images
struct to reflect a more complete set of options, but this seems nitpicky and I have some other changes I've been thinking about to some of this handling, so perhaps we land this and I can try to find something we're happy with.thanks for the change. 👍