@@ -657,29 +657,30 @@ func (d *Driver) Remove() error {
657657 return errors .Wrap (err , "could not delete server" )
658658 }
659659
660- err = d . removeEmptyServerPlacementGroup ( srv )
661- if err != nil {
662- log .Error (err ) // not a hard failure
660+ // failure to remove a placement group is not a hard error
661+ if softErr := d . removeEmptyServerPlacementGroup ( srv ); softErr != nil {
662+ log .Error (softErr )
663663 }
664664 }
665665 }
666666
667- // Failing to remove these is just a soft error
667+ // failure to remove a key is not ha hard error
668668 for i , id := range d .AdditionalKeyIDs {
669669 log .Infof (" -> Destroying additional key #%d (%d)" , i , id )
670- key , _ , err := d .getClient ().SSHKey .GetByID (context .Background (), id )
671- if err != nil {
672- log .Warnf (" -> -> could not retrieve key %v" , err )
670+ key , _ , softErr := d .getClient ().SSHKey .GetByID (context .Background (), id )
671+ if softErr != nil {
672+ log .Warnf (" -> -> could not retrieve key %v" , softErr )
673673 } else if key == nil {
674674 log .Warnf (" -> -> %d no longer exists" , id )
675675 }
676676
677- _ , err = d .getClient ().SSHKey .Delete (context .Background (), key )
678- if err != nil {
679- log .Warnf (" -> -> could not remove key: %v" , err )
677+ _ , softErr = d .getClient ().SSHKey .Delete (context .Background (), key )
678+ if softErr != nil {
679+ log .Warnf (" -> -> could not remove key: %v" , softErr )
680680 }
681681 }
682682
683+ // failure to remove a server-specific key is a hard error
683684 if ! d .IsExistingKey && d .KeyID != 0 {
684685 key , err := d .getKey ()
685686 if err != nil {
@@ -953,16 +954,16 @@ func (d *Driver) makePlacementGroup(name string, labels map[string]string) (*hcl
953954 d .dangling = append (d .dangling , func () {
954955 _ , err := d .getClient ().PlacementGroup .Delete (context .Background (), grp .PlacementGroup )
955956 if err != nil {
956- log .Error ( fmt . Errorf ("could not delete placement group: %w " , err ) )
957+ log .Errorf ("could not delete placement group: %v " , err )
957958 }
958959 })
959960 }
960961
961962 if err != nil {
962- err = fmt .Errorf ("could not create placement group: %w" , err )
963+ return nil , fmt .Errorf ("could not create placement group: %w" , err )
963964 }
964965
965- return grp .PlacementGroup , err
966+ return grp .PlacementGroup , nil
966967}
967968
968969func (d * Driver ) getPlacementGroup () (* hcloud.PlacementGroup , error ) {
@@ -1006,9 +1007,9 @@ func (d *Driver) removeEmptyServerPlacementGroup(srv *hcloud.Server) error {
10061007 if auto , exists := pg .Labels [d .labelName (labelAutoCreated )]; exists && auto == "true" {
10071008 _ , err := d .getClient ().PlacementGroup .Delete (context .Background (), pg )
10081009 if err != nil {
1009- err = fmt .Errorf ("could not remove placement group: %w" , err )
1010+ return fmt .Errorf ("could not remove placement group: %w" , err )
10101011 }
1011- return err
1012+ return nil
10121013 } else {
10131014 log .Debugf ("group not auto-created, ignoring: %v" , pg )
10141015 return nil
0 commit comments