From bd2235b5ce059e416adf8eeb9c406dc66856abe3 Mon Sep 17 00:00:00 2001 From: David Grove Date: Tue, 16 Apr 2024 16:02:20 -0400 Subject: [PATCH] detect missing podSetInfo and raise fatal error (#98) Avoid crashing the operator with an index-out-of-bounds panic when a misconfiguration results in a workload being in the Resuming phase without the expected assignment of PodSetInfos by Kueue. This can happen when running in dev mode (no webhooks) and the input appwrapper yaml didn't explicitly set suspend to True. --- internal/controller/appwrapper/resource_management.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/controller/appwrapper/resource_management.go b/internal/controller/appwrapper/resource_management.go index c6a926ec..f1f5eb37 100644 --- a/internal/controller/appwrapper/resource_management.go +++ b/internal/controller/appwrapper/resource_management.go @@ -90,7 +90,11 @@ func (r *AppWrapperReconciler) createComponent(ctx context.Context, aw *workload for podSetsIdx, podSet := range component.PodSets { toInject := &workloadv1beta2.AppWrapperPodSetInfo{} if !r.Config.StandaloneMode { - toInject = &component.PodSetInfos[podSetsIdx] + if podSetsIdx < len(component.PodSetInfos) { + toInject = &component.PodSetInfos[podSetsIdx] + } else { + return nil, fmt.Errorf("missing podSetInfo %v for component %v", podSetsIdx, componentIdx), true + } } p, err := utils.GetRawTemplate(obj.UnstructuredContent(), podSet.Path)