mirror of
https://github.com/lukaszraczylo/jobs-manager-operator.git
synced 2026-10-11 05:28:07 +00:00
fix(controller): detect existing job with AlreadyExists
The job creation check matched the substring 'exists' in the error text. It now uses apierrors.IsAlreadyExists, so unrelated errors no longer match.
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/lukaszraczylo/pandati"
|
||||
kbatch "k8s.io/api/batch/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
jobsmanagerv1beta1 "raczylo.com/jobs-manager-operator/api/v1beta1"
|
||||
@@ -203,7 +202,7 @@ func (cp *connPackage) runPendingJobs() {
|
||||
err := cp.executeJob(job, group)
|
||||
if err != nil {
|
||||
cp.logger.Error(err, "Unable to execute job", "job", job.Name, "group", group.Name)
|
||||
if !strings.Contains(err.Error(), "exists") {
|
||||
if !apierrors.IsAlreadyExists(err) {
|
||||
job.Status = ExecutionStatusFailed
|
||||
group.Status = ExecutionStatusFailed
|
||||
cp.updateDependentJobs(job.Name, ExecutionStatusFailed)
|
||||
|
||||
Reference in New Issue
Block a user