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

rpc: add rpc calls to create the maintenance mode reconciler in ocs-operator #2870

Open
wants to merge 3 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
1 change: 1 addition & 0 deletions controllers/storageconsumer/storageconsumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
StorageProfileLabel = "ocs.openshift.io/storageprofile"
ConsumerUUIDLabel = "ocs.openshift.io/storageconsumer-uuid"
StorageConsumerNameLabel = "ocs.openshift.io/storageconsumer-name"
MaintenanceModeLabel = "ocs.openshift.io/maintenanceMode"
)

// StorageConsumerReconciler reconciles a StorageConsumer object
Expand Down
13 changes: 13 additions & 0 deletions controllers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ func AddLabel(obj metav1.Object, key string, value string) bool {
return false
}

func RemoveLabel(obj metav1.Object, key string) bool {
labels := obj.GetLabels()
if labels == nil {
return false
}
if _, exists := labels[key]; exists {
delete(labels, key)
obj.SetLabels(labels)
return true
}
return false
}

func CalculateMD5Hash(value any) string {
data, err := json.Marshal(value)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions deploy/ocs-operator/manifests/provider-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ rules:
- services
verbs:
- get
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- apiGroups:
- ceph.rook.io
resources:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rbac/provider-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ rules:
- services
verbs:
- get
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- list
- apiGroups:
- ceph.rook.io
resources:
Expand Down
46 changes: 46 additions & 0 deletions services/provider/api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,50 @@ func (cc *OCSProviderClient) PeerStorageCluster(ctx context.Context, onboardingT
defer cancel()

return cc.Client.PeerStorageCluster(apiCtx, req)

}

func (cc *OCSProviderClient) StartMaintenanceMode(ctx context.Context, consumerUUID string) (*pb.StartMaintenanceModeResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("provider client is closed")
}

req := &pb.StartMaintenanceModeRequest{
StorageConsumerUUID: consumerUUID,
}

apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()

return cc.Client.StartMaintenanceMode(apiCtx, req)
}

func (cc *OCSProviderClient) StopMaintenanceMode(ctx context.Context, consumerUUID string) (*pb.StopMaintenanceModeResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("provider client is closed")
}

req := &pb.StopMaintenanceModeRequest{
StorageConsumerUUID: consumerUUID,
}

apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()

return cc.Client.StopMaintenanceMode(apiCtx, req)
}

func (cc *OCSProviderClient) GetMaintenanceModeStatus(ctx context.Context, consumerUUID string) (*pb.GetMaintenanceModeStatusResponse, error) {
if cc.Client == nil || cc.clientConn == nil {
return nil, fmt.Errorf("provider client is closed")
}

req := &pb.GetMaintenanceModeStatusRequest{
StorageConsumerUUID: consumerUUID,
}

apiCtx, cancel := context.WithTimeout(ctx, cc.timeout)
defer cancel()

return cc.Client.GetMaintenanceModeStatus(apiCtx, req)
}
Loading
Loading