-
Notifications
You must be signed in to change notification settings - Fork 251
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
Conversation
649020a
to
a4adb28
Compare
@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! |
Yeah, that should be fine. Thank you @phlogistonjohn |
There was a problem hiding this 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.
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>
a4adb28
to
0139940
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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
//go:build ceph_preview
make api-update
to record new APIsNew 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.