Skip to content

controllers: send the client profile mapping required for DR #2879

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

Merged
merged 2 commits into from
Nov 19, 2024
Merged
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
2 changes: 2 additions & 0 deletions controllers/util/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const (

OdfInfoNamespacedNameClaimName = "odfinfo.odf.openshift.io"
ExitCodeThatShouldRestartTheProcess = 42

BlockPoolMirroringTargetIDAnnotation = "ocs.openshift.io/mirroring-target-id"
)

var podNamespace = os.Getenv(PodNamespaceEnvVar)
Expand Down
1 change: 1 addition & 0 deletions deploy/ocs-operator/manifests/provider-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rules:
resources:
- cephfilesystemsubvolumegroups
- cephblockpoolradosnamespaces
- cephblockpools
verbs:
- get
- list
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ replace github.com/red-hat-storage/ocs-operator/services/provider/api/v4 => ./se
require (
github.com/RHsyseng/operator-utils v1.4.13
github.com/blang/semver/v4 v4.0.0
github.com/ceph/ceph-csi-operator/api v0.0.0-20240812072523-4d50cf3a32a0
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3
github.com/ceph/ceph-csi/api v0.0.0-20240815120002-0eabe32b7634
github.com/go-logr/logr v1.4.2
github.com/google/go-cmp v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4r
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/ceph/ceph-csi-operator/api v0.0.0-20240812072523-4d50cf3a32a0 h1:LIAWGeOu1JzrhknCyD0JbuCUuCuhfiY/H+cBz4nsUcg=
github.com/ceph/ceph-csi-operator/api v0.0.0-20240812072523-4d50cf3a32a0/go.mod h1:odEUoarG26wXBCC2l4O4nMWhAz6VTKr2FRkv9yELgi8=
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3 h1:ft8h5V7BfQqIGJAyiTvn6x86Oi/yMs8yqW7rfKvN9SQ=
github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3/go.mod h1:odEUoarG26wXBCC2l4O4nMWhAz6VTKr2FRkv9yELgi8=
github.com/ceph/ceph-csi/api v0.0.0-20240815120002-0eabe32b7634 h1:d324xJccJ9CmP4EE8DirsDnGh+9VVCLHALW1RtHldwI=
github.com/ceph/ceph-csi/api v0.0.0-20240815120002-0eabe32b7634/go.mod h1:wdTHxRuI5lEeHRgOgOY29Wxd+C29RvvMGHu9nEqV56E=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
Expand Down

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

1 change: 1 addition & 0 deletions rbac/provider-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ rules:
resources:
- cephfilesystemsubvolumegroups
- cephblockpoolradosnamespaces
- cephblockpools
verbs:
- get
- list
Expand Down
48 changes: 42 additions & 6 deletions services/provider/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"encoding/json"
"encoding/pem"
"fmt"
nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
"math"
"net"
"slices"
Expand All @@ -21,7 +22,6 @@ import (
"k8s.io/utils/ptr"

"github.com/blang/semver/v4"
nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
quotav1 "github.com/openshift/api/quota/v1"
routev1 "github.com/openshift/api/route/v1"
opv1a1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
Expand Down Expand Up @@ -62,11 +62,8 @@ const (
ramenDRReplicationIDKey = "ramendr.openshift.io/replicationid"
ramenDRFlattenModeKey = "replication.storage.openshift.io/flatten-mode"
oneGibInBytes = 1024 * 1024 * 1024
)

const (
monConfigMap = "rook-ceph-mon-endpoints"
monSecret = "rook-ceph-mon"
monConfigMap = "rook-ceph-mon-endpoints"
monSecret = "rook-ceph-mon"
)

type OCSProviderServer struct {
Expand Down Expand Up @@ -423,6 +420,45 @@ func (s *OCSProviderServer) getExternalResources(ctx context.Context, consumerRe

}

cbpList := &rookCephv1.CephBlockPoolList{}
err = s.client.List(ctx, cbpList, client.InNamespace(s.namespace))
if err != nil {
return nil, fmt.Errorf("failed to list cephBlockPools in namespace. %v", err)
}
blockPoolMapping := []csiopv1a1.BlockPoolIdPair{}
for i := range cbpList.Items {
cephBlockPool := &cbpList.Items[i]
remoteBlockPoolID := cephBlockPool.GetAnnotations()[util.BlockPoolMirroringTargetIDAnnotation]
if remoteBlockPoolID != "" {
localBlockPoolID := strconv.Itoa(cephBlockPool.Status.PoolID)
blockPoolMapping = append(
blockPoolMapping,
csiopv1a1.BlockPoolIdPair{localBlockPoolID, remoteBlockPoolID},
)
}
}

if len(blockPoolMapping) > 0 {
// This is an assumption and should go away when deprecating the StorageClaim API
// The current proposal is to read the clientProfile name from the storageConsumer status and
// the remote ClientProfile name should be fetched from the GetClientsInfo rpc
clientName := consumerResource.Status.Client.Name
clientProfileName := util.CalculateMD5Hash(fmt.Sprintf("%s-ceph-rbd", clientName))
extR = append(extR, &pb.ExternalResource{
Name: consumerResource.Status.Client.Name,
Kind: "ClientProfileMapping",
Data: mustMarshal(&csiopv1a1.ClientProfileMappingSpec{
Mappings: []csiopv1a1.MappingsSpec{
{
LocalClientProfile: clientProfileName,
RemoteClientProfile: clientProfileName,
BlockPoolIdMapping: blockPoolMapping,
},
},
}),
})
}

// Fetch noobaa remote secret and management address and append to extResources
consumerName := consumerResource.Name
noobaaOperatorSecret := &v1.Secret{}
Expand Down

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

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

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ github.com/blang/semver/v4
# github.com/cenkalti/backoff/v4 v4.3.0
## explicit; go 1.18
github.com/cenkalti/backoff/v4
# github.com/ceph/ceph-csi-operator/api v0.0.0-20240812072523-4d50cf3a32a0
# github.com/ceph/ceph-csi-operator/api v0.0.0-20241114115439-f325f74205d3
## explicit; go 1.22.0
github.com/ceph/ceph-csi-operator/api/v1alpha1
# github.com/ceph/ceph-csi/api v0.0.0-20240815120002-0eabe32b7634
Expand Down
Loading