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

radosnamespace: add new CRD #9733

Merged
merged 1 commit into from Apr 5, 2022
Merged

radosnamespace: add new CRD #9733

merged 1 commit into from Apr 5, 2022

Conversation

Madhu-1
Copy link
Member

@Madhu-1 Madhu-1 commented Feb 14, 2022

Description of your changes:
This introduces a new CRD to add the ability to create a rados namespace for a given ceph block pool. Typically the name of the pool is the name of the block pool created by the rook.

Signed-off-by: Madhu Rajanna madhupr007@gmail.com

Which issue is resolved by this Pull Request:
Resolves #7035

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

@Madhu-1 Madhu-1 added the do-not-merge DO NOT MERGE :) label Feb 14, 2022
@Madhu-1
Copy link
Member Author

Madhu-1 commented Feb 14, 2022

@leseb @travisn this is ready for initial review. added DNM as am still testing the changes

@Madhu-1 Madhu-1 force-pushed the fix-7035 branch 2 times, most recently from 5c628cc to 44860b9 Compare February 14, 2022 07:28
Copy link
Contributor

@subhamkrai subhamkrai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits

pkg/daemon/ceph/client/radosnamespace.go Outdated Show resolved Hide resolved
pkg/operator/ceph/pool/dependents.go Outdated Show resolved Hide resolved
@Madhu-1 Madhu-1 force-pushed the fix-7035 branch 2 times, most recently from f04b3f2 to d921888 Compare February 14, 2022 07:45
@Madhu-1 Madhu-1 removed the do-not-merge DO NOT MERGE :) label Feb 14, 2022
@Madhu-1 Madhu-1 force-pushed the fix-7035 branch 2 times, most recently from 964bf40 to 6fe3d73 Compare February 14, 2022 08:11
@Madhu-1
Copy link
Member Author

Madhu-1 commented Feb 14, 2022

Removed DNM as my manual testing works fine.

[🎩︎]mrajanna@fedora rook $]kuberc gekuberc get cephblockpoolradosnamespace -oyaml
apiVersion: v1
items:
- apiVersion: ceph.rook.io/v1
  kind: CephBlockPoolRadosNamespace
  metadata:
    creationTimestamp: "2022-02-14T07:55:43Z"
    finalizers:
    - cephblockpoolradosnamespace.ceph.rook.io
    generation: 1
    name: namespace-a
    namespace: rook-ceph
    resourceVersion: "116578"
    uid: f3a5dd75-4fc2-4cc1-bdd9-71eb08673cc8
  spec:
    blockpoolName: replicapool
  status:
    info:
      clusterID: 80fc4f4bacc064be641633e6ed25ba7e
    phase: Ready
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
[🎩︎]mrajanna@fedora rook $]kuberc get cm
NAME                           DATA   AGE
kube-root-ca.crt               1      4d2h
rook-ceph-csi-config           1      4d2h
rook-ceph-csi-mapping-config   1      4d2h
rook-ceph-mon-endpoints        4      4d2h
rook-ceph-operator-config      18     4d2h
rook-ceph-pdbstatemap          2      4d2h
rook-config-override           1      4d2h
[🎩︎]mrajanna@fedora rook $]kuberc get cm rook-ceph-csi-config -oyaml
apiVersion: v1
data:
  csi-cluster-config-json: '[{"clusterID":"rook-ceph","monitors":["10.104.250.35:6789"]},{"clusterID":"4df0bb6e1b7ddc0c1ea080cbe043dd1a","monitors":["10.104.250.35:6789"],"cephFS":{"subvolumeGroup":"group-a"}},{"clusterID":"80fc4f4bacc064be641633e6ed25ba7e","monitors":["10.104.250.35:6789"],"radosNamespace":"namespace-a"}]'
