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

Add requeueAfter to volume deletion flow #1158

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
)

const (
eventuallyTimeout = 3 * time.Second
eventuallyTimeout = 6 * time.Second
pollingInterval = 50 * time.Millisecond
consistentlyDuration = 1 * time.Second
apiServiceTimeout = 5 * time.Minute
Expand Down
17 changes: 9 additions & 8 deletions poollet/volumepoollet/controllers/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"time"

"github.com/go-logr/logr"
"github.com/ironcore-dev/controller-utils/clientutils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

corev1alpha1 "github.com/ironcore-dev/ironcore/api/core/v1alpha1"
storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1"
irimeta "github.com/ironcore-dev/ironcore/iri/apis/meta/v1alpha1"
iriVolume "github.com/ironcore-dev/ironcore/iri/apis/volume"
iri "github.com/ironcore-dev/ironcore/iri/apis/volume/v1alpha1"

volumepoolletv1alpha1 "github.com/ironcore-dev/ironcore/poollet/volumepoollet/api/v1alpha1"
"github.com/ironcore-dev/ironcore/poollet/volumepoollet/controllers/events"
"github.com/ironcore-dev/ironcore/poollet/volumepoollet/vcm"
ironcoreclient "github.com/ironcore-dev/ironcore/utils/client"
"github.com/ironcore-dev/ironcore/utils/predicates"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/ironcore-dev/controller-utils/clientutils"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -125,7 +127,7 @@ func (r *VolumeReconciler) deleteGone(ctx context.Context, log logr.Logger, volu
}
if !ok {
log.V(1).Info("Not all iri volumes are gone, requeueing")
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this configurable via a flag?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also

// RequeueAfter if greater than 0, tells the Controller to requeue the reconcile key after the Duration.
// Implies that Requeue is true, there is no need to set Requeue to true at the same time as RequeueAfter.
RequeueAfter time.Duration

}

log.V(1).Info("Deleted gone")
Expand Down Expand Up @@ -198,7 +200,7 @@ func (r *VolumeReconciler) delete(ctx context.Context, log logr.Logger, volume *
}
if !ok {
log.V(1).Info("Not all iri volumes are gone, requeueing")
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh. I'm not sure if we should use a "fixed" delay, since we are working actively against the controller-runtime requeue mechanism with an exponential backoff. Waiting a fixed time multiplies if we build multiple layers of the brokers/poollets. Wdyt about returning an error to circumvent this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even without returning an error we already have the optimal behavior: https://github.com/kubernetes-sigs/controller-runtime/blob/main/pkg/reconcile/reconcile.go#L99-L112

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// If the error is nil and result.RequeueAfter is zero and result.Requeue is true, the request
// will be requeued using exponential backoff.

}

log.V(1).Info("Deleted all iri volumes, removing finalizer")
Expand Down Expand Up @@ -443,7 +445,7 @@ func (r *VolumeReconciler) update(ctx context.Context, log logr.Logger, volume *
return nil
}

func (r *VolumeReconciler) volumeSecretName(volumeName string, volumeHandle string) string {
func (r *VolumeReconciler) volumeSecretName(volumeName, volumeHandle string) string {
sum := sha256.Sum256([]byte(fmt.Sprintf("%s/%s", volumeName, volumeHandle)))
return hex.EncodeToString(sum[:])[:63]
}
Expand Down Expand Up @@ -508,7 +510,6 @@ func (r *VolumeReconciler) updateStatus(ctx context.Context, log logr.Logger, vo
VolumeAttributes: iriAccess.Attributes,
}
}

}

base := volume.DeepCopy()
Expand Down
Loading