Skip to content

Commit 17a6def

Browse files
frelondavidcassany
authored andcommitted
Fix channel sync bug
During upgrades we have a race-condition for the ManagedOSVersionChannels. This commit checks to see if a ManagedOSVersionChannel syncer pod was created with another image than the provided elemental-operator and if true, will delete the old pod and recreate the syncer pod. Signed-off-by: Fredrik Lönnegren <fredrik.lonnegren@suse.com> (cherry picked from commit cfdcb4a)
1 parent d4eef62 commit 17a6def

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

controllers/managedosversionchannel_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import (
2222
"fmt"
2323
"time"
2424

25-
elementalv1 "github.com/rancher/elemental-operator/api/v1beta1"
26-
"github.com/rancher/elemental-operator/pkg/log"
27-
"github.com/rancher/elemental-operator/pkg/syncer"
28-
"github.com/rancher/elemental-operator/pkg/util"
2925
corev1 "k8s.io/api/core/v1"
3026
apierrors "k8s.io/apimachinery/pkg/api/errors"
3127
"k8s.io/apimachinery/pkg/api/meta"
@@ -40,6 +36,11 @@ import (
4036
"sigs.k8s.io/controller-runtime/pkg/event"
4137
"sigs.k8s.io/controller-runtime/pkg/predicate"
4238
"sigs.k8s.io/controller-runtime/pkg/reconcile"
39+
40+
elementalv1 "github.com/rancher/elemental-operator/api/v1beta1"
41+
"github.com/rancher/elemental-operator/pkg/log"
42+
"github.com/rancher/elemental-operator/pkg/syncer"
43+
"github.com/rancher/elemental-operator/pkg/util"
4344
)
4445

4546
const (
@@ -204,6 +205,13 @@ func (r *ManagedOSVersionChannelReconciler) reconcile(ctx context.Context, manag
204205
return ctrl.Result{}, err
205206
}
206207

208+
// Sometimes during upgrade the new elemental-channel will be created using
209+
// the old logic. This checks if this happened we recreate the syncer pod.
210+
if pod.Spec.Containers[0].Image != r.OperatorImage {
211+
_ = r.Delete(ctx, pod)
212+
return ctrl.Result{}, r.createSyncerPod(ctx, managedOSVersionChannel, sync)
213+
}
214+
207215
return r.handleSyncPod(ctx, pod, managedOSVersionChannel, interval), nil
208216
}
209217

0 commit comments

Comments
 (0)