kind: ConfigMap
metadata:
  creationTimestamp: "2022-02-10T05:13:47Z"
  name: rook-ceph-csi-config
  namespace: rook-ceph
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: false
    controller: true
    kind: Deployment
    name: rook-ceph-operator
    uid: 795ddb4f-33f9-4617-be83-1a3373df725e
  resourceVersion: "116577"
  uid: 81ce4b71-1383-4320-933e-ad5e9ac036ea
[🎩︎]mrajanna@fedora rook $]kuberc deleterc delete -f deploy/examples/radosnamespace.yaml 
cephblockpoolradosnamespace.ceph.rook.io "namespace-a" deleted
[🎩︎]mrajanna@fedora rook $]kuberc delete -fget cm rook-ceph-csi-config -oyaml
apiVersion: v1
data:
  csi-cluster-config-json: '[{"clusterID":"rook-ceph","monitors":["10.104.250.35:6789"]},{"clusterID":"4df0bb6e1b7ddc0c1ea080cbe043dd1a","monitors":["10.104.250.35:6789"],"cephFS":{"subvolumeGroup":"group-a"}}]'
kind: ConfigMap
metadata:
  creationTimestamp: "2022-02-10T05:13:47Z"
  name: rook-ceph-csi-config
  namespace: rook-ceph
  ownerReferences:
  - apiVersion: apps/v1
    blockOwnerDeletion: false
    controller: true
    kind: Deployment
    name: rook-ceph-operator
    uid: 795ddb4f-33f9-4617-be83-1a3373df725e
  resourceVersion: "116777"
  uid: 81ce4b71-1383-4320-933e-ad5e9ac036ea

@Madhu-1 Madhu-1 force-pushed the fix-7035 branch 2 times, most recently from c2a01c0 to e2fc574 Compare February 14, 2022 09:33
@Madhu-1 Madhu-1 added the ceph main ceph tag label Feb 14, 2022
Documentation/ceph-pool-radosnamespace.md Outdated Show resolved Hide resolved
deploy/examples/radosnamespace.yaml Outdated Show resolved Hide resolved
pkg/apis/ceph.rook.io/v1/types.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/client/radosnamespace.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/client/radosnamespace.go Outdated Show resolved Hide resolved
pkg/operator/ceph/pool/radosnamespace/controller.go Outdated Show resolved Hide resolved
})
}

