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

Fixes podman-remote save to directories does not work #10025

Merged

Conversation

zhangguanzhang
Copy link
Collaborator

Fixes: #9742
Signed-off-by: zhangguanzhang [email protected]

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zhangguanzhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2021
@@ -244,6 +244,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) {
decoder := r.Context().Value("decoder").(*schema.Decoder)
query := struct {
Compress bool `schema:"compress"`
Remote bool `schema:"remote"`
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed. It is Remote by definition?

// client will unArchive after receive the archive file
// so must convert is at here
if query.Remote {
if query.Format == define.OCIManifestDir {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to just do this on the client side and not change the server side at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Server will save to dir, not respone in on file.and client will untar the archive file

Copy link
Member

Choose a reason for hiding this comment

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

I am saying that the client checks to see if it is remote and sends across the

	query.Format = define.OCIArchive
             or
	query.Format = define.V2s2Archive

And then dumps it locally.

Copy link
Collaborator Author

@zhangguanzhang zhangguanzhang Apr 15, 2021

Choose a reason for hiding this comment

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

I am saying that the client checks to see if it is remote and sends across the

	query.Format = define.OCIArchive
             or
	query.Format = define.V2s2Archive

And then dumps it locally.

if format is an archive, will return at these lines (end at L279)

exErr := images.Export(ir.ClientCtx, append([]string{nameOrID}, tags...), f, options)
if err := f.Close(); err != nil {
return err
}
if exErr != nil {
return exErr
}
if opts.Format != "oci-dir" && opts.Format != "docker-dir" {
return nil
}

if is a dir, will recreive an archive of the dir, and untar at this line
return utils2.UntarToFileSystem(opts.Output, f, nil)

The logic already exists, so I don’t need to add it

@@ -143,6 +143,7 @@ func Export(ctx context.Context, nameOrIDs []string, w io.Writer, options *Expor
for _, ref := range nameOrIDs {
params.Add("references", ref)
}
params.Add("remote", "true")
Copy link
Member

Choose a reason for hiding this comment

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

This parameter shouldn't be needed as it's always remote.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I remove all the remote parameter in all files?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, yes please remove it.

@zhangguanzhang zhangguanzhang force-pushed the remote-save-dir branch 2 times, most recently from 97229a1 to 0ad20f7 Compare April 15, 2021 08:12
}
if query.Format == define.V2s2ManifestDir {
query.Format = define.V2s2Archive
}
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking: a switch query.Format {...} may be more idiomatic.

LGTM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

had done

@TomSweeneyRedHat
Copy link
Member

LGTM
and happy test buttons

@rhatdan
Copy link
Member

rhatdan commented Apr 17, 2021

Someone will have to explain to me why this is being done on the server side? Seems like the client knows what it is doing, and the server is not doing what the caller requested. If I write a python client and ask for a directory, I will not have the majic available to convert, and will end up with a mess. Or am I missing something?

@zhangguanzhang
Copy link
Collaborator Author

Someone will have to explain to me why this is being done on the server side? Seems like the client knows what it is doing, and the server is not doing what the caller requested. If I write a python client and ask for a directory, I will not have the majic available to convert, and will end up with a mess. Or am I missing something?

server side always return file bytes in one file:

rdr, err := os.Open(output)
if err != nil {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "failed to read the exported tarfile"))
return
}
defer rdr.Close()
utils.WriteResponse(w, http.StatusOK, rdr)

@rhatdan
Copy link
Member

rhatdan commented Apr 19, 2021

Well outvoted and it does fix a bug, so merging.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 19, 2021
@openshift-merge-robot openshift-merge-robot merged commit a917bae into containers:master Apr 19, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman-remote save to directories does not work
6 participants