Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CP-45795: Decompress compressed trace files without Forkexecd #6293

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

snwoods
Copy link
Contributor

@snwoods snwoods commented Feb 11, 2025

This allows an xs_trace.exe to be run on any linux machine, whereas previously the use of forkexecd meant that it had to be run on a XS host. It also allows the logic to be simplified (json and ndjson can be handled in the same way).

@snwoods snwoods force-pushed the private/stevenwo/CP-45795 branch from 5dd6cf6 to 69bb471 Compare February 11, 2025 15:09
Copy link
Contributor

@contificate contificate left a comment

Choose a reason for hiding this comment

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

May be worth including a \n on the error message.

@psafont
Copy link
Member

psafont commented Feb 11, 2025

I'd rather wait for the changes in forkexec to be merged rather than special-casing this one case.

@snwoods
Copy link
Contributor Author

snwoods commented Feb 11, 2025

I'd rather wait for the changes in forkexec to be merged rather than special-casing this one case.

Ah, good point, I'd forgotten about that...

@snwoods snwoods closed this Feb 11, 2025
@snwoods
Copy link
Contributor Author

snwoods commented Feb 12, 2025

Reopening as discussed in the standup: as xs_trace needs to be portable, it would be best to remove the dependency on forkexec and the dependencies used in the new PR e.g. vfork.

@snwoods snwoods reopened this Feb 12, 2025
@snwoods snwoods force-pushed the private/stevenwo/CP-45795 branch from 69bb471 to a106203 Compare February 12, 2025 12:32
| Unix.WEXITED 0 ->
()
| _ ->
Printf.eprintf "File %s exited with non-zero\n" path
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to use open_process_args_in as this is currently a string that is interpreted by the shell and that always has the risks of funny problems with spaces in names and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't quite understand the difference between the two. I thought I should just be able to change it to:
let ic = Unix.open_process_args_in "zstdcat" [|path|] in
but it gives the error stdin is a console, aborting when the original code does not have this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Even the documentation says Unix.open_process_args_in is a safe replacement. I assume that stdin is handled differently by the shell (underlying open_proess and zstdcat. What stdin does the error even refer to?

Copy link
Contributor

Choose a reason for hiding this comment

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

Where is ic closed?

Copy link
Contributor

Choose a reason for hiding this comment

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

You will need to satisfy the convention that argv[0] is the program's name/path when using Unix.open_process_args_in. The usual convention is:

let args = [|"zstdcat"; ...|] in
let ic = Unix.open_process_args_in args.(0) args in
...

The error you're getting is the same as if you just executed zstdcat with no user-supplied arguments from a shell:

~ zstdcat
stdin is a console, aborting

Copy link
Contributor Author

@snwoods snwoods Feb 14, 2025

Choose a reason for hiding this comment

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

Where is ic closed?

It's closed on line 41 match Unix.close_process_in ic with

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You will need to satisfy the convention that argv[0] is the program's name/path

Ahhh of course. I even read that statement but I think I glossed over it because I'm obviously passing the process name already, but it needs to be in args too! So it's assuming my first arg (path) is the name and therefore I haven't provided any filenames...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the change is now understood; can we change this and merge then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry, I wanted to test the change first and Jaeger was experiencing unrelated flakiness. Tried again now and it's all good 👍

@edwintorok edwintorok added this pull request to the merge queue Feb 17, 2025
@lindig lindig removed this pull request from the merge queue due to a manual request Feb 17, 2025
@lindig
Copy link
Contributor

lindig commented Feb 17, 2025

I stopped this from being merged. We want this to use array-based arguments as discussed.

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

Please use open_process_args_in where the 0th argument needs to be the name of the binary.

@snwoods snwoods force-pushed the private/stevenwo/CP-45795 branch from a106203 to 903d8f0 Compare February 17, 2025 17:02
@lindig
Copy link
Contributor

lindig commented Feb 19, 2025

The DCO checks fails - so need an update @snwoods

This allows an xs_trace.exe to be run on any linux machine, whereas
previously the use of forkexecd meant that it had to be run on a XS host.

Signed-off-by: Steven Woods <steven.woods@citrix.com>
@snwoods snwoods force-pushed the private/stevenwo/CP-45795 branch from 903d8f0 to c608902 Compare February 20, 2025 07:26
@lindig lindig added this pull request to the merge queue Feb 20, 2025
Merged via the queue into xapi-project:master with commit f146978 Feb 20, 2025
15 checks passed
@snwoods snwoods deleted the private/stevenwo/CP-45795 branch February 20, 2025 10:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants