Skip to content

Add lastsyncbytes and lastsyncduration to vol rep status#366

Merged
mergify[bot] merged 4 commits into
csi-addons:mainfrom
yati1998:volrepstatus
Jun 22, 2023
Merged

Add lastsyncbytes and lastsyncduration to vol rep status#366
mergify[bot] merged 4 commits into
csi-addons:mainfrom
yati1998:volrepstatus

Conversation

@yati1998

Copy link
Copy Markdown
Contributor

This PR adds lastsyncbytes and lastsyncduration to volume replication status and generates updated crds.
Also it adds the logic to update the status in the volume replication object.

@mergify mergify Bot requested review from Rakshith-R and nixpanic June 12, 2023 11:47
@mergify mergify Bot added the vendor Pull requests that update vendored dependencies label Jun 12, 2023

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please add controller and sidecar changes too (in same pr) and (keep it in draft) / open it for review when completed ?

LastStartTime *metav1.Time `json:"lastStartTime,omitempty"`
LastCompletionTime *metav1.Time `json:"lastCompletionTime,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
LastSyncBytes int64 `json:"lastSyncBytes,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
LastSyncBytes int64 `json:"lastSyncBytes,omitempty"`
LastSyncBytes *int64 `json:"lastSyncBytes,omitempty"`

This should be a pointer since it is a optional parameter,

@nixpanic nixpanic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the duration.proto file should probably be moved to the commit where it is imported.

format: int64
type: integer
lastSyncDuration:
format: date-time

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this really date-time? is there not a duration format, there is no date in this, I think?

@nixpanic

Copy link
Copy Markdown
Member

@yati1998 make sure to install protoc v3.19.6, or do not commit the changes in the version of the .proto files.

There is also a crd generation issue, it seems that the duration can not have a format: date-time.

@yati1998

Copy link
Copy Markdown
Contributor Author

@yati1998 make sure to install protoc v3.19.6, or do not commit the changes in the version of the .proto files.

There is also a crd generation issue, it seems that the duration can not have a format: date-time.

yeah sure, I am testing with changes, once it is successful, I will update all.

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc v3.19.6

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You are using an old version to re-generate these files, please use protoc v3.19.6

@yati1998 yati1998 force-pushed the volrepstatus branch 4 times, most recently from 37b2062 to 5f45cec Compare June 21, 2023 11:22
@yati1998 yati1998 requested review from Rakshith-R and nixpanic June 21, 2023 11:33
@yati1998

Copy link
Copy Markdown
Contributor Author

Working on to revert the protobuf version issue, meanwhile please do review the PR.
cc @nixpanic @Rakshith-R @Madhu-1

nixpanic
nixpanic previously approved these changes Jun 21, 2023
Comment on lines +227 to +228
LastSyncDuration: lastsyncduration,
LastSyncBytes: lastsyncbytes,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

instead of new variables you can directly use resp.GetLastSyncDuration() and resp.GetLastSyncBytes() here

@yati1998 yati1998 requested review from Madhu-1 and nixpanic June 21, 2023 15:50
@mergify mergify Bot dismissed nixpanic’s stale review June 21, 2023 15:54

Pull request has been modified.

@yati1998

Copy link
Copy Markdown
Contributor Author

@nixpanic and @Madhu-1 can you please revisit it again.

Comment on lines +210 to +221
// This field is OPTIONAL.
.google.protobuf.Duration last_sync_duration = 2;
// This field is OPTIONAL.
// A value of 0 is equal to an unspecified field value.
// The value of this field MUST NOT be negative.
int64 last_sync_bytes = 3;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure to match the comments with csi-addons spec or close to it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This has to be edited in spec then, cause it's required to clear it here, will send another PR to update spec comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant to update it here.

Comment on lines +383 to +393
td := info.GetLastSyncDuration()
if td != nil {
lastSyncDuration := metav1.Duration{Duration: td.AsDuration()}
instance.Status.LastSyncDuration = &lastSyncDuration
}
tb := info.GetLastSyncBytes()
if tb != 0 {
instance.Status.LastSyncBytes = &tb
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fields should be explicitly set to nil to indicate missing value.
otherwise, they may inherit values that were previously set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure about this, considering the corner case where lastsynctime retains its value and on requeue other values will be nil. Will verify this once and update if it's fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On line 91 (wow, what a horrible long function this is?!) instance is fetched, so it will have a .Status.LastSyncBytes from the previous reconcile. If there were 0 bytes in the last sync, the information would not be correct in the object. So yes, setting it explicitly to an initial value is probably a good thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Rakshith-R @nixpanic IMO we should not set this to nil explicitly #366 (comment)

This commit adds lastsyncbytes and lastsyncduration
to volume replication status and generates updated crds.

Signed-off-by: yati1998 <ypadia@redhat.com>
@yati1998

Copy link
Copy Markdown
Contributor Author

Addressed the changes, @Rakshith-R @nixpanic

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

a small nit

Comment thread internal/proto/replication.proto Outdated
Comment on lines +211 to +212
// last_sync_duration states the time taken to sync
// to execute the last sync operation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// last_sync_duration states the time taken to sync
// to execute the last sync operation.
// last_sync_duration represents the time taken
// to execute the last sync operation.

yati1998 added 3 commits June 22, 2023 14:45
This commit updates the getvolumereplicationinfo
rpc to include lastsyncbytes and lastsyncduration.

Signed-off-by: yati1998 <ypadia@redhat.com>
This commit updates the vendor directory to
include lastest spec.

Signed-off-by: yati1998 <ypadia@redhat.com>
This commit updates the reconcile logic to
get more info and update the volrep status.

Signed-off-by: yati1998 <ypadia@redhat.com>

@Rakshith-R Rakshith-R left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks !

Comment on lines +383 to +384
instance.Status.LastSyncDuration = nil
instance.Status.LastSyncBytes = nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i dont think you should make this nil. You should preserve the last data because you already have lastSyncTime, Duration, Byte to give to complete sync information.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i dont think you should make this nil. You should preserve the last data because you already have lastSyncTime, Duration, Byte to give to complete sync information.

@Madhu-1 ,
We'll reach this point only when csi driver gives us a valid new lastSyncTime.

It'll be incorrect to keep previous duration and bytes data with new lastSyncTime according to me.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

okay, just read the code, LGTM

@mergify mergify Bot merged commit ee9403c into csi-addons:main Jun 22, 2023
Nikhil-Ladha pushed a commit to Nikhil-Ladha/kubernetes-csi-addons that referenced this pull request Jan 6, 2026
Syncing latest changes from upstream main for kubernetes-csi-addons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vendor Pull requests that update vendored dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replication: add lastsyncbytes and lastsyncduration to volumereplication object

4 participants