nfs: admin APIs for managing nfs exports#655
Conversation
817e299 to
45961b6
Compare
| const delSucc = "Successfully deleted export" | ||
|
|
||
| // RemoveExport will remove an NFS export based on the pseudo-path of the export. | ||
| // PREVIEW | ||
| // | ||
| // Similar To: | ||
| // ceph nfs export rm | ||
| func (nfsa *Admin) RemoveExport(clusterID, pseudoPath string) error { | ||
| m := map[string]string{ | ||
| "prefix": "nfs export rm", | ||
| "format": "json", | ||
| "cluster_id": clusterID, | ||
| "pseudo_path": pseudoPath, | ||
| } | ||
| return (commands.MarshalMgrCommand(nfsa.conn, m). | ||
| FilterBodyPrefix(delSucc).NoData().End()) | ||
| } |
There was a problem hiding this comment.
Is this looking for text in the response from Ceph (delSucc)? How is that different from getting a return code? Could this be broken if the NFS code changes this message?
Since this might apply to Rook as well, (and assuming I'm on the right track) how does go-ceph handle things like this where ceph changes might break integration?
There was a problem hiding this comment.
Yes it is coming from the ceph mgr module for nfs. Normally on success we expect either a json object in the body to parse and return to the caller OR nothing. Unfortunately, the mgr module returns this "helpful" string in this case. If future versions of ceph change the response string (prefix) it could cause a problem. If it stops returning the "helpful" string, its fine as we "want" no body. Note that we are not checking for that string, just filtering it out if it appears.
Unfortunately, I don't think there's a general way to future proof all the things ceph could change in the future, But if things do change we'd need to release a new version that handles all those versions.
| t.Run("filterBodyPrefix", func(t *testing.T) { | ||
| rtemp := Response{ | ||
| body: []byte("No way, no how"), | ||
| } | ||
| if assert.True(t, rtemp.Ok()) { | ||
| r2 := rtemp.FilterBodyPrefix("No way") | ||
| assert.True(t, r2.Ok()) | ||
| assert.Equal(t, []byte(""), r2.body) | ||
| err := r2.NoBody().End() | ||
| assert.NoError(t, err) | ||
| } | ||
| }) |
There was a problem hiding this comment.
Should there be an additional test that validates the negative case where the body is not filtered? Or is that somehow implicit from the above tests?
There was a problem hiding this comment.
Sure. I can add an explicit case for that.
20c85f5 to
62ecb4b
Compare
62ecb4b to
3dfea74
Compare
|
Just noting that ceph/ceph-csi#2948 could use this API. We might be able to test it out with a custom build of the (work-in-progress) NFS provisioner. |
The NFS-Admin API is not part of go-ceph yet, it has been proposed as an enhancement. This vendors the contents of the PR, which should be replaced once the PR has been merged. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This call is used for removing "routine" responses that get sent in the body of a response rather than the status. Otherwise, it is the same as the FilterPrefix function. Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This will provide APIs for managing NFS exports via the Ceph NFS manager module. Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
* Add CreateCephFSExport method * Add RemoveExport method * Add ListDetailedExports method * Add ExportInfo method Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Our test container does not support an orchestrator to pre configure the ".nfs" configuration pool for us. This is something that rook and cephadm are expected to do before exports are created, etc. So we support creating a minimal "mock" configuration in rados. This option can be toggled on and off via the GO_CEPH_TEST_MOCK_NFS env var. Turning it off can be useful if you want to run the live suite against a "real" ceph cluster. Signed-off-by: John Mulligan <jmulligan@redhat.com>
I found this useful when debugging the mock nfs configuration pool and the nfs mgr module. Signed-off-by: John Mulligan <jmulligan@redhat.com>
3dfea74 to
513dcff
Compare
|
@nixpanic @BlaineEXE @ansiwen - based on some chats & verbal discussions this week, I've added a special build tag Once ceph pacific has the necessary patches I will remove the special build tag and enable the code as a "normal" preview API. If ceph pacific releases soon enough I can simply do that before our release in approx. 2 weeks. If I learn ceph pacific is going to release around mid-april, I'm willing to delay the release - but only by a week or so. Otherwise, if ceph pacific doesn't release until late April or later we'll probably just release with this feature gated by this build tag. Any questions/comments/concerns? If we're generally all good with the above, and CI passes I'll move this PR out of draft state. |
|
CCing @Rakshith-R as well. See my previous comment, please. |
👍 Thanks, I'm happy with that! Unfortunately the new API does not work with Ceph 16.2.0, but is seems to be fine for 16.2.7 and newer. In case of failure with the API, Ceph-CSI will probably fall-back to the old |
OK, I do wish ceph wouldn't make "API" changes on the mgr within major version release... but it happens and we have to deal with it. If you needed it I'd consider adding code to work with older versions IF it was something we could add tests for. But that would almost certainly not happen until after the next release. |
|
@nixpanic github is being rather weird and not letting me add you to the reviewers. I'll try again later, but feel free to review anyway. |
It seems I am not part of the maintainers for go-ceph anymore? |
The NFS-Admin API is not part of go-ceph yet, it has been proposed as an enhancement. This vendors the contents of the PR, which should be replaced once the PR has been merged. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
The NFS-Admin API is not part of go-ceph yet, it has been proposed as an enhancement. This vendors the contents of the PR, which should be replaced once the PR has been merged. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
|
@ansiwen please review when you have a moment, thanks! |
ansiwen
left a comment
There was a problem hiding this comment.
In general LGTM. There are some comments, but if you prefer to merge like this, I'm fine with it. Then just remove the do-not-merge label.
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com>
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com> (cherry picked from commit 282c33c)
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com> (cherry picked from commit 282c33c)
The NFS-Admin API has been added to go-ceph v0.15.0. As the API can not be tested in the go-ceph CI, it requires build-tag `ceph_ci_untested`. This additional build-tag has been added to the `Makefile` and should be removed when the API does not require the build-tag anymore. See-also: ceph/go-ceph#655 Signed-off-by: Niels de Vos <ndevos@redhat.com> (cherry picked from commit 282c33c)
The initial set of APIs are mostly in place, but the tests are untested.
Fixes: #628
Checklist