Skip to content

Commit

Permalink
Fix DVM/DVMP hotlooping, remove remote watch TouchAnnotation, fix req…
Browse files Browse the repository at this point in the history
…ueue times

Remove predicate

Remove leftover log

Move default PollReQ setting for better locality

Remove redundant requeue

Back out explicit requeue
  • Loading branch information
djwhatle committed Mar 25, 2021
1 parent 6d270c1 commit 719eb24
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha1
import (
"context"

"github.com/google/uuid"
liberr "github.com/konveyor/controller/pkg/error"
kapi "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -108,11 +107,9 @@ type DirectVolumeMigrationProgress struct {
}

func (d *DirectVolumeMigrationProgress) MarkReconciled() {
u, _ := uuid.NewUUID()
if d.Annotations == nil {
d.Annotations = map[string]string{}
}
d.Annotations[TouchAnnotation] = u.String()
d.Status.ObservedDigest = digest(d.Spec)
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/migration/v1alpha1/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,9 @@ func (r *DirectVolumeMigration) GetName() string {
}

func (r *DirectVolumeMigration) MarkReconciled() {
uuid, _ := uuid.NewUUID()
if r.Annotations == nil {
r.Annotations = map[string]string{}
}
r.Annotations[TouchAnnotation] = uuid.String()
r.Status.ObservedDigest = digest(r.Spec)
}

Expand Down Expand Up @@ -269,11 +267,9 @@ func (r *DirectImageMigration) GetName() string {
}

func (r *DirectImageMigration) MarkReconciled() {
uuid, _ := uuid.NewUUID()
if r.Annotations == nil {
r.Annotations = map[string]string{}
}
r.Annotations[TouchAnnotation] = uuid.String()
r.Status.ObservedDigest = digest(r.Spec)
}

Expand Down Expand Up @@ -303,11 +299,9 @@ func (r *DirectImageStreamMigration) GetName() string {
}

func (r *DirectImageStreamMigration) MarkReconciled() {
uuid, _ := uuid.NewUUID()
if r.Annotations == nil {
r.Annotations = map[string]string{}
}
r.Annotations[TouchAnnotation] = uuid.String()
r.Status.ObservedDigest = digest(r.Spec)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package directimagemigration

import (
"context"
"time"

"github.com/konveyor/controller/pkg/logging"
migapi "github.com/konveyor/mig-controller/pkg/apis/migration/v1alpha1"
Expand Down Expand Up @@ -122,7 +123,7 @@ func (r *ReconcileDirectImageMigration) Reconcile(request reconcile.Request) (re
return reconcile.Result{}, nil
}
// Error reading the object - requeue the request.
return reconcile.Result{}, err
return reconcile.Result{Requeue: true}, err
}

// Set up jaeger tracing
Expand All @@ -146,8 +147,11 @@ func (r *ReconcileDirectImageMigration) Reconcile(request reconcile.Request) (re
return reconcile.Result{Requeue: true}, nil
}

// Default to PollReQ, can be overridden by r.migrate phase-specific ReQ interval
requeueAfter := time.Duration(PollReQ)

if !imageMigration.Status.HasBlockerCondition() {
_, err = r.migrate(imageMigration, reconcileSpan)
requeueAfter, err = r.migrate(imageMigration, reconcileSpan)
if err != nil {
log.Trace(err)
return reconcile.Result{Requeue: true}, nil
Expand All @@ -171,6 +175,10 @@ func (r *ReconcileDirectImageMigration) Reconcile(request reconcile.Request) (re
return reconcile.Result{Requeue: true}, nil
}

// Done
// Requeue
if requeueAfter > 0 {
return reconcile.Result{RequeueAfter: requeueAfter}, nil
}

return reconcile.Result{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package directimagestreammigration

import (
"context"
"time"

"github.com/konveyor/controller/pkg/logging"
migapi "github.com/konveyor/mig-controller/pkg/apis/migration/v1alpha1"
Expand Down Expand Up @@ -113,7 +114,7 @@ func (r *ReconcileDirectImageStreamMigration) Reconcile(request reconcile.Reques
return reconcile.Result{}, nil
}
// Error reading the object - requeue the request.
return reconcile.Result{}, err
return reconcile.Result{Requeue: true}, err
}

// Set up jaeger tracing
Expand All @@ -137,8 +138,11 @@ func (r *ReconcileDirectImageStreamMigration) Reconcile(request reconcile.Reques
return reconcile.Result{Requeue: true}, nil
}

// Default to PollReQ, can be overridden by r.migrate phase-specific ReQ interval
requeueAfter := time.Duration(PollReQ)

if !imageStreamMigration.Status.HasBlockerCondition() {
_, err = r.migrate(imageStreamMigration, reconcileSpan)
requeueAfter, err = r.migrate(imageStreamMigration, reconcileSpan)
if err != nil {
log.Trace(err)
return reconcile.Result{Requeue: true}, nil
Expand All @@ -162,6 +166,10 @@ func (r *ReconcileDirectImageStreamMigration) Reconcile(request reconcile.Reques
return reconcile.Result{Requeue: true}, nil
}

// Done
// Requeue
if requeueAfter > 0 {
return reconcile.Result{RequeueAfter: requeueAfter}, nil
}

return reconcile.Result{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package directvolumemigration

import (
"context"
"time"

"github.com/konveyor/controller/pkg/logging"
migapi "github.com/konveyor/mig-controller/pkg/apis/migration/v1alpha1"
Expand Down Expand Up @@ -103,7 +104,7 @@ func (r *ReconcileDirectVolumeMigration) Reconcile(request reconcile.Request) (r
return reconcile.Result{}, nil
}
// Error reading the object - requeue the request.
return reconcile.Result{}, err
return reconcile.Result{Requeue: true}, err
}

// Set up jaeger tracing
Expand All @@ -130,8 +131,11 @@ func (r *ReconcileDirectVolumeMigration) Reconcile(request reconcile.Request) (r
return reconcile.Result{Requeue: true}, nil
}

// Default to PollReQ, can be overridden by r.migrate phase-specific ReQ interval
requeueAfter := time.Duration(PollReQ)

if !direct.Status.HasBlockerCondition() {
_, err = r.migrate(direct, reconcileSpan)
requeueAfter, err = r.migrate(direct, reconcileSpan)
if err != nil {
log.Trace(err)
return reconcile.Result{Requeue: true}, nil
Expand All @@ -155,6 +159,11 @@ func (r *ReconcileDirectVolumeMigration) Reconcile(request reconcile.Request) (r
return reconcile.Result{Requeue: true}, nil
}

// Requeue
if requeueAfter > 0 {
return reconcile.Result{RequeueAfter: requeueAfter}, nil
}

// Done
return reconcile.Result{}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ func (r *ReconcileDirectVolumeMigrationProgress) Reconcile(request reconcile.Req
return reconcile.Result{Requeue: true}, nil
}

if !pvProgress.Status.IsReady() {
return reconcile.Result{Requeue: true}, nil
}

// we will requeue this every 5 seconds
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 5}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/migmigration/migmigration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (r *ReconcileMigMigration) Reconcile(request reconcile.Request) (reconcile.
if err != nil {
if errors.IsNotFound(err) {
err = r.deleted()
return reconcile.Result{Requeue: false}, nil
return reconcile.Result{}, nil
}
log.Info("Error getting migmigration for reconcile, requeueing.")
log.Trace(err)
Expand Down Expand Up @@ -210,9 +210,6 @@ func (r *ReconcileMigMigration) Reconcile(request reconcile.Request) (reconcile.
return reconcile.Result{Requeue: true}, err
}

// Re-queue (after) in seconds.
requeueAfter := time.Duration(PollReQ)

// Begin staging conditions.
migration.Status.BeginStagingConditions()

Expand All @@ -224,6 +221,9 @@ func (r *ReconcileMigMigration) Reconcile(request reconcile.Request) (reconcile.
return reconcile.Result{Requeue: true}, nil
}

// Default to PollReQ, can be overridden by r.postpone() or r.migrate()
requeueAfter := time.Duration(PollReQ)

// Ensure that migrations run serially ordered by when created
// and grouped with stage migrations followed by final migrations.
// Reconcile of a migration not in the desired order will be postponed.
Expand Down

0 comments on commit 719eb24

Please sign in to comment.