flyte icon indicating copy to clipboard operation
flyte copied to clipboard

[BUG] Container plugin coding issue results in panic

Open convexquad opened this issue 5 years ago • 4 comments

Describe the bug A user reported a failing task whose stack trace contained a panic (stack trace shown below). Going through the trace, the issue is a poorly coded series of conditional checks immediately preceeding https://github.com/flyteorg/flyteplugins/blob/v0.5.54/go/tasks/pluginmachinery/flytek8s/pod_helper.go#L269.

@katrogan at line https://github.com/flyteorg/flyteplugins/blob/v0.5.54/go/tasks/pluginmachinery/flytek8s/pod_helper.go#L264 you can assign containerState = c.LastTerminationState. Then line 268 will check if containerState.Terminated != nil, but then on line 269 you access c.State.Terminated.Reason. This flow never verifies that c.State.Terminated != nil.

Here is the stack trace capture on execution page:

Workflow[avfleetscenes:dev:flyte.workflows.fs1_scene_evaluation.AVEvaluationWorkflow] failed. RuntimeExecutionError: max number of system retry attempts [51/50] exhausted. Last known status message: failed at Node[n1]. RuntimeExecutionError: failed during plugin execution, caused by: failed to execute handle for plugin [container]: panic when executing a plugin [container]. Stack: [goroutine 846 [running]:
runtime/debug.Stack(0xc00103c448, 0x0, 0x0)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task.Handler.invokePlugin.func1.1(0xc0457bf8f8, 0x2864b70, 0xc074bf88a0, 0x286e258, 0xc05a7443c0, 0xc0457bf240, 0xc0457bf210)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/handler.go:348 +0xd8
panic(0x21424a0, 0x38128a0)
	/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/flytek8s.ConvertPodFailureToError(0xc0a5618b60, 0x6, 0xc0754e4e00, 0x4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/flyteorg/[email protected]/go/tasks/pluginmachinery/flytek8s/pod_helper.go:269 +0x27a
github.com/flyteorg/flyteplugins/go/tasks/plugins/k8s/container.Plugin.GetTaskPhase(0x2864b70, 0xc074bf8b70, 0x28732f0, 0xc0ac8629d8, 0x2893ba0, 0xc084390400, 0x0, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/flyteorg/[email protected]/go/tasks/plugins/k8s/container/container.go:48 +0x3c5
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/k8s.(*PluginManager).CheckResourcePhase(0xc0457bedb0, 0x2864b70, 0xc074bf8b70, 0x2887620, 0xc0848cdb80, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/k8s/plugin_manager.go:269 +0xce2
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/k8s.PluginManager.Handle(0x247f89e, 0x9, 0x2865820, 0x3871d98, 0x2831838, 0xc000600c00, 0x7fd188869908, 0xc000a2b880, 0x288f710, 0xc0010cd710, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/k8s/plugin_manager.go:321 +0x725
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task.Handler.invokePlugin.func1(0xc0457bf8f8, 0x2864b70, 0xc074bf88a0, 0x286e258, 0xc05a7443c0, 0xc0848cdb80, 0x0, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/handler.go:355 +0x1d0
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task.Handler.invokePlugin(0x282f128, 0xc000c665e8, 0x28343d0, 0xc00150d9e0, 0xc000fbe120, 0xc000fbe150, 0xc000fbe180, 0x286e258, 0xc05a7443c0, 0xc00000a1e0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/handler.go:357 +0xbf
github.com/flyteorg/flytepropeller/pkg/controller/nodes/task.Handler.Handle(0x282f128, 0xc000c665e8, 0x28343d0, 0xc00150d9e0, 0xc000fbe120, 0xc000fbe150, 0xc000fbe180, 0x286e258, 0xc05a7443c0, 0xc00000a1e0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/task/handler.go:537 +0x568
github.com/flyteorg/flytepropeller/pkg/controller/nodes/dynamic.dynamicNodeTaskNodeHandler.handleParentNode(0x28732a8, 0xc0015dc160, 0xc0005ede90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0005edeb0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/dynamic/handler.go:67 +0xdb
github.com/flyteorg/flytepropeller/pkg/controller/nodes/dynamic.dynamicNodeTaskNodeHandler.Handle(0x28732a8, 0xc0015dc160, 0xc0005ede90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0005edeb0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/dynamic/handler.go:216 +0x296
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).execute(0xc000c1e320, 0x2864b70, 0xc074bf82a0, 0x286e0d8, 0xc000c50000, 0xc080c0fa40, 0x28947f0, 0xc084619e10, 0x0, 0x0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:232 +0x19b
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).handleQueuedOrRunningNode(0xc000c1e320, 0x2864b70, 0xc074bf82a0, 0xc080c0fa40, 0x286e0d8, 0xc000c50000, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:361 +0x293
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).handleNode(0xc000c1e320, 0x2864b70, 0xc074bf82a0, 0x282ede0, 0xc04daf6a00, 0xc080c0fa40, 0x286e0d8, 0xc000c50000, 0x0, 0x0, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:541 +0x458
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).RecursiveNodeHandler(0xc000c1e320, 0x2864b70, 0xc09825d710, 0x288e418, 0xc0a68156d0, 0x282ede0, 0xc04daf6a00, 0x282ee08, 0xc04daf6a00, 0x288a2c8, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:724 +0x91a
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).handleDownstream(0xc000c1e320, 0x2864b70, 0xc09825d710, 0x288e418, 0xc0a68156d0, 0x282ede0, 0xc04daf6a00, 0x282ee08, 0xc04daf6a00, 0x288a2c8, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:579 +0x23b
github.com/flyteorg/flytepropeller/pkg/controller/nodes.(*nodeExecutor).RecursiveNodeHandler(0xc000c1e320, 0x2864b70, 0xc09825d710, 0x288e418, 0xc0a68156d0, 0x282ede0, 0xc04daf6a00, 0x282ee08, 0xc04daf6a00, 0x288a2c8, ...)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/nodes/executor.go:731 +0x104f
github.com/flyteorg/flytepropeller/pkg/controller/workflow.(*workflowExecutor).handleRunningWorkflow(0xc0014271a0, 0x2864b70, 0xc09825d710, 0xc04daf6a00, 0xc09825d7d0, 0x3, 0x3, 0xc0457c3598)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workflow/executor.go:143 +0x1f4
github.com/flyteorg/flytepropeller/pkg/controller/workflow.(*workflowExecutor).HandleFlyteWorkflow(0xc0014271a0, 0x2864b70, 0xc09825d710, 0xc04daf6a00, 0x0, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workflow/executor.go:377 +0x725
github.com/flyteorg/flytepropeller/pkg/controller.(*Propeller).TryMutateWorkflow.func2(0xc000ff7290, 0x2864b70, 0xc09825d710, 0xc0457c38a0, 0xc04daf6a00)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/handler.go:129 +0x16c
github.com/flyteorg/flytepropeller/pkg/controller.(*Propeller).TryMutateWorkflow(0xc000ff7290, 0x2864b70, 0xc09825d710, 0xc0464a9b80, 0x0, 0x0, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/handler.go:130 +0x532
github.com/flyteorg/flytepropeller/pkg/controller.(*Propeller).Handle(0xc000ff7290, 0x2864b70, 0xc09825cf60, 0xc0a269b250, 0x3, 0xc0a269b254, 0x8, 0x0, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/handler.go:205 +0x478
github.com/flyteorg/flytepropeller/pkg/controller.(*WorkerPool).processNextWorkItem.func1(0xc000fa70e0, 0xc0457c3ee0, 0x2069740, 0xc0872b5f40, 0x0, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workers.go:88 +0x52c
github.com/flyteorg/flytepropeller/pkg/controller.(*WorkerPool).processNextWorkItem(0xc000fa70e0, 0x2864b70, 0xc09825cf60, 0x0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workers.go:99 +0xd8
github.com/flyteorg/flytepropeller/pkg/controller.(*WorkerPool).runWorker(0xc000fa70e0, 0x2864b70, 0xc062574420)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workers.go:115 +0x10d
github.com/flyteorg/flytepropeller/pkg/controller.(*WorkerPool).Run.func1(0x2864ac8, 0xc000873400, 0xc047891a60, 0x9, 0xc000fa70e0)
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workers.go:150 +0x91
created by github.com/flyteorg/flytepropeller/pkg/controller.(*WorkerPool).Run
	/go/src/github.com/flyteorg/flytepropeller/pkg/controller/workers.go:147 +0x379
]

convexquad avatar Aug 26 '21 18:08 convexquad

Thank you for opening your first issue here! 🛠

welcome[bot] avatar Aug 26 '21 18:08 welcome[bot]

thanks @convexquad for the detailed bug report! would you be interested in submitting a fix?

katrogan avatar Aug 26 '21 18:08 katrogan

@convexquad you almost wrote the fix :)

kumare3 avatar Aug 26 '21 22:08 kumare3

Bug fix PR - https://github.com/flyteorg/flyteplugins/pull/206. cc @katrogan

kumare3 avatar Aug 29 '21 05:08 kumare3