Skip to content

Commit

Permalink
Implement DRClusterConfig reconciler to create required ClusterClaims (
Browse files Browse the repository at this point in the history
…#1485)

* Add logger to DRClusterConfig reconciler

Also, cleanup some scaffolding comments.

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Add initial reconcile for DRClusterConfig

- Add finalizer to resource being reconciled
- Remove on delete
- Update reconciler to rate limit max exponential backoff to
5 minutes

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Add roles for various storage classes and cluster claims

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Add StorageClass listing and dummy functions for claim creation

Building the scaffold for the overall functionality.

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Add ClusterClaims for detected StorageClasses

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Implement pruning of ClusterClaims

For classes listed, those that do not need a ClusterClaim
any longer are deleted.

Added a StorageClass watcher as well to the reconcile on
changes to StorageClasses.

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

* Implement CLassClaims for VRClass and VSClass

Signed-off-by: Shyamsundar Ranganathan <[email protected]>

---------

Signed-off-by: Shyamsundar Ranganathan <[email protected]>
  • Loading branch information
ShyamsundarR authored Sep 18, 2024
1 parent 19b296a commit 91e5a5b
Show file tree
Hide file tree
Showing 8 changed files with 804 additions and 66 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ test-drcluster: generate manifests envtest ## Run DRCluster tests.
test-drpolicy: generate manifests envtest ## Run DRPolicy tests.
go test ./internal/controller -coverprofile cover.out -ginkgo.focus DRPolicyController

test-drclusterconfig: generate manifests envtest ## Run DRClusterConfig tests.
go test ./internal/controller -coverprofile cover.out -ginkgo.focus DRClusterConfig

test-util: generate manifests envtest ## Run util tests.
go test ./internal/controller/util -coverprofile cover.out

Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func setupReconcilersCluster(mgr ctrl.Manager, ramenConfig *ramendrv1alpha1.Rame
if err := (&controllers.DRClusterConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Log: ctrl.Log.WithName("controllers").WithName("DRClusterConfig"),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DRClusterConfig")
os.Exit(1)
Expand Down
11 changes: 11 additions & 0 deletions config/dr-cluster/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ rules:
- patch
- update
- watch
- apiGroups:
- cluster.open-cluster-management.io
resources:
- clusterclaims
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- ramendr.openshift.io
resources:
Expand Down
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ rules:
- get
- list
- watch
- apiGroups:
- cluster.open-cluster-management.io
resources:
- clusterclaims
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- cluster.open-cluster-management.io
resources:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clusterclaims.cluster.open-cluster-management.io
spec:
group: cluster.open-cluster-management.io
names:
kind: ClusterClaim
listKind: ClusterClaimList
plural: clusterclaims
singular: clusterclaim
preserveUnknownFields: false
scope: Cluster
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: |-
ClusterClaim represents cluster information that a managed cluster claims
ClusterClaims with well known names include,
1. id.k8s.io, it contains a unique identifier for the cluster.
2. clusterset.k8s.io, it contains an identifier that relates the cluster
to the ClusterSet in which it belongs.
ClusterClaims created on a managed cluster will be collected and saved into
the status of the corresponding ManagedCluster on hub.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: Spec defines the attributes of the ClusterClaim.
properties:
value:
description: Value is a claim-dependent string
maxLength: 1024
minLength: 1
type: string
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 91e5a5b

Please sign in to comment.