Skip to content

Commit

Permalink
rename notSafeToDetach to Attach
Browse files Browse the repository at this point in the history
  • Loading branch information
benpresnell authored Jul 19, 2022
1 parent de27a8d commit 925341c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
10 changes: 5 additions & 5 deletions core/orchestrator_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -4340,7 +4340,7 @@ func (o *TridentOrchestrator) addVolumePublication(

// UpdateVolumePublication updates a volume publication on the specified node with the provided value
func (o *TridentOrchestrator) UpdateVolumePublication(
ctx context.Context, volumeName, nodeName string, notSafeToDetach *bool,
ctx context.Context, volumeName, nodeName string, notSafeToAttach *bool,
) (err error) {
if o.bootstrapError != nil {
return o.bootstrapError
Expand All @@ -4352,19 +4352,19 @@ func (o *TridentOrchestrator) UpdateVolumePublication(
defer o.mutex.Unlock()
defer o.updateMetrics()

return o.updateVolumePublication(ctx, volumeName, nodeName, notSafeToDetach)
return o.updateVolumePublication(ctx, volumeName, nodeName, notSafeToAttach)
}

func (o *TridentOrchestrator) updateVolumePublication(
ctx context.Context, volumeName, nodeName string, notSafeToDetach *bool,
ctx context.Context, volumeName, nodeName string, notSafeToAttach *bool,
) error {
vPub, err := o.getVolumePublication(volumeName, nodeName)
if err != nil {
return err
}

if notSafeToDetach != nil {
vPub.NotSafeToDetach = *notSafeToDetach
if notSafeToAttach != nil {
vPub.NotSafeToAttach = *notSafeToAttach
}

if err := o.unpublishVolume(ctx, volumeName, nodeName); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions core/orchestrator_core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,7 @@ func TestUpdateVolumePublication(t *testing.T) {
VolumeName: vol1,
ReadOnly: true,
AccessMode: 1,
NotSafeToDetach: true,
NotSafeToAttach: true,
}

fakeName2 := utils.GenerateVolumePublishName(vol2, node2)
Expand All @@ -2782,7 +2782,7 @@ func TestUpdateVolumePublication(t *testing.T) {
VolumeName: vol2,
ReadOnly: true,
AccessMode: 1,
NotSafeToDetach: false,
NotSafeToAttach: false,
}

fakeName3 := utils.GenerateVolumePublishName(vol3, node3)
Expand All @@ -2792,7 +2792,7 @@ func TestUpdateVolumePublication(t *testing.T) {
VolumeName: vol3,
ReadOnly: true,
AccessMode: 1,
NotSafeToDetach: false,
NotSafeToAttach: false,
}

pubs := map[string]*utils.VolumePublication{
Expand Down Expand Up @@ -2839,7 +2839,7 @@ func TestUpdateVolumePublication(t *testing.T) {
assert.Nil(t, err, "update volume publication did not return an error")
aPub, err := orchestrator.getVolumePublication(arg.Vol, arg.Node)
assert.Nil(t, err, "get volume publication error was not nil")
assert.Equal(t, arg.Expected, aPub.NotSafeToDetach, "value of updated field did not match the desired value")
assert.Equal(t, arg.Expected, aPub.NotSafeToAttach, "value of updated field did not match the desired value")
err = orchestrator.deleteVolumePublication(context.Background(), arg.Vol, arg.Node)
assert.Nil(t, err, "delete volume publication did not return an error")
})
Expand Down
2 changes: 1 addition & 1 deletion core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type Orchestrator interface {
PeriodicallyReconcileNodeAccessOnBackends()

AddVolumePublication(ctx context.Context, vp *utils.VolumePublication) error
UpdateVolumePublication(ctx context.Context, nodeName, volumeName string, notSafeToDetach *bool) error
UpdateVolumePublication(ctx context.Context, nodeName, volumeName string, notSafeToAttach *bool) error
GetVolumePublication(ctx context.Context, volumeName, nodeName string) (*utils.VolumePublication, error)
ListVolumePublications(ctx context.Context) ([]*utils.VolumePublicationExternal, error)
ListVolumePublicationsForVolume(
Expand Down
4 changes: 2 additions & 2 deletions frontend/rest/controller_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,8 @@ func UpdateVolumePublication(w http.ResponseWriter, r *http.Request) {
response := &VolumePublicationsResponse{}
UpdateGeneric(w, r, response,
func(vars map[string]string, _ []byte) int {
notSafeToDetach := vars["notSafeToDetach"] == "true"
err := orchestrator.UpdateVolumePublication(r.Context(), vars["volume"], vars["node"], &notSafeToDetach)
notSafeToAttach := vars["notSafeToAttach"] == "true"
err := orchestrator.UpdateVolumePublication(r.Context(), vars["volume"], vars["node"], &notSafeToAttach)
if err != nil {
response.Error = err.Error()
}
Expand Down
6 changes: 3 additions & 3 deletions utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type VolumePublication struct {
// The access mode values are defined by CSI
// See https://github.com/container-storage-interface/spec/blob/release-1.5/lib/go/csi/csi.pb.go#L135
AccessMode int32 `json:"accessMode"`
NotSafeToDetach bool `json:"notSafeToDetach"`
NotSafeToAttach bool `json:"notSafeToAttach"`
}

type VolumePublicationExternal struct {
Expand All @@ -86,7 +86,7 @@ type VolumePublicationExternal struct {
// The access mode values are defined by CSI
// See https://github.com/container-storage-interface/spec/blob/release-1.5/lib/go/csi/csi.pb.go#L135
AccessMode int32 `json:"accessMode"`
NotSafeToDetach bool `json:"notSafeToDetach"`
NotSafeToAttach bool `json:"notSafeToAttach"`
}

func (v *VolumePublication) ConstructExternal() *VolumePublicationExternal {
Expand All @@ -96,7 +96,7 @@ func (v *VolumePublication) ConstructExternal() *VolumePublicationExternal {
VolumeName: v.VolumeName,
ReadOnly: v.ReadOnly,
AccessMode: v.AccessMode,
NotSafeToDetach: v.NotSafeToDetach,
NotSafeToAttach: v.NotSafeToAttach,
}
}

Expand Down

0 comments on commit 925341c

Please sign in to comment.