Skip to content

Commit

Permalink
Merge pull request red-hat-storage#1141 from obnoxxx/update-rook
Browse files Browse the repository at this point in the history
Update rook to latest master build.
  • Loading branch information
openshift-merge-robot committed Apr 19, 2021
2 parents 70c13cf + 93a2928 commit dee571f
Show file tree
Hide file tree
Showing 243 changed files with 20,115 additions and 12,601 deletions.
58 changes: 37 additions & 21 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Expand Up @@ -712,10 +712,8 @@ spec:
be used to connect the cluster. Meanwhile the keys describe
each network respective responsibilities or any metadata storage
provider decide.
nullable: true
type: object
required:
- provider
- selectors
type: object
nodeTopologies:
description: NodeTopologies specifies the nodes available for the
Expand Down Expand Up @@ -746,10 +744,11 @@ spec:
type: object
placement:
additionalProperties:
description: Placement is the placement for an object
properties:
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
description: NodeAffinity is a group of node affinity scheduling
rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -953,8 +952,8 @@ spec:
type: object
type: object
podAffinity:
description: Pod affinity is a group of inter pod affinity scheduling
rules.
description: PodAffinity is a group of inter pod affinity scheduling
rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -1147,8 +1146,8 @@ spec:
type: array
type: object
podAntiAffinity:
description: Pod anti affinity is a group of inter pod anti
affinity scheduling rules.
description: PodAntiAffinity is a group of inter pod anti affinity
scheduling rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -1342,6 +1341,9 @@ spec:
type: array
type: object
tolerations:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
Expand Down Expand Up @@ -1383,6 +1385,8 @@ spec:
type: object
type: array
topologySpreadConstraints:
description: TopologySpreadConstraint specifies how to spread
matching pods among the given topology
items:
description: TopologySpreadConstraint specifies how to spread
matching pods among the given topology.
Expand Down Expand Up @@ -1984,10 +1988,11 @@ spec:
name:
type: string
placement:
description: Placement is the placement for an object
properties:
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
description: NodeAffinity is a group of node affinity scheduling
rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -2200,8 +2205,8 @@ spec:
type: object
type: object
podAffinity:
description: Pod affinity is a group of inter pod affinity
scheduling rules.
description: PodAffinity is a group of inter pod affinity
scheduling rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -2403,8 +2408,8 @@ spec:
type: array
type: object
podAntiAffinity:
description: Pod anti affinity is a group of inter pod anti
affinity scheduling rules.
description: PodAntiAffinity is a group of inter pod anti
affinity scheduling rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -2606,6 +2611,9 @@ spec:
type: array
type: object
tolerations:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect>
Expand Down Expand Up @@ -2648,6 +2656,8 @@ spec:
type: object
type: array
topologySpreadConstraints:
description: TopologySpreadConstraint specifies how to spread
matching pods among the given topology
items:
description: TopologySpreadConstraint specifies how to
spread matching pods among the given topology.
Expand Down Expand Up @@ -2762,10 +2772,11 @@ spec:
set
type: boolean
preparePlacement:
description: Placement is the placement for an object
properties:
nodeAffinity:
description: Node affinity is a group of node affinity scheduling
rules.
description: NodeAffinity is a group of node affinity scheduling
rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -2978,8 +2989,8 @@ spec:
type: object
type: object
podAffinity:
description: Pod affinity is a group of inter pod affinity
scheduling rules.
description: PodAffinity is a group of inter pod affinity
scheduling rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -3181,8 +3192,8 @@ spec:
type: array
type: object
podAntiAffinity:
description: Pod anti affinity is a group of inter pod anti
affinity scheduling rules.
description: PodAntiAffinity is a group of inter pod anti
affinity scheduling rules
properties:
preferredDuringSchedulingIgnoredDuringExecution:
description: The scheduler will prefer to schedule pods
Expand Down Expand Up @@ -3384,6 +3395,9 @@ spec:
type: array
type: object
tolerations:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect>
Expand Down Expand Up @@ -3426,6 +3440,8 @@ spec:
type: object
type: array
topologySpreadConstraints:
description: TopologySpreadConstraint specifies how to spread
matching pods among the given topology
items:
description: TopologySpreadConstraint specifies how to
spread matching pods among the given topology.
Expand Down
9 changes: 9 additions & 0 deletions config/rbac/role.yaml
Expand Up @@ -49,6 +49,15 @@ rules:
- consolequickstarts
verbs:
- '*'
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- get
- list
- update
- apiGroups:
- ""
resources:
Expand Down
18 changes: 9 additions & 9 deletions controllers/ocsinitialization/ocsinitialization_controller.go
Expand Up @@ -189,7 +189,7 @@ func (r *OCSInitializationReconciler) ensureToolsDeployment(initialData *ocsv1.O
// and what is in the OCSInitialization.Spec
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) {
func (r *OCSInitializationReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {

prevLogger := r.Log
defer func() { r.Log = prevLogger }()
Expand All @@ -202,7 +202,7 @@ func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reco
if initNamespacedName.Name != request.Name || initNamespacedName.Namespace != request.Namespace {
// Ignoring this resource because it has the wrong name or namespace
r.Log.Info(wrongNamespacedName)
err := r.Client.Get(context.TODO(), request.NamespacedName, instance)
err := r.Client.Get(ctx, request.NamespacedName, instance)
if err != nil {
// the resource probably got deleted
if errors.IsNotFound(err) {
Expand All @@ -212,22 +212,22 @@ func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reco
}

instance.Status.Phase = util.PhaseIgnored
err = r.Client.Status().Update(context.TODO(), instance)
err = r.Client.Status().Update(ctx, instance)
if err != nil {
r.Log.Error(err, "failed to update ignored resource")
}
return reconcile.Result{}, err
}

// Fetch the OCSInitialization instance
err := r.Client.Get(context.TODO(), request.NamespacedName, instance)
err := r.Client.Get(ctx, request.NamespacedName, instance)
if err != nil {
if errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
// Recreating since we depend on this to exist. A user may delete it to
// induce a reset of all initial data.
r.Log.Info("recreating OCSInitialization resource")
return reconcile.Result{}, r.Client.Create(context.TODO(), &ocsv1.OCSInitialization{
return reconcile.Result{}, r.Client.Create(ctx, &ocsv1.OCSInitialization{
ObjectMeta: metav1.ObjectMeta{
Name: initNamespacedName.Name,
Namespace: initNamespacedName.Namespace,
Expand All @@ -244,7 +244,7 @@ func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reco
util.SetProgressingCondition(&instance.Status.Conditions, reason, message)

instance.Status.Phase = util.PhaseProgressing
err = r.Client.Status().Update(context.TODO(), instance)
err = r.Client.Status().Update(ctx, instance)
if err != nil {
r.Log.Error(err, "Failed to add conditions to status")
return reconcile.Result{}, err
Expand All @@ -259,15 +259,15 @@ func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reco

instance.Status.Phase = util.PhaseError
// don't want to overwrite the actual reconcile failure
uErr := r.Client.Status().Update(context.TODO(), instance)
uErr := r.Client.Status().Update(ctx, instance)
if uErr != nil {
r.Log.Error(uErr, "Failed to update conditions")
}
return reconcile.Result{}, err
}
instance.Status.SCCsCreated = true

err = r.Client.Status().Update(context.TODO(), instance)
err = r.Client.Status().Update(ctx, instance)
if err != nil {
return reconcile.Result{}, err
}
Expand All @@ -294,7 +294,7 @@ func (r *OCSInitializationReconciler) Reconcile(request reconcile.Request) (reco
util.SetCompleteCondition(&instance.Status.Conditions, reason, message)

instance.Status.Phase = util.PhaseReady
err = r.Client.Status().Update(context.TODO(), instance)
err = r.Client.Status().Update(ctx, instance)

return reconcile.Result{}, err
}
Expand Down
36 changes: 23 additions & 13 deletions controllers/ocsinitialization/ocsinitialization_controller_test.go
Expand Up @@ -18,6 +18,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
testingClient "k8s.io/client-go/testing"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -49,13 +50,19 @@ func getTestParams(mockNamespace bool, t *testing.T) (v1.OCSInitialization, reco
Namespace: request.Namespace,
},
}
ocsRecon := v1.OCSInitialization{
ObjectMeta: metav1.ObjectMeta{
Name: request.Name,
Namespace: request.Namespace,
},
}

return ocs, request, getReconciler(t, &ocs)
return ocs, request, getReconciler(t, &ocsRecon)
}

func getReconciler(t *testing.T, objs ...runtime.Object) OCSInitializationReconciler {
func getReconciler(t *testing.T, objs ...client.Object) OCSInitializationReconciler {
scheme := createFakeScheme(t)
client := fake.NewFakeClientWithScheme(scheme, objs...)
client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(objs...).Build()
secClient := &fakeSecClient.FakeSecurityV1{Fake: &testingClient.Fake{}}
log := logf.Log.WithName("controller_storagecluster_test")

Expand Down Expand Up @@ -126,7 +133,7 @@ func TestNonWatchedResourceNotFound(t *testing.T) {
_, request, reconciler := getTestParams(true, t)
request.Name = tc.name
request.Namespace = tc.namespace
_, err := reconciler.Reconcile(request)
_, err := reconciler.Reconcile(context.TODO(), request)
assert.NoErrorf(t, err, "[%s]: failed to reconcile with non watched resource", tc.label)
}
}
Expand Down Expand Up @@ -156,12 +163,14 @@ func TestNonWatchedResourceFound(t *testing.T) {
request.Namespace = tc.namespace
ocs.Name = tc.name
ocs.Namespace = tc.namespace
reconciler.Client.Create(nil, &ocs)
_, err := reconciler.Reconcile(request)
err := reconciler.Client.Create(nil, &ocs)
assert.NoErrorf(t, err, "[%s]: failed CREATE of non watched resource", tc.label)
_, err = reconciler.Reconcile(context.TODO(), request)
assert.NoErrorf(t, err, "[%s]: failed to reconcile with non watched resource", tc.label)
actual := &v1.OCSInitialization{}
reconciler.Client.Get(nil, request.NamespacedName, actual)
assert.Equalf(t, statusutil.PhaseIgnored, actual.Status.Phase, "[%s]: failed to update phase of non watched resource that already exists", tc.label)
err = reconciler.Client.Get(nil, request.NamespacedName, actual)
assert.NoErrorf(t, err, "[%s]: failed GET of actual resource", tc.label)
assert.Equalf(t, statusutil.PhaseIgnored, actual.Status.Phase, "[%s]: failed to update phase of non watched resource that already exists OCS:\n%v", tc.label, actual)
}
}

Expand Down Expand Up @@ -192,7 +201,7 @@ func TestCreateWatchedResource(t *testing.T) {
err = reconciler.Client.Get(nil, request.NamespacedName, &ocs)
assert.Error(t, err)
}
_, err := reconciler.Reconcile(request)
_, err := reconciler.Reconcile(context.TODO(), request)
assert.NoError(t, err)
obj := v1.OCSInitialization{}
_ = reconciler.Client.Get(nil, request.NamespacedName, &obj)
Expand Down Expand Up @@ -221,11 +230,12 @@ func TestCreateSCCs(t *testing.T) {

if tc.sscCreated {
ocs.Status.SCCsCreated = false
err := reconciler.Client.Update(context.TODO(), &ocs)
assert.NoErrorf(t, err, "[%s]: failed to update ocsInit status", tc.label)
// TODO: uncomment this!
//err := reconciler.Client.Update(context.TODO(), &ocs)
//assert.NoErrorf(t, err, "[%s]: failed to update ocsInit status", tc.label)
}

_, err := reconciler.Reconcile(request)
_, err := reconciler.Reconcile(context.TODO(), request)
assert.NoErrorf(t, err, "[%s]: failed to reconcile ocsInit", tc.label)
obj := v1.OCSInitialization{}
_ = reconciler.Client.Get(context.TODO(), request.NamespacedName, &obj)
Expand All @@ -241,7 +251,7 @@ func TestCreateSCCs(t *testing.T) {
func TestReconcileCompleteConditions(t *testing.T) {
_, request, reconciler := getTestParams(false, t)

_, err := reconciler.Reconcile(request)
_, err := reconciler.Reconcile(context.TODO(), request)
assert.NoError(t, err)
obj := v1.OCSInitialization{}
_ = reconciler.Client.Get(context.TODO(), request.NamespacedName, &obj)
Expand Down
4 changes: 2 additions & 2 deletions controllers/persistentvolume/reconcile.go
Expand Up @@ -18,14 +18,14 @@ type ensureFunc func(*corev1.PersistentVolume) error
// +kubebuilder:rbac:groups=storage.k8s.io,resources=storageclasses,verbs=get

// Reconcile ...
func (r *PersistentVolumeReconciler) Reconcile(request reconcile.Request) (reconcile.Result, error) {
func (r *PersistentVolumeReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {

prevLogger := r.Log
defer func() { r.Log = prevLogger }()
r.Log = r.Log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)

pv := &corev1.PersistentVolume{}
err := r.Client.Get(context.TODO(), request.NamespacedName, pv)
err := r.Client.Get(ctx, request.NamespacedName, pv)
if err != nil {
if errors.IsNotFound(err) {
r.Log.Info("PersistentVolume not found")
Expand Down

0 comments on commit dee571f

Please sign in to comment.