-
Notifications
You must be signed in to change notification settings - Fork 16
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
Lvol snapshot management of User Created flag #106
Conversation
Longhorn 7578 Signed-off-by: Damiano Cipriani <[email protected]>
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.
The UserCreated
flag modification LGTM.
But the vendor update introduced xattrs SnapshotTime
as well. We need to add it for ReplicaSnapshotCreate
so that one snapshot has the same timestamp among all replicas. Besides, for snapshots, the creation time should be loaded from the xattrs instead.
Yes, I agree with you. We will make the development for SnapshotTimestamp in another PR, now let's merge this one so we can update longhorn-instance-manager and close the UserCreated issue. |
pkg/spdk/engine.go
Outdated
return err | ||
} | ||
|
||
func (e *Engine) snapshotOperation(spdkClient *spdkclient.Client, inputSnapshotName string, snapshotOp SnapshotOperationType) (snapshotName string, err error) { | ||
func (e *Engine) snapshotOperation(spdkClient *spdkclient.Client, inputSnapshotName string, snapshotOp SnapshotOperationType, opts util.SnapshotOptions) (snapshotName string, err error) { |
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.
Suggest just use opts *SnapshotOptions
to prevent unnecessary obj copy. This suggestion is for all changed methods.
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.
Done
pkg/spdk/replica.go
Outdated
@@ -835,6 +847,9 @@ func (r *Replica) SnapshotCreate(spdkClient *spdkclient.Client, snapshotName str | |||
return nil, fmt.Errorf("zero or multiple snap lvols with UUID %s found after lvol snapshot", snapUUID) | |||
} | |||
|
|||
if userCreatedFlag { | |||
bdevLvolList[0].DriverSpecific.Lvol.Xattrs[spdkclient.UserCreated] = "true" | |||
} |
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.
Why do we need this? This should be implemented in BdevLvolGet
already.
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.
Done
pkg/util/util.go
Outdated
@@ -22,6 +22,10 @@ import ( | |||
"github.com/longhorn/go-common-libs/proc" | |||
) | |||
|
|||
type SnapshotOptions struct { | |||
UserCreated bool | |||
} |
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.
Suggest moving this to pkg/spdk/typges.go
instead? Adding this to a common util package seems not intuitive to me.
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.
Done
pkg/spdk/server.go
Outdated
UserCreated: req.UserCreated, | ||
} | ||
|
||
snapshotName, err := e.SnapshotCreate(spdkClient, req.SnapshotName, opts) |
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.
Why don't we use the same way for both replica and engine snapshot call? The engine call is using an option struct, but the replica call is just using a bool parameter.
return r.SnapshotCreate(spdkClient, req.SnapshotName, req.UserCreated)
Can we just make them consistent?
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.
Done
@@ -1427,7 +1440,7 @@ func (r *Replica) RebuildingDstSnapshotCreate(spdkClient *spdkclient.Client, sna | |||
}() | |||
|
|||
snapLvolName := GetReplicaSnapshotLvolName(r.Name, snapshotName) | |||
snapUUID, err := spdkClient.BdevLvolSnapshot(r.rebuildingLvol.UUID, snapLvolName) | |||
snapUUID, err := spdkClient.BdevLvolSnapshot(r.rebuildingLvol.UUID, snapLvolName, nil) |
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.
We should add opts
for this API input then put it here.
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.
Remember to update this.
This API will be invoked by the engine rebuilding here. The engine should check the flag of each snapshot then input the opts
correct for RebuildingDstSnapshotCreate
invocation
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.
Sorry but I don't understand well what you are asking to me. If this API is invoked by the engine during the rebuild, the snapshot is not a user created snapshot ans so there is no necessity to pass opts here.
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.
This function copies all snapshots from a healthy replica to the new replica. If a snapshot was ever requested by users, this snapshot should contain the attribute userCreated: true
for all replicas.
In other words, the tag user created
means if the snapshot CR of the volume is requested by the users themselves. It does not stand for the snapshot file in a specific replica being created by API SnapshotCreate
or rebuilt from other replicas.
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.
Ok thanks, I will add this
Longhorn 7578 Signed-off-by: Damiano Cipriani <[email protected]>
Longhorn 7578 Signed-off-by: Damiano Cipriani <[email protected]>
Codespell is returning the following error: |
Codespell errro is fine. Just skip it. |
So, once you will have resolved the requested changes (I have already addressed all of them), the PR can be merged also with codespell errors? |
Yes. However, we will fix the codespell setting later. |
@@ -1427,7 +1440,7 @@ func (r *Replica) RebuildingDstSnapshotCreate(spdkClient *spdkclient.Client, sna | |||
}() | |||
|
|||
snapLvolName := GetReplicaSnapshotLvolName(r.Name, snapshotName) | |||
snapUUID, err := spdkClient.BdevLvolSnapshot(r.rebuildingLvol.UUID, snapLvolName) | |||
snapUUID, err := spdkClient.BdevLvolSnapshot(r.rebuildingLvol.UUID, snapLvolName, nil) |
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.
Remember to update this.
This API will be invoked by the engine rebuilding here. The engine should check the flag of each snapshot then input the opts
correct for RebuildingDstSnapshotCreate
invocation
@DamiaSan is this PR ready? |
This pull request is now in conflict. Could you fix it @DamiaSan? 🙏 |
I am going to close this PR and will make a new one. |
Which issue(s) this PR fixes:
Issue #7578
What this PR does / why we need it:
Special notes for your reviewer:
Additional documentation or context