diff --git a/pkg/operator/resources/batchapi/api.go b/pkg/operator/resources/batchapi/api.go index 5c54193556..6e02cf5f55 100644 --- a/pkg/operator/resources/batchapi/api.go +++ b/pkg/operator/resources/batchapi/api.go @@ -192,6 +192,11 @@ func GetAllAPIs(virtualServices []istioclientnetworking.VirtualService, k8sJobs for _, jobKey := range inProgressJobKeys { alreadyAdded := false + if _, ok := batchAPIsMap[jobKey.APIName]; !ok { + // It is possible that the Batch API may have been deleted but the in progress job keys have not been deleted yet + continue + } + for _, jobStatus := range batchAPIsMap[jobKey.APIName].JobStatuses { if jobStatus.ID == jobKey.ID { alreadyAdded = true