Skip to content

Commit a7be1bf

Browse files
authored
fix: fall back to TCP if on a read-only disk (#1072)
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it In a read-only disk ( like a scratch container ) the flow to detect connection fails because it can't create a folder. In that case it should fall back to TCP. #### Which issue(s) this PR fixes <!-- Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. --> --------- Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
1 parent 7f181dc commit a7be1bf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

bindings/go/plugin/manager/manager.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (pm *PluginManager) addPlugin(ctx context.Context, ocmConfig *genericv1.Con
234234
// Create a command that can then be managed.
235235
pluginCmd := exec.CommandContext(ctx, cleanPath(plugin.Path), "--config", string(serialized)) //nolint:gosec // G204 does not apply
236236
pluginCmd.Cancel = func() error {
237-
slog.Info("killing plugin process because the parent context is cancelled", "id", plugin.ID)
237+
slog.InfoContext(ctx, "killing plugin process because the parent context is cancelled", "id", plugin.ID)
238238
return pluginCmd.Process.Kill()
239239
}
240240

@@ -305,10 +305,13 @@ func (pm *PluginManager) addPlugin(ctx context.Context, ocmConfig *genericv1.Con
305305
}
306306

307307
func determineConnectionType(ctx context.Context) (mtypes.ConnectionType, error) {
308+
// if we can't create a temp folder ( for example we are in a scratch container ) we default to TCP
308309
tmp, err := os.MkdirTemp("", "")
309310
if err != nil {
310-
return "", fmt.Errorf("failed to create temporary directory: %w", err)
311+
slog.DebugContext(ctx, "failed to create temporary folder, falling back to TCP connection", "err", err.Error())
312+
return mtypes.TCP, nil
311313
}
314+
312315
defer func() {
313316
_ = os.RemoveAll(tmp)
314317
}()

0 commit comments

Comments
 (0)