Files
my-rook-config/pkg/operator/ceph/object/bucket/api-handlers.go
T
Sébastien Han b89730d895 ceph: refactor operator initialization sequence
This commit is a large refactor on how the operator starts, stops and
how it starts various sub-components such as the ceph-csi driver. It
also refines the way we cancel orchestrations. We don't use breakpoints
anymore but send our self a SIGUP to reload our controller runtime
manager.
The reload will happen under different circonstances like:

* a new adminission controller secret is created/deleted/changed
* a CephCluster CR is edited

As mentioned earlier, the csi driver now has its own controller, just
like flex. It reacts to change in the operator config map for particular
ROOK_CSI_ fields.

A second new controller for the operator's general config has been
created, it manages:

* the logging level
* the ceph CLI command timeout
* the discovery daemon

The operator reacts much more rapidly to cancellation events by stopping
the manager's context and reloading it.

Signed-off-by: Sébastien Han <seb@redhat.com>
2021-09-17 16:57:12 +02:00

49 lines
1.2 KiB
Go

package bucket
import (
"time"
"github.com/pkg/errors"
storagev1 "k8s.io/api/storage/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
)
const (
waitDuration = time.Second * 3
waitFactor = 2
waitJitter = 0.5
waitSteps = 5
waitCap = time.Minute * 5
)
var backoff = wait.Backoff{
Duration: waitDuration,
Factor: waitFactor,
Jitter: waitJitter,
Steps: waitSteps,
Cap: waitCap,
}
func (p *Provisioner) getStorageClassWithBackoff(name string) (class *storagev1.StorageClass, err error) {
logger.Infof("getting storage class %q", name)
classClient := p.context.Clientset.StorageV1().StorageClasses()
// Retry Get() with backoff. Errors other than IsNotFound are ignored.
err = wait.ExponentialBackoff(backoff, func() (done bool, err error) {
class, err = classClient.Get(p.clusterInfo.Context, name, metav1.GetOptions{})
if err == nil {
return true, nil
}
if kerrors.IsNotFound(err) {
return true, err
}
logger.Errorf("error getting class %q, retrying. %v", name, err)
return false, nil
})
if err != nil {
return nil, errors.Wrapf(err, "unable to Get storageclass %q", name)
}
return
}