Jira (BOLT-1366) Overhaul user experience handling plan errors

2 views
Skip to first unread message

Reid Vandewiele (JIRA)

unread,
Jun 5, 2019, 7:59:03 PM6/5/19
to puppe...@googlegroups.com
Reid Vandewiele created an issue
 
Puppet Task Runner / Improvement BOLT-1366
Overhaul user experience handling plan errors
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2019/06/05 4:58 PM
Priority: Normal Normal
Reporter: Reid Vandewiele

It isn't possible today for a plan author to formally signal to callers that the plan failed (surfacing an error without requiring the caller to provide distinct (and not bound by convention) code paths for "ok" vs. "error". E.g.

$results = case ($plan_result = run_plan('mymodule::myplan',
  '_catch_errors' => true,
)) {
  Error:   { $plan_result.details['result_set'] }
  default: { $plan_result }
}

Ideally, a caller should be able to expect a consistent return type regardless of whether or not the plan failed; just like a caller can always expect an object of type ResultSet to be returned from run_task.

Allow for a moment that a plan always returns an object of type PlanResult. If this is true, we can generalize success/failure based on $pr.ok, just as ResultSet handling can be based on $rs.ok. If a PlanResult is not ok (it failed), we can generalize access to the error raised via e.g. $pr.error. The PlanResult object can define a standard interface to data returned by a plan, such as defining a .value method, and the index method (.[]) for easy access to returned data keys.

A caller could then simplify their code to e.g.

$result = run_plan('mymodule::myplan',
  _catch_errors => true,
)
 
run_task('mymodule::next_step, $result.value.ok_set)

OR

$result['summary']

OR

if !$result.ok {
  # handle it
}

...etc., depending on what the plan author chooses to return.

Being able to rely on the datatype returned by run_plan greatly simplifies how plan authors can call and deal with the results from running other plans.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages