Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle copy preflight results job already exists error #1650

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions operator/controllers/installation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -508,9 +508,12 @@ func (r *InstallationReconciler) CopyHostPreflightResultsFromNodes(ctx context.C
}

if err := r.Create(ctx, job); err != nil {
return fmt.Errorf("failed to create job: %w", err)
if !k8serrors.IsAlreadyExists(err) {
return fmt.Errorf("failed to create job: %w", err)
}
} else {
log.Info("Copy host preflight results job for node created", "node", event.NodeName, "installation", in.Name)
}
log.Info("Copy host preflight results job for node created", "node", event.NodeName, "installation", in.Name)
}

return nil
Expand Down Expand Up @@ -638,7 +641,7 @@ func (r *InstallationReconciler) Reconcile(ctx context.Context, req ctrl.Request

// save the installation status. nothing more to do with it.
if err := r.Status().Update(ctx, in.DeepCopy()); err != nil {
if errors.IsConflict(err) {
if k8serrors.IsConflict(err) {
return ctrl.Result{}, fmt.Errorf("failed to update status: conflict")
}
return ctrl.Result{}, fmt.Errorf("failed to update installation status: %w", err)
Expand Down
Loading