Skip to content

Commit

Permalink
Merge pull request #2797 from ActiveState/DX-2251
Browse files Browse the repository at this point in the history
  • Loading branch information
Naatan authored Oct 10, 2023
2 parents 7a54123 + 02b32fe commit aa90168
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
19 changes: 19 additions & 0 deletions pkg/platform/runtime/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,25 @@ func New(target Targeter, eventHandler events.Handler, auth *authentication.Auth

// Update installs the runtime locally (or updates it if it's already partially installed)
func (s *Setup) Update() (rerr error) {
defer func() {
// Panics are serious, and reproducing them in the runtime package is HARD. To help with this we dump
// the build plan when a panic occurs so we have something more to go on.
if r := recover(); r != nil {
buildplan, err := s.store.BuildPlanRaw()
if err != nil {
logging.Error("Could not get raw buildplan: %s", err)
}
env, err := s.store.EnvDef()
if err != nil {
logging.Error("Could not get envdef: %s", err)
}
// We do a standard error log first here, as rollbar reports will pick up the most recent log lines.
// We can't put the buildplan in the multilog message as it'd be way too big a message for rollbar.
logging.Error("Panic during runtime update: %s, build plan:\n%s\n\nEnvDef:\n%#v", r, buildplan, env)
multilog.Critical("Panic during runtime update: %s", r)
panic(r) // We're just logging the panic while we have context, we're not meant to handle it here
}
}()
defer func() {
var ev events.Eventer = events.Success{}
if rerr != nil {
Expand Down
11 changes: 10 additions & 1 deletion pkg/platform/runtime/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,21 @@ func (s *Store) InstallPath() string {
return s.installPath
}

func (s *Store) BuildPlan() (*bpModel.Build, error) {
func (s *Store) BuildPlanRaw() ([]byte, error) {
data, err := fileutils.ReadFile(s.buildPlanFile())
if err != nil {
return nil, errs.Wrap(err, "Could not read build plan file.")
}

return data, nil
}

func (s *Store) BuildPlan() (*bpModel.Build, error) {
data, err := s.BuildPlanRaw()
if err != nil {
return nil, errs.Wrap(err, "Could not get build plan file.")
}

var buildPlan bpModel.Build
err = json.Unmarshal(data, &buildPlan)
if err != nil {
Expand Down

0 comments on commit aa90168

Please sign in to comment.