Skip to content

nfs: admin APIs for managing nfs exports#655

Merged
mergify[bot] merged 10 commits intoceph:masterfrom
phlogistonjohn:jjm-nfs-exports
Apr 6, 2022
Merged

nfs: admin APIs for managing nfs exports#655
mergify[bot] merged 10 commits intoceph:masterfrom
phlogistonjohn:jjm-nfs-exports

Conversation

@phlogistonjohn
Copy link
Collaborator

@phlogistonjohn phlogistonjohn commented Feb 23, 2022

The initial set of APIs are mostly in place, but the tests are untested.

Fixes: #628

Checklist

  • Added tests for features and functional changes
  • Public functions and types are documented
  • Standard formatting is applied to Go code
  • Is this a new API? Is this new API marked PREVIEW?

@phlogistonjohn phlogistonjohn force-pushed the jjm-nfs-exports branch 2 times, most recently from 817e299 to 45961b6 Compare February 23, 2022 15:29
Comment on lines +126 to +142
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())
}
Copy link

@BlaineEXE BlaineEXE Feb 23, 2022

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment on lines +141 to +152
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)
}
})

Choose a reason for hiding this comment

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

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. I can add an explicit case for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All set.

@phlogistonjohn phlogistonjohn force-pushed the jjm-nfs-exports branch 2 times, most recently from 20c85f5 to 62ecb4b Compare February 23, 2022 20:33
@nixpanic
Copy link
Member

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.

nixpanic added a commit to nixpanic/ceph-csi that referenced this pull request Mar 30, 2022
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>
@phlogistonjohn
Copy link
Collaborator Author

@nixpanic @BlaineEXE @ansiwen - based on some chats & verbal discussions this week, I've added a special build tag ceph_ci_untested that will allow us to leave have the source code for this in our tree but not be enabled by default or tested by the CI. The ceph-csi team can then try/test it manually by setting this build tag w/o go-ceph team "making promises" about this API to the other code bases that consume go-ceph.

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.

@phlogistonjohn
Copy link
Collaborator Author

CCing @Rakshith-R as well. See my previous comment, please.

@nixpanic
Copy link
Member

nixpanic commented Apr 1, 2022

If we're generally all good with the above, and CI passes I'll move this PR out of draft state.

👍 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 ceph command (which also changed in 16.2.7).

@phlogistonjohn
Copy link
Collaborator Author

If we're generally all good with the above, and CI passes I'll move this PR out of draft state.

+1 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 ceph command (which also changed in 16.2.7).

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.

@phlogistonjohn phlogistonjohn marked this pull request as ready for review April 1, 2022 14:43
@phlogistonjohn phlogistonjohn requested a review from ansiwen April 1, 2022 14:43
@phlogistonjohn phlogistonjohn changed the title [WIP] nfs: admin APIs for managing nfs exports nfs: admin APIs for managing nfs exports Apr 1, 2022
@phlogistonjohn
Copy link
Collaborator Author

@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.

@nixpanic
Copy link
Member

nixpanic commented Apr 4, 2022

@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?

nixpanic added a commit to nixpanic/ceph-csi that referenced this pull request Apr 4, 2022
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>
nixpanic added a commit to nixpanic/ceph-csi that referenced this pull request Apr 4, 2022
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>
@phlogistonjohn
Copy link
Collaborator Author

@ansiwen please review when you have a moment, thanks!

@ansiwen ansiwen added API This PR includes a change to the public API of a go-ceph package do-not-merge labels Apr 6, 2022
Copy link
Collaborator

@ansiwen ansiwen left a comment

Choose a reason for hiding this comment

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

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.

@mergify mergify bot merged commit 50f803d into ceph:master Apr 6, 2022
nixpanic added a commit to nixpanic/ceph-csi that referenced this pull request Apr 12, 2022
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>
nixpanic added a commit to nixpanic/ceph-csi that referenced this pull request Apr 14, 2022
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>
mergify bot pushed a commit to ceph/ceph-csi that referenced this pull request Apr 14, 2022
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>
mergify bot pushed a commit to ceph/ceph-csi that referenced this pull request Apr 14, 2022
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)
ceph-csi-bot pushed a commit to ceph/ceph-csi that referenced this pull request Apr 15, 2022
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)
mergify bot pushed a commit to ceph/ceph-csi that referenced this pull request Apr 15, 2022
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)
@phlogistonjohn phlogistonjohn deleted the jjm-nfs-exports branch June 9, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API This PR includes a change to the public API of a go-ceph package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NFS: feature: NFS Export management API

4 participants