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

rbd: add functions to parse json in mirroring status description field #842

Merged
merged 4 commits into from
Mar 17, 2023

Conversation

phlogistonjohn
Copy link
Collaborator

Fixes: #841

Add UnmarshalDescriptionJSON method to SiteMirrorImageStatus
Add DescriptionReplayStatus method to SiteMirrorImageStatus

Both these functions are meant to help extract the JSON object that is some times appended to the Description field in the SiteMirrorImageStatus struct. I have only seen the JSON appear after "replaying, " but there's little docs for this and I skimmed to code to even find out what fields the JSON might include. As such, the UnmarshalDescriptionJSON tries to unmarshal the appended JSON into an object the caller provides in case skimming the code was insufficient or the caller has other needs. For most cases, DescriptionReplayStatus can be used to parse the JSON into a struct containing known fields.

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? Added a new file that begins with //go:build ceph_preview
  • Ran make api-update to record new APIs

New or infrequent contributors may want to review the go-ceph Developer's Guide including the section on how we track API Status and the API Stability Plan.

The go-ceph project uses mergify. View the mergify command guide for information on how to interact with mergify. Add a comment with @Mergifyio rebase to rebase your PR when github indicates that the PR is out of date with the base branch.

@phlogistonjohn
Copy link
Collaborator Author

@yati1998 here's a draft PR for issue #841 the api extensions to get rbd snapshot mirroring stats to the API. If you think this is sufficient for the needs of csi-addons please let me know and I will move the PR to reviewable state and request reviews. If I hear no feedback for about a week or so I'll just request reviews anyway. Thanks!

@yati1998
Copy link

yati1998 commented Mar 8, 2023

Yeah, that should be fine. Thank you @phlogistonjohn

@phlogistonjohn phlogistonjohn marked this pull request as ready for review March 8, 2023 21:10
Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

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

See below for few comments.

rbd/mirror_desc_status_test.go Show resolved Hide resolved
rbd/mirror_desc_status.go Show resolved Hide resolved
rbd/mirror_desc_status_test.go Outdated Show resolved Hide resolved
rbd/mirror_test.go Show resolved Hide resolved
rbd/mirror_test.go Show resolved Hide resolved
Add UnmarshalDescriptionJSON method to SiteMirrorImageStatus
Add DescriptionReplayStatus method to SiteMirrorImageStatus

Both these functions are meant to help extract the JSON object that is
some times appended to the Description field in the
SiteMirrorImageStatus struct. I have only seen the JSON appear after
"replaying, " but there's little docs for this and I skimmed to code to
even find out what fields the JSON might include.  As such, the
UnmarshalDescriptionJSON tries to unmarshal the appended JSON into an
object the caller provides in case skimming the code was insufficient or
the caller has other needs. For most cases, DescriptionReplayStatus can
be used to parse the JSON into a struct containing known fields.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Add unit and simplistic functional tests for new JSON/status description
extraction functions.  Because these are preview functions we also add a
stub file to add a no-op function to be built on non-preview builds.
This avoids having to reimplement large parts of the existing mirroring
tests just to validate this small aspect of the SiteMirrorImageStatus
struct.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Signed-off-by: John Mulligan <jmulligan@redhat.com>
It is doubtful that these Print(f)s have been useful to any one for a
long time.  Remove them.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@anoopcs9 anoopcs9 added the API This PR includes a change to the public API of a go-ceph package label Mar 17, 2023
Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

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

Thanks.

if end == -1 {
return "", ErrNotExist
}
if start >= end {
Copy link
Collaborator

Choose a reason for hiding this comment

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

cannot be equal. ;-) (not a serious comment.)

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.

LGTM

@mergify mergify bot merged commit 1feedf3 into ceph:master Mar 17, 2023
@phlogistonjohn phlogistonjohn deleted the jjm-rdb-desc-status branch April 3, 2023 20:27
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.

rbd: expose more image mirroring stats to the api
4 participants