Skip to content

Commit

Permalink
Fixing nil pointer deref on Scrapli send config errors (#1723)
Browse files Browse the repository at this point in the history
  • Loading branch information
steiler authored Nov 15, 2023
1 parent 2184f2d commit fab4221
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions nodes/vr_sros/vr-sros.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,16 @@ func (s *vrSROS) applyPartialConfig(ctx context.Context, addr, platformName, use
// converting byte slice to newline delimited string slice
cfgs := strings.Split(string(configContent), "\n")

mr, err := d.SendConfigs(cfgs)
if err != nil || mr.Failed != nil {
return fmt.Errorf("failed to apply config; error: %+v %+v", err, mr.Failed)
}
// condfig snippets should not have commit command, so we need to commit manually
r, err := d.SendConfig("commit")
if err != nil || r.Failed != nil {
return fmt.Errorf("failed to commit config; error: %+v %+v", err, mr.Failed)
}
cfgs = append(cfgs, "commit", "/admin save")

r, err = d.SendCommand("/admin save")
if err != nil || r.Failed != nil {
return fmt.Errorf("failed to persist config; error: %+v %+v", err, mr.Failed)
mr, err := d.SendConfigs(cfgs)
if err != nil || (mr != nil && mr.Failed != nil) {
if mr != nil {
return fmt.Errorf("failed to apply config; error: %+v %+v", err, mr.Failed)
} else {
return fmt.Errorf("failed to apply config; error: %+v", err)
}
}

return nil
Expand Down

0 comments on commit fab4221

Please sign in to comment.