func Test_buildClusterID(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not needed if we move the function to opcontroller

@@ -30,6 +30,7 @@
"rgw",
"security",
"subvolumegroup",
"radosnamespace",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we keep it simpler for the prefix?

Suggested change
"radosnamespace",
"rados",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the concept is related to radosnamespace in a pool can this be kept as radosnamespace only?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might even just call it namespace, this will better match the latest proposed crd name. This is just a commit prefix so shorter is fine.

deploy/examples/radosnamespace.yaml Show resolved Hide resolved
deploy/examples/radosnamespace.yaml Outdated Show resolved Hide resolved
pkg/daemon/ceph/client/radosnamespace.go Outdated Show resolved Hide resolved
pkg/daemon/ceph/client/radosnamespace.go Outdated Show resolved Hide resolved
pkg/operator/ceph/pool/dependents.go Show resolved Hide resolved
Rook allows creation of Ceph BlockPool
[RadosNamespaces](https://docs.ceph.com/en/latest/man/8/rbd/) through the
custom resource definitions (CRDs). BlockPool Rados Namespace is an abstraction
for a block pool. For more information about BlockPool and namespace refer to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for a block pool. For more information about BlockPool and namespace refer to
for a Ceph RADOS namespace. For more information about BlockPool and namespace refer to

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an abstraction for a block pool. we can have N number of rados namespaces in a pool.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this?

Suggested change
for a block pool. For more information about BlockPool and namespace refer to
inside a block pool. For more information about BlockPool and namespace refer to

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good 👍

Documentation/ceph-pool-radosnamespace.md Show resolved Hide resolved
@@ -0,0 +1,44 @@
---
title: RadosNamespace CRD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of its own topic, what if we just added a new section to ceph-pool-crd.md? This really seems like a detail related to the block pools so it doesn't need its own topic. This would be similar to the object multisite page that lists the three related CRDs for multisite. See ceph-object-multisite-crd.md.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the pattern followed when we added subvolumegroup CRD, we have a new document for subvolumegroups https://rook.io/docs/rook/v1.8/ceph-fs-subvolumegroup.html, if we expand the CRD and add more details to radosnamespace CRD or the pool CRD the file content might grow. if required I can change this and add it to pool CRD section,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the subvolumegroup doc could likewise be merged with the filesystem CRD doc. @leseb wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will wait for @leseb response or I can do a follow-up PR for both filesystem and namespace doc.

Documentation/ceph-pool-radosnamespace.md Outdated Show resolved Hide resolved
deploy/olm/assemble/metadata-common.yaml Outdated Show resolved Hide resolved
pkg/operator/ceph/pool/dependents.go Show resolved Hide resolved
Comment on lines 287 to 306
cephBlockPoolRadosNamespace := &cephv1.CephBlockPoolRadosNamespace{}
if err := client.Get(r.opManagerContext, name, cephBlockPoolRadosNamespace); err != nil {
if kerrors.IsNotFound(err) {
logger.Debug("CephBlockPoolRadosNamespace resource not found. Ignoring since object must be deleted.")
return
}
logger.Warningf("failed to retrieve ceph blockpool rados namespace %q to update status to %q. %v", name, status, err)
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do this before calling updateStatus. Can't we just pass that same object here and issue an update?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be possible. @leseb any thoughts on this one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get is there to make sure we fetch the latest version of the object before updating it. I have a PR I'll rebase on top of this, to use a better pattern: #9686

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it problematic to update status on latest version even before operator reconciles it? retryOnConflict makes it easier to try updating the same object version that the operator reconciled.

@Madhu-1 Madhu-1 force-pushed the fix-7035 branch 2 times, most recently from d119e82 to 90471ed Compare February 16, 2022 15:29
Documentation/ceph-pool-radosnamespace.md Show resolved Hide resolved
@@ -0,0 +1,44 @@
---
title: RadosNamespace CRD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Documentation/ceph-pool-radosnamespace.md Show resolved Hide resolved
[RadosNamespaces](https://docs.ceph.com/en/latest/man/8/rbd/) through the
custom resource definitions (CRDs). BlockPool Rados Namespace is an abstraction
inside a block pool. For more information about BlockPool and namespace refer to
the [Ceph docs](https://docs.ceph.com/en/latest/man/8/rbd/).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a sentence that gives an idea why a namespace would be useful or when it should be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure will do it.

tests/scripts/github-action-helper.sh Outdated Show resolved Hide resolved
if: failure() && github.event_name == 'pull_request'
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60
- name: checkout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you adjust your editor's auto-indentation so it doesn't change all these blocks? It's difficult to see the diff, and we don't want it changing all the time between commits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My appologies, I didn't check the latest push, Editor messed it up. fixing it.

}
// Success! Let's update the status
if cephCluster.Spec.External.Enable {
r.updateStatus(r.client, request.NamespacedName, cephv1.ConditionConnected)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a "connected" status for the rados namespace? The cluster CR tracks if there is a connection, but this CR only creates/deletes rados namespaces, right? Seems like it's either created or not, rather than connected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And according to the check above, creating a rados namespace from an external cluster isn't supported. Shouldn't that check just return an error and fail the reconcile? Or what is the purpose in reconciling the rados namespace for an external cluster?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have a "connected" status for the rados namespace? The cluster CR tracks if there is a connection, but this CR only creates/deletes rados namespaces, right? Seems like it's either created or not, rather than connected.

This is the same as the https://github.com/rook/rook/blob/master/pkg/operator/ceph/file/subvolumegroup/controller.go#L265-L272 nothing new in this one. i have seen in other places also cephv1.ConditionType used for status.Phase, just reusing the same here also.

Or what is the purpose in reconciling the rados namespace for an external cluster?

This is requested to generate the clusterID which is required for the storageclass creation, the whole idea of supporting external cluster got added in #9694

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leseb What is the need to support subvolume groups or rados namespaces as "connected" status in external mode? It seems like nothing is reconciled in external mode, not sure what external mode is doing here. "connected" just seems like a status for the cluster CR, not other CRs like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The external condition is a bit of a hack/noop to not perform some commands and expect the producer cluster (external) to perform the operation instead.
I tend to agree that we could have avoided the "Connected" state for subvolumegrp CRD and perhaps this one but we need to decide if we keep it for this new controller or change both :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, the controllers don't need to do anything for external clusters for the rados namespaces and subvolume groups, right? In that case I'd vote that we don't support them in external mode and just error out if they are created in an external cluster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they do need to do something on external mode, which is updating the ceph-csi configmap to input the subvolumegroup/namespace crd name cpeh-csi should use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see now where the configmap is updated. I think what would help is just a little code refactor like suggested above so it's more obvious.

return reconcile.Result{}, nil
}

if !cephCluster.Spec.External.Enable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rados namespace behaves so differently for external clusters, how about refactoring this into two methods to handle external or local? The multiple checks for external clusters is confusing to me. Or just error for external clusters as suggested below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the same code pattern used for https://github.com/rook/rook/blob/master/pkg/operator/ceph/file/subvolumegroup/controller.go#L211-L271 if required to separate it out i can do it. please let me know what do you think

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the refactor would really help understand the code flow, something like:

if external cluster {
  // call a helper method to update the configmap
  return
}
// for local clusters create the namespace 
// call helper method to update the configmap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. added help function and did refactoring.

@mergify
Copy link

mergify bot commented Apr 4, 2022

This pull request has merge conflicts that must be resolved before it can be merged. @Madhu-1 please rebase it. https://rook.io/docs/rook/latest/development-flow.html#updating-your-fork

@travisn
Copy link
Member

travisn commented Apr 4, 2022

@Madhu-1 just a simple merge conflict to resolve...

Copy link
Contributor

@subhamkrai subhamkrai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good after the merge conflict resolves.

Copy link
Member

@BlaineEXE BlaineEXE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after merge conflict resolved.

This introduces a new CRD to add the ability
to create rados namespace for a given
ceph block pool. Typically the name of the pool
is the name of the blockpool created by rook.

Closes: rook#7035

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
@Madhu-1
Copy link
Member Author

Madhu-1 commented Apr 5, 2022

@travisn Resolved merge conflicts. PTAL

@travisn travisn merged commit 9b6c0c9 into rook:master Apr 5, 2022
travisn added a commit that referenced this pull request Apr 6, 2022
parth-gr added a commit to parth-gr/rook that referenced this pull request May 9, 2022
THe radosnamespace CRD is already added by
rook#9733,
Checking the external script with the namespace created by
the CRD

Signed-off-by: parth-gr <paarora@redhat.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request May 10, 2022
THe radosnamespace CRD is already added by
rook#9733,
Checking the external script with the namespace created by
the CRD

Signed-off-by: parth-gr <paarora@redhat.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request May 10, 2022
THe radosnamespace CRD is already added by
rook#9733,
Checking the external script with the namespace created by
the CRD

Signed-off-by: parth-gr <paarora@redhat.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request May 10, 2022
THe radosnamespace CRD is already added by
rook#9733,
Checking the external script with the namespace created by
the CRD

Signed-off-by: parth-gr <paarora@redhat.com>
parth-gr added a commit to parth-gr/rook that referenced this pull request May 10, 2022
THe radosnamespace CRD is already added by
rook#9733,
Checking the external script with the namespace created by
the CRD

Signed-off-by: parth-gr <paarora@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ceph main ceph tag
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for RBD namespace creation
7 participants