-
Notifications
You must be signed in to change notification settings - Fork 20
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
Create or update StorageClusterPeer #221
Create or update StorageClusterPeer #221
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vbnrh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Commits contain changes from #220 and can be ignored |
/test integration-test |
a2f2376
to
b912827
Compare
b912827
to
686de01
Compare
d5eb008
to
66aa1cd
Compare
66aa1cd
to
e7b374d
Compare
go.sum
Outdated
@@ -711,8 +710,8 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c | |||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= | |||
github.com/ramendr/ramen/api v0.0.0-20240409201920-10024cae3bfd h1:TsDaQqfb1BcR78JWXBmUyj6Qx4By5loUZ95CxmA/6zo= | |||
github.com/ramendr/ramen/api v0.0.0-20240409201920-10024cae3bfd/go.mod h1:PCb0ODjdi4eYuxY/nSw+/rQqmzkmBVqGNoDr2JXdlKE= | |||
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20240327160100-bbe9d9d49462 h1:84M7EBnmBISt2LcoyYPWsw+A3/7BGXp6Mh3sjUH5vIg= | |||
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20240327160100-bbe9d9d49462/go.mod h1:uySjux/lY0DpC+VXof4ly2SlS7QUocTm2CH4sU8ICeg= | |||
github.com/rewantsoni/ocs-operator/api/v4 v4.0.0-20240701052137-de69df292a5d h1:zXBbu5hpZmW4i3heppui4pqbvubZF/WsBiuP6ZekNKE= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporarily till this merges red-hat-storage/ocs-operator#2466
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
red-hat-storage/ocs-operator#2677 is merged. We can update this.
go.mod
Outdated
@@ -133,6 +133,7 @@ replace ( | |||
github.com/openshift/hive => github.com/openshift/hive v1.1.17-0.20220223000051-b1c8fa5853b1 | |||
github.com/openshift/hive/apis => github.com/openshift/hive/apis v0.0.0-20220221165319-b389a65758da | |||
github.com/portworx/sched-ops => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 | |||
github.com/red-hat-storage/ocs-operator/api/v4 => github.com/rewantsoni/ocs-operator/api/v4 v4.0.0-20240701052137-de69df292a5d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be removed as soon as this merges red-hat-storage/ocs-operator#2466
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: red-hat-storage/ocs-operator#2677 is the PR, the older PR was before the design changes
controllers/utils/peer_ref.go
Outdated
if peerRefs[0].StorageClusterRef.Namespace == "" && peerRefs[1].StorageClusterRef.Namespace == "" { | ||
return true | ||
} | ||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Namespace empty as the condition to verify if it is a StorageClient or check for its existence?
We could simplify this to
return peerRefs[0].StorageClusterRef.Namespace == "" && peerRefs[1].StorageClusterRef.Namespace == ""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a MirrorPeer check to see if its client pairing . Later more changes will made to API to make it more explicit.
controllers/mirrorpeer_controller.go
Outdated
func getClientInfoFromConfigMap(clientInfoMap map[string]string, clientName string) (ClientInfo, error) { | ||
clientInfoJSON, ok := clientInfoMap[clientName] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might change after https://github.com/red-hat-storage/odf-multicluster-orchestrator/pull/219/files#r1680476919
e43ec63
to
62202a2
Compare
8f86941
to
31b9f0e
Compare
1aafe87
to
1a5c378
Compare
1a5c378
to
832ce81
Compare
/test integration-test |
api/v1alpha1/mirrorpeer_types.go
Outdated
Name string `json:"name"` | ||
Name string `json:"name"` | ||
|
||
// +kubebuilder:validation:Optional | ||
Namespace string `json:"namespace"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Namespace string `json:"namespace"` | |
Namespace string `json:"namespace,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
r.Logger.Error("Failed to create ODR ObjectBucketClaim", "error", err, "MirrorPeer", mirrorPeer.Name, "namespace", scNamespace) | ||
return err | ||
} | ||
logger := r.Logger.With("MirrorPeer", mirrorPeer.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already set by the main Reconcile()
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -113,6 +113,11 @@ func (r *DRPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
if utils.IsStorageClientType(mirrorPeer.Spec.Items) { | |||
logger.Info("MirrorPeer contains StorageClient reference. Skipping creation of VolumeReplicationClasses", "MirrorPeer", mirrorPeer.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Info("MirrorPeer contains StorageClient reference. Skipping creation of VolumeReplicationClasses", "MirrorPeer", mirrorPeer.Name) | |
logger.Info("MirrorPeer contains StorageClient reference. Skipping creation of VolumeReplicationClasses") |
Isn't MirrorPeer name already injected in the main reconcile function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is DRPolicy controller, only the req is injected with the logger. MirrorPeer is fetched separately
controllers/mirrorpeer_controller.go
Outdated
const ( | ||
mirrorPeerFinalizer = "hub.multicluster.odf.openshift.io" | ||
spokeClusterRoleBindingName = "spoke-clusterrole-bindings" | ||
ClientConfigMapKeyTemplate = "%s/%s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a constant.
controllers/mirrorpeer_controller.go
Outdated
func getKey(clusterName, clientName string) string { | ||
return fmt.Sprintf(ClientConfigMapKeyTemplate, clusterName, clientName) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this? I think Sprintf is good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer it this way as it is more verbally descriptive. I will remove the clientconfigmapkey and use a format string
controllers/mirrorpeer_controller.go
Outdated
// Provider B's onboarding token will be used for Provider A's StorageClusterPeer | ||
onboardingToken, err := fetchOnboardingTicket(ctx, client, oppositeClient, mirrorPeer) | ||
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("failed to fetch onboarding token for provider %s. err %w", oppositeClient.ProviderInfo.ProviderManagedClusterName, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ctrl.Result{}, fmt.Errorf("failed to fetch onboarding token for provider %s. err %w", oppositeClient.ProviderInfo.ProviderManagedClusterName, err) | |
return ctrl.Result{}, fmt.Errorf("failed to fetch onboarding token for provider %s. %w", oppositeClient.ProviderInfo.ProviderManagedClusterName, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
controllers/utils/peer_ref.go
Outdated
@@ -33,3 +33,7 @@ func GetPeerRefForSpokeCluster(mp *multiclusterv1alpha1.MirrorPeer, spokeCluster | |||
} | |||
return nil, fmt.Errorf("PeerRef for cluster %s under mirrorpeer %s not found", spokeClusterName, mp.Name) | |||
} | |||
|
|||
func IsStorageClientType(peerRefs []multiclusterv1alpha1.PeerRef) bool { | |||
return peerRefs[0].StorageClusterRef.Namespace == "" && peerRefs[1].StorageClusterRef.Namespace == "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't the right way to check this. IMO we need to cross-reference with our configmap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a196623
to
52a9939
Compare
…pe handling - Updated `MirrorPeerReconciler` to handle `StorageClientType` by adding conditions in `Reconcile` method. - Introduced `createStorageClusterPeer` function for creating `StorageClusterPeer` objects. - Added utility functions `fetchClientInfoConfigMap` and `getClientInfoFromConfigMap` for handling client info. - Modified `processManagedClusterAddon` to utilize new config structure. - Enhanced `DRPolicyReconciler` to skip certain operations based on `StorageClientType`. Signed-off-by: vbadrina <[email protected]>
Signed-off-by: vbadrina <[email protected]>
- New utility functions for checking if MirrorPeer is having StorageClient ref - Functions cross check with the configmap to see if client - Functions will take a parameter for managedCluster and hub cluster separately to pick the configmap properly Signed-off-by: vbadrina <[email protected]>
52a9939
to
ebdb0b3
Compare
511cd6d
to
3c0cf48
Compare
- Upgrade `sigs.k8s.io/controller-runtime` to v0.19.0 - Upgrade Kubernetes modules to v0.31.0: - `k8s.io/api` v0.31.0 - `k8s.io/apimachinery` v0.31.0 - `k8s.io/client-go` v0.31.0 - `k8s.io/apiextensions-apiserver` v0.31.0 - Update other dependencies to compatible versions - Modify `Mirroring` field in `ocsv1.StorageClusterSpec` to use a pointer (`*ocsv1.MirroringSpec`) - Update tests in: - `addons/agent_mirrorpeer_controller_test.go` - `addons/green_secret_controller_test.go` - Run `go mod tidy` to clean up `go.mod` and `go.sum` - Fix build errors due to mismatched dependencies and API changes Signed-off-by: vbadrina <[email protected]>
3c0cf48
to
b4e0f4f
Compare
/test integration-test |
8c27440
into
red-hat-storage:main
MirrorPeerReconciler
to handleStorageClientType
by adding conditions inReconcile
method.createStorageClusterPeer
function for creatingStorageClusterPeer
objects.fetchClientInfoConfigMap
andgetClientInfoFromConfigMap
for handling client info.processManagedClusterAddon
to utilize new config structure.DRPolicyReconciler
to skip certain operations based onStorageClientType
.