Skip to content

Conversation

@N-o-Z
Copy link
Member

@N-o-Z N-o-Z commented Dec 8, 2025

Closes #9747

Change Description

Background

Support async operations in lakectl with fallback

Testing Details

Verified backwards and forwards compatibility with existing tests

Breaking Change?

No

@N-o-Z N-o-Z requested a review from a team December 8, 2025 20:01
@N-o-Z N-o-Z self-assigned this Dec 8, 2025
@N-o-Z N-o-Z added area/lakectl Issues related to lakeFS' command line interface (lakectl) exclude-changelog PR description should not be included in next release changelog labels Dec 8, 2025
Copy link
Contributor

@itaigilo itaigilo left a comment

Choose a reason for hiding this comment

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

Looking good.

The only thing is, you wrote:

Verified backwards and forwards compatibility with existing tests

How about testing the added functionality?
No tests added?


const (
initialInterval = 1 * time.Second // initial interval for exponential backoff
MaxInterval = 10 * time.Second // max interval for exponential backoff
Copy link
Contributor

Choose a reason for hiding this comment

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

maxInterval?

DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK)
if resp.JSON200 == nil {
Die("Bad response from server", 1)
// # try asynchronous merge first
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// # try asynchronous merge first
// try asynchronous merge first

err error
)

// # try asynchronous commit first
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// # try asynchronous commit first
// try asynchronous commit first

@N-o-Z
Copy link
Member Author

N-o-Z commented Dec 10, 2025

Looking good.

The only thing is, you wrote:

Verified backwards and forwards compatibility with existing tests

How about testing the added functionality? No tests added?

Whatever we can test here is already covered in existing tests

Copy link
Contributor

@zubron zubron left a comment

Choose a reason for hiding this comment

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

Just a few minor comments, but otherwise looks good!

}
var (
commit *apigen.Commit
err error
Copy link
Contributor

Choose a reason for hiding this comment

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

This pre-declaration of err can be removed since we assign directly below.

}
var result *apigen.MergeResult
taskID := startResp.JSON202.Id
err := pollAsyncOperationStatus(ctx, taskID, "commit", func() (*apigen.AsyncTaskStatus, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/commit/merge

Copy link
Contributor

Choose a reason for hiding this comment

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

this comment is regarding the operation should be "merge" right?

ctx := cmd.Context()
var (
ref string
err error
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Contributor

@Annaseli Annaseli left a comment

Choose a reason for hiding this comment

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

Almost finished reviewing

resp, err := client.CommitWithResponse(cmd.Context(), branchURI.Repository, branchURI.Ref, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{
Message: message,
Metadata: &metadata,
body := apigen.CommitJSONRequestBody{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you wrapping it with apigen.CommitJSONRequestBody?

When calling client.CommitAsyncWithResponse, the body is already wrapped using apigen.CommitAsyncJSONRequestBody.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure I understand the question.
I'm using this body for both sync and async operations.
Since the are of different types with the same underlying type I need to cast it one way or another.
In this case I'm using apigen.CommitJSONRequestBody and casting it to apigen.CommitAsyncJSONRequestBody in the async request

Copy link
Contributor

Choose a reason for hiding this comment

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

added this comment because i was thinkung that we should only have the apigen.CommitAsyncJSONRequestBody without the apigen.CommitJSONRequestBody because they both rely on the CommitCreation struct


defaultPollInterval = 3 * time.Second // default interval while pulling tasks status
minimumPollInterval = time.Second // minimum interval while pulling tasks status
defaultPollTimeout = time.Hour // default expiry for pull status with no update
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn’t one hour too long? For example, on the server I used a 20-minute timeout, as Barak suggested.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no timeout on the client side. This is a parameter that was moved from a different file and is being used by another command

Copy link
Contributor

Choose a reason for hiding this comment

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

so in this PR you are not planning to add to the client timeout, right? since last time we talked about it you said we need to add timeout to the client

Copy link
Member Author

Choose a reason for hiding this comment

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

No - we don't need a timeout. Once we have a cancel operation user will simply break execution to cancel the operation

// TODO (niro): We will need to implement timeout and cancel logic here
func pollAsyncOperationStatus(ctx context.Context, taskID string, operation string, cb asyncStatusCallback) error {
var bo backoff.BackOff = backoff.NewExponentialBackOff(
backoff.WithInitialInterval(initialInterval), backoff.WithMaxInterval(maxInterval)) // No timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

So you won’t be using the defaultPollTimeout parameter you defined for handling the timeout here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not defined, just moved


type StatusResponse struct {
Completed bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you use it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not used - removed

@N-o-Z N-o-Z requested a review from itaigilo December 10, 2025 18:25
if resp.JSON200 == nil {
Die("Bad response from server", 1)
// try asynchronous merge first
startResp, err := client.MergeIntoBranchAsyncWithResponse(ctx, destinationRef.Repository, sourceRef.Ref, destinationRef.Ref, apigen.MergeIntoBranchAsyncJSONRequestBody(body))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as in the commit regarding the body

}
var result *apigen.MergeResult
taskID := startResp.JSON202.Id
err := pollAsyncOperationStatus(ctx, taskID, "commit", func() (*apigen.AsyncTaskStatus, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment is regarding the operation should be "merge" right?

Result: resp.JSON200,
Result: &apigen.MergeResult{
Reference: ref,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

In the commit you pass the commit var you created as the result but here you create the &apigen.MergeResult{} struct - maybe we should align them?

@N-o-Z N-o-Z requested a review from Annaseli December 10, 2025 18:48
Copy link
Contributor

@Annaseli Annaseli left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/lakectl Issues related to lakeFS' command line interface (lakectl) exclude-changelog PR description should not be included in next release changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Async commit and merge: lakectl

4 participants