Skip to content

Commit

Permalink
local volume: remove unix-domain-socket file after deleting replica p…
Browse files Browse the repository at this point in the history
…rocess

Longhorn 3957

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit committed Nov 25, 2022
1 parent 5b708c6 commit 976a206
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controller/replica_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"context"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -556,10 +557,15 @@ func (rc *ReplicaController) DeleteInstance(obj interface{}) error {
return err
}
defer c.Close()

if err := c.ProcessDelete(r.Name); err != nil && !types.ErrorIsNotFound(err) {
return err
}

if err := deleteUnixSocketFile(r.Spec.VolumeName); err != nil && !types.ErrorIsNotFound(err) {
log.Warnf("Failed to delete unix-domain-socket file for volume %v since %v", r.Spec.VolumeName, err)
}

// Directly remove the instance from the map. Best effort.
if im.Status.APIVersion == engineapi.IncompatibleInstanceManagerAPIVersion {
delete(im.Status.Instances, r.Name)
Expand All @@ -571,6 +577,10 @@ func (rc *ReplicaController) DeleteInstance(obj interface{}) error {
return nil
}

func deleteUnixSocketFile(volumeName string) error {
return os.RemoveAll(filepath.Join(types.UnixDomainSocketDirectoryOnHost, volumeName+filepath.Ext(".sock")))
}

func (rc *ReplicaController) deleteInstanceWithCLIAPIVersionOne(r *longhorn.Replica) (err error) {
isCLIAPIVersionOne := false
if r.Status.CurrentImage != "" {
Expand Down

0 comments on commit 976a206

Please sign in to comment.