-
Notifications
You must be signed in to change notification settings - Fork 231
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
porch: Added renderstatus to packagerevisionresources update api #3522
Conversation
/cc @ChristopherFry |
12677e0
to
9619676
Compare
20a00cf
to
eb83914
Compare
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.
Looking good ... I vote to merge and iterate :-)
.gitignore
Outdated
@@ -20,6 +20,7 @@ kpt/kpt | |||
*.exe | |||
*.gif | |||
bin/ | |||
porch/cmd/porch/__debug_bin |
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.
I don't love this (I think I'd prefer a wildcard), but I guess it saves us from committing it by mistake :-)
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.
Found the wildcard **
matches any subdirectories.
Spec PackageRevisionResourcesSpec `json:"spec,omitempty"` | ||
// Status PackageRevisionResourcesStatuc `json:"status,omitempty"` | ||
Spec PackageRevisionResourcesSpec `json:"spec,omitempty"` | ||
Status PackageRevisionResourcesStatus `json:"status,omitempty"` |
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.
I'm not sure which which kind we should expose this on. I'm happy for it to start here, though my guess is that PackageRevision is the more likely long-term home.
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.
Yes. PackageRevision is the ultimate home.
// on a package resources. | ||
type RenderStatus struct { | ||
Result fnresult.ResultList `json:"result,omitempty"` | ||
Err string `json:"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.
Nit: json:"error"
I suggest
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.
Done.
applied, task, err := m.Apply(ctx, baseResources) | ||
updatedResources, taskResult, task, err := m.Apply(ctx, baseResources) | ||
if taskResult != nil && taskResult.Type == api.TaskTypeEval { | ||
renderStatus = taskResult.RenderStatus |
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.
Does this mean we only capture the last eval
(i.e. the last function?)
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.
Yes.
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.
But is the goal that it should contain the output/errors from every function in the pipeline? Or do we abort the run when a function return an error?
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.
We abort the run when function returns error and if the last applied mutation was render
, then we also return the renderStatus.
We can definitely extend it for all the mutations over time.
porch/pkg/engine/init.go
Outdated
} | ||
|
||
return result, m.task, nil | ||
return result, nil, m.task, nil |
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.
Nit: four retvals is likely where I start to think about a struct
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.
along these lines, perhaps there could be a struct that contains both Task
and its TaskResult
?
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.
Now returning TaskResult
that contains *Task
. Thanks.
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, small question above
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.
I agree with the merge and iterate approach, but we should be careful with the API. Probably easier to make changes in the types from the Aggregated APIserver than CRDs though.
Could we add a test of this to make sure we don't accidentally break it?
porch/pkg/engine/engine.go
Outdated
// and is returned in packageresourceresources API's status field. We continue with | ||
// saving the non-rendered resources to avoid losing user's changes. | ||
// and supress this err. | ||
err = nil |
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.
Do we need this block? If we don't use the err
variable for anything, can't we just replace it with _
in the call to applyResourceMutations
?
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.
Good suggestion. Done. Moved the comment above it.
// PackageRevisionResourcesStatus represents state of the rendered package resources. | ||
type PackageRevisionResourcesStatus struct { | ||
// RenderStatus contains the result of rendering the package resources. | ||
RenderStatus RenderStatus `json:"renderStatus,omitempty"` |
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.
So this only contains the result after a push right? We don't actually store the information anywhere, so a subsequent get
will not contain the error? I would expect that he results from the latest run would be returned on every get
. Similar to the previous comment, I would expect this to be on the PackageRevision
rather than the PackageRevisionResources
type.
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.
subsequent get
will not contain the error. I started with this API because this is the API that get's called when user edits a package and that's the place renderStatus is most useful. And I agree that renderStatus
should be added to packagerevision
's status and should also be persisted so that we get it on every get
. And that can be done as a follow up incrementally.
applied, task, err := m.Apply(ctx, baseResources) | ||
updatedResources, taskResult, task, err := m.Apply(ctx, baseResources) | ||
if taskResult != nil && taskResult.Type == api.TaskTypeEval { | ||
renderStatus = taskResult.RenderStatus |
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.
But is the goal that it should contain the output/errors from every function in the pipeline? Or do we abort the run when a function return an error?
21c52aa
to
d424b55
Compare
d424b55
to
c802d2f
Compare
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.
Thanks for the feedback everyone. I have addressed all the feedback that I was planning to address in current cycle. There is definitely more follow ups but I think this is a reasonable checkpoint to get merged.
I enhanced the existing |
This PR exposes
kpt fn render
results in the porch API (packagerevisionresources
).Note: Since API no longer returns failure on render failures, the existing tests are failing, I am looking into it but the code is good for review. The change is split in two commits to make it easier to review.
/cc @mortent @justinsb @ChristopherFry
Some follow ups:
rpkg push
should display renderstatus