Skip to content

Commit

Permalink
Revert "CSI: set plugin socket path on restore (#12149)"
Browse files Browse the repository at this point in the history
This reverts commit 1ffdda0.
  • Loading branch information
lgfa29 committed Apr 19, 2022
1 parent f4cbc81 commit b186c36
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions client/allocrunner/taskrunner/plugin_supervisor_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,12 @@ func (*csiPluginSupervisorHook) Name() string {
}

// Prestart is called before the task is started including after every
// restart (but not after restore). This requires that the mount paths
// for a plugin be idempotent, despite us not knowing the name of the
// plugin ahead of time. Because of this, we use the allocid_taskname
// as the unique identifier for a plugin on the filesystem.
// restart. This requires that the mount paths for a plugin be idempotent,
// despite us not knowing the name of the plugin ahead of time.
// Because of this, we use the allocid_taskname as the unique identifier for a
// plugin on the filesystem.
func (h *csiPluginSupervisorHook) Prestart(ctx context.Context,
req *interfaces.TaskPrestartRequest, resp *interfaces.TaskPrestartResponse) error {

// Create the mount directory that the container will access if it doesn't
// already exist. Default to only nomad user access.
if err := os.MkdirAll(h.mountPoint, 0700); err != nil && !os.IsExist(err) {
Expand All @@ -135,8 +134,6 @@ func (h *csiPluginSupervisorHook) Prestart(ctx context.Context,
Readonly: false,
}

h.setSocketHook()

switch h.caps.FSIsolation {
case drivers.FSIsolationNone:
// Plugin tasks with no filesystem isolation won't have the
Expand All @@ -160,29 +157,11 @@ func (h *csiPluginSupervisorHook) Prestart(ctx context.Context,
return nil
}

func (h *csiPluginSupervisorHook) setSocketHook() {

// TODO(tgross): https://github.com/hashicorp/nomad/issues/11786
// If we're already registered, we should be able to update the
// definition in the update hook

// For backwards compatibility, ensure that we don't overwrite the
// socketPath on client restart with existing plugin allocations.
pluginInfo, _ := h.runner.dynamicRegistry.PluginForAlloc(
string(h.task.CSIPluginConfig.Type), h.task.CSIPluginConfig.ID, h.alloc.ID)
if pluginInfo != nil && pluginInfo.ConnectionInfo.SocketPath != "" {
h.socketPath = pluginInfo.ConnectionInfo.SocketPath
return
}
h.socketPath = filepath.Join(h.socketMountPoint, structs.CSISocketName)
}

// Poststart is called after the task has started. Poststart is not
// called if the allocation is terminal.
//
// The context is cancelled if the task is killed.
func (h *csiPluginSupervisorHook) Poststart(_ context.Context, _ *interfaces.TaskPoststartRequest, _ *interfaces.TaskPoststartResponse) error {

// If we're already running the supervisor routine, then we don't need to try
// and restart it here as it only terminates on `Stop` hooks.
h.runningLock.Lock()
Expand All @@ -192,8 +171,6 @@ func (h *csiPluginSupervisorHook) Poststart(_ context.Context, _ *interfaces.Tas
}
h.runningLock.Unlock()

h.setSocketHook()

go h.ensureSupervisorLoop(h.shutdownCtx)
return nil
}
Expand Down

0 comments on commit b186c36

Please sign in to comment.