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

Record run when a bundle action generates outputs #1980

Closed
carolynvs opened this issue Mar 24, 2022 · 2 comments · Fixed by #2291
Closed

Record run when a bundle action generates outputs #1980

carolynvs opened this issue Mar 24, 2022 · 2 comments · Fixed by #2291
Assignees
Labels
gap We missed a spot help wanted Good for someone who has contributed before
Milestone

Comments

@carolynvs
Copy link
Member

Right now the logic for when porter should record a bundle run is:

  • the bundle action is not stateless
  • the bundle action modifies bundle resources

It is possible for a stateless action to create outputs though, and unless modifies is artificially set to true, the outputs would not be captured by Porter.

A couple things come to mind here:

  1. modifies and stateless are CNAB concepts that Porter has exposed without any user experience improvements. I feel like these are concepts that maybe the runtime needs to know but perhaps Porter can help map that better to how a bundle author thinks about what the action does.
  2. If we don't tweak how custom actions are defined, we should at least change the runtime to record when a bundle output is created.

Is there a better way to represent the concepts of stateless and modifies in a way that works for us?

  • stateless - does this require the bundle to already be installed? Could be renamed to "allowBeforeInstall".
  • modifies - does this change any resources managed by the bundle? We can use that eventually to prevent concurrent runs that modify resources. Users can use this to figure out if it's safe to run an action. Could be renamed to "modifiesBundleResources"

A couple examples of how these two can combine to make real-world actions:

  • preflight (stateless: true, modifies: true) - Run a series of checks against an environment before installing. If there are configuration problems identified, correct them.
  • dry-run (stateless: true, modifies: false) - Print the actions the bundle would take but don't change anything. Could be run either before or after the bundle is installed.
  • status (stateless: false, modifies: false) - Print the status of the bundle resources.
@carolynvs carolynvs added the suggestion Idea for maintainers to consider. Do not take this issue until triaged. label Mar 24, 2022
@carolynvs carolynvs added this to the 1.0 milestone Mar 24, 2022
@carolynvs carolynvs added gap We missed a spot and removed suggestion Idea for maintainers to consider. Do not take this issue until triaged. labels Jun 23, 2022
@carolynvs
Copy link
Member Author

carolynvs commented Jun 23, 2022

After discussing further, we realized that the problem is in the lack of documentation around those two fields. The names work just fine.

So what we need to do is fix the bug: When a custom action generates an output, it should always persist an installation/run/result/outputs to the database.

Here is the function that needs to be updated:

func (r Run) ShouldRecord() bool {
// Assume all actions modify bundle resources, and should be recorded.
stateful := true
modifies := true
if action, err := r.Bundle.GetAction(r.Action); err == nil {
modifies = action.Modifies
stateful = !action.Stateless
}
return modifies || stateful
}

@carolynvs carolynvs added the help wanted Good for someone who has contributed before label Jun 23, 2022
@VinozzZ VinozzZ self-assigned this Aug 8, 2022
@github-actions
Copy link

Closed by #2291.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gap We missed a spot help wanted Good for someone who has contributed before
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants