GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Respect proxy settings when streaming the download and extraction of the CodeQL bundle by NlightNFotis · Pull Request #2624 · github/codeql-action

Conversation

@NlightNFotis

@NlightNFotis NlightNFotis commented Nov 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description

This PR is adding support for respecting proxy settings while downloading the CodeQL bundle in streaming mode.

Fixes #2600

Guidance

  • The code changes required to support the feature have been added in 0dc76a9.
  • It's introducing a justfile, which is a script interpreted by https://github.com/casey/just, a command action runner. It allows us to create an python virtual environment and run the sync.py to update dependencies in one step, which is very useful for someone trying to interact with it the first time.
    • If just is not present, the file is irrelevant (it's just a text file) but can act as documentation for the steps to invoke manually.
  • I have initially tested this works locally, by setting tinyproxy and writing a function that invoked downloadAndExtractZstdWithStreaming and observing that we go through the proxy.
    • This function was subsequently thrown away after the first tests locally validated the design.
  • For CI testing, I have made changes to the test_proxy.yml workflow, so that we download the latest nightly bundle, which by default has the extension .tar.zst which goes through the code path introduced.
    • This can be seen working here (latest CI run at the time of writing).
  • This required some changes to the sync.py file in 9c48c8b in order to support a step that is being used to initialise the container image (because the Ubuntu container is leaned out and doesn't come with the list of pre-installed software the runners usually come prepared with).
  • The diff (~31k lines) is mostly comprised of a couple of packages added in 8f2cb3a. The actual code changes introduced by this PR are in the other commits, and are much smaller in terms of loc changed.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@NlightNFotis
NlightNFotis force-pushed the NlightNFotis/detect_use_proxy_when_streaming branch 2 times, most recently from c888d44 to f742d6b Compare December 3, 2024 16:10
aeisenberg
aeisenberg reviewed Dec 3, 2024
View reviewed changes
Comment thread src/tools-download.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@NlightNFotis
NlightNFotis force-pushed the NlightNFotis/detect_use_proxy_when_streaming branch from 326b0f1 to 28dd147 Compare December 3, 2024 17:06
@NlightNFotis

NlightNFotis commented Dec 4, 2024

Copy link
Copy Markdown
Contributor Author

The streaming of the bundle using the Proxy worked fine in the last CI run: https://github.com/github/codeql-action/actions/runs/12146133664/job/33869336618?pr=2624#step:7:33

I'm now in the process of tidying this up (lots of experimental commits), and incorporating conflicting changes from main.

aeisenberg reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NlightNFotis
NlightNFotis force-pushed the NlightNFotis/detect_use_proxy_when_streaming branch 3 times, most recently from 99f0c0d to 2ff0598 Compare December 4, 2024 18:32
NlightNFotis added 3 commits December 4, 2024 19:29
@NlightNFotis
feat: use http agent that respects environment proxy settings when st…
0dc76a9
…reaming
@NlightNFotis
build: add undici to node_modules folder - CI fails without it
8f2cb3a
@NlightNFotis
ci: add configuration tto run proxy with zstd package to test streami…
78be2f1
…ng with proxy
@NlightNFotis
NlightNFotis force-pushed the NlightNFotis/detect_use_proxy_when_streaming branch from 2ff0598 to 78be2f1 Compare December 4, 2024 19:29
aeisenberg
aeisenberg reviewed Dec 4, 2024
View reviewed changes
Comment thread pr-checks/test-proxy.patch Resolved

Uh oh!

There was an error while loading. Please reload this page.

NlightNFotis added 2 commits December 5, 2024 15:32
@NlightNFotis
ci: add capability to handle container initialisation steps to sync.py
9c48c8b
@NlightNFotis
ci: remove patch file and cleanup justfile
b4bc093
@NlightNFotis
NlightNFotis marked this pull request as ready for review December 5, 2024 17:00
@NlightNFotis
NlightNFotis requested a review from a team as a code owner December 5, 2024 17:00
@NlightNFotis
NlightNFotis requested review from aeisenberg, henrymercer and zutshisunakshi December 5, 2024 17:00
@NlightNFotis NlightNFotis changed the title feat: detect and adjust CodeQL bundle download URL if proxy settings present Respect proxy settings when streaming the download and extraction of the CodeQL bundle Dec 5, 2024
@NlightNFotis
chore: add changelog entry
b706e37
@NlightNFotis NlightNFotis self-assigned this Dec 5, 2024
@NlightNFotis

NlightNFotis commented Dec 5, 2024

Copy link
Copy Markdown
Contributor Author

Something that I forgot to mention: this PR is not removing the feature flag: there are 2 references in the code (after this PR gets merged) which are very easy to remove and do not impact functionality.

There are also two more references in a couple of test actions, which would require a bit more thought as to how to handle (we could just remove the environment variable reference in them, or just delete them given that this is more or less tested in the new test_proxy workflow).

I wanted to do any changes to the feature flag/env var as a different PR, and keep the changes here scoped down to the proxy settings and their handling by the streaming download handler.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

henrymercer
henrymercer reviewed Dec 5, 2024
View reviewed changes

@henrymercer henrymercer left a comment

Copy link
Copy Markdown
Contributor

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.

Thanks for this fix! I've added a couple of questions / suggestions:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread CHANGELOG.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/test-proxy.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/test-proxy.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/checks/test-proxy.yml
@@ -1,10 +1,20 @@
name: "Proxy test"
description: "Tests using a proxy specified by the https_proxy environment variable"
versions: ["linked"]
versions: ["linked", "nightly-latest"]

@henrymercer henrymercer Dec 5, 2024

Copy link
Copy Markdown
Contributor

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 test was passing before when we were streaming zstd bundles with a CodeQL Action version that wasn't respecting proxy settings, presumably because the CodeQL Action could still access the bundle without the proxy.

Can we update the test to ensure that we're downloading the bundle via the proxy?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

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.

In the latest test added as part of this PR, I'm fairly confident we're downloading the bundle through the proxy.

The reason it worked before is that it didn't test the streaming of the bundle, because when linked is passed as the version, the prepare-step action was choosing the .tar.gz bundle by default - as example the latest run from a PR merged recently.

I am not sure though how it makes that selection between the .tar.gz and the .tar.zst one, because in this PR, the same job downloaded the .tar.zst one. But previously, we didn't go through this code because the same job was opting for the .tar.gz when downloading.

Will look more into that and report back any interesting findings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

henrymercer reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Comment thread src/tools-download.ts Outdated
Comment on lines +127 to +128
core.warning(
`Failed to download and extract CodeQL bundle using streaming. Falling back to downloading the bundle before extracting.`,

@henrymercer henrymercer Dec 5, 2024

Copy link
Copy Markdown
Contributor

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.

Have you tested this fallback? For instance, what happens if we partially extract the CodeQL bundle while streaming, but something goes wrong? Is it worth cleaning up the destination directory in this case or is that handled elsewhere?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 6, 2024

Copy link
Copy Markdown
Contributor Author

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.

Yes, I'm quoting from a previous message of mine that probably got lost because of the volume of messages here:

I'm confident we are good without a flag to manage the risk.

To explain why: because the conflicts introduced by a couple of other PRs were extensive, and I couldn't sort out a clean commit history, I opted to instead just manually recreate the PR on top of main (my code changes are small, so easy to manually replay).

In doing so, I made a mistake: I initialised the HTTP client (the one that respects the proxy settings) and passed it to the headers by accident (instead of the http.get options). What happened is here, but short story, because of the streaming download now being inside of a fallback try/catch, the failure to download the CodeQL pack with streaming resulted in falling back to downloading it and then extracting it.

I've since fixed this, but this little mistake validated the fallback mechanism working as intended, so I believe that this won't cause an incident like last time - if it fails, worst case scenario is that the mechanism won't work as expected and fall back to the previous mechanism (download and then extract), with the impact being that we lose a few seconds per run (compared to a failed run).

Does this answer your question satisfactorily?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@henrymercer henrymercer Dec 9, 2024

Copy link
Copy Markdown
Contributor

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.

Thank you, that answers the first part of my question. I still wonder if it is worth cleaning up the destination directory as part of the catch in case we managed to extract some of the CodeQL bundle but not a complete CodeQL bundle.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

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.

I agree this is a good idea, and something prudent for us to do before we retry.

Added in 4c20d4f.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
aeisenberg
aeisenberg reviewed Dec 5, 2024
View reviewed changes
Comment thread pr-checks/checks/test-proxy.yml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pr-checks/justfile Resolved

Uh oh!

There was an error while loading. Please reload this page.

NlightNFotis and others added 4 commits December 6, 2024 18:37
@NlightNFotis @henrymercer
chore: reword description in CHANGELOG.md
182c5e7
Co-authored-by: Henry Mercer <[email protected]>
@NlightNFotis
docs: add readme for justfile/pr-checks update
a89fbc8
@NlightNFotis
ci: remove dns for container running proxy steps (experimental)
c901aee
@NlightNFotis
Merge branch 'main' into NlightNFotis/detect_use_proxy_when_streaming
3951a82
NlightNFotis added 2 commits December 9, 2024 18:59
@NlightNFotis
docs: add documentation for the reason why we need to have a setup st…
51e71f8
…ep for the container
@NlightNFotis
feat: cleanup destination directory if we fail during streaming of th…
4c20d4f
…e extraction
@NlightNFotis

NlightNFotis commented Dec 9, 2024

Copy link
Copy Markdown
Contributor Author

Thank you for your reviews @aeisenberg @henrymercer.

I have now implemented all outstanding items on this PR. Would it be possible to have another look at this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aeisenberg
aeisenberg reviewed Dec 9, 2024
View reviewed changes
Comment thread CHANGELOG.md
- We are rolling out a change in December 2024 that will extract the CodeQL bundle directly to the toolcache to improve performance. [#2631](https://github.com/github/codeql-action/pull/2631)
- We have added support for respecting the proxy settings present in environment variables in a runner when streaming the download and extraction of the CodeQL bundle. [#2624](https://github.com/github/codeql-action/pull/2624)
- Fixed an issue where streaming the download and extraction of the CodeQL bundle did not respect proxy settings. [#2624](https://github.com/github/codeql-action/pull/2624)
- Update default CodeQL bundle version to 2.20.0. [#2636](https://github.com/github/codeql-action/pull/2636)

@aeisenberg aeisenberg Dec 9, 2024

Copy link
Copy Markdown
Contributor

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.

Was this line added due to a bad merge?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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.

Hm, I will have a look.

This was reported as a conflict in the GitHub UI, but when I did a git merge locally, it had no problem automatically resolving the conflict. Perhaps it did a weird thing because of my .gitconfig.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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.

I cannot find precisely what went wrong here, as the merge log is past my terminal character limit. I remember it saying that it resolved it automatically using the ort method, but it apparently went wrong there.

This is now fixed in 9e8cd42.

Going forward I will be more careful validating these merges went right.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/tools-download.ts Outdated

@aeisenberg aeisenberg Dec 9, 2024

Copy link
Copy Markdown
Contributor

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.

Don't prefix a warning with Error.

Suggested change
core.warning(`Error: ${getErrorMessage(e)}`);
core.warning(`Warning: ${getErrorMessage(e)}`);

But, do we even need the prefix at all?

Maybe reverting this is better:

Suggested change
core.warning(`Error: ${getErrorMessage(e)}`);
core.warning(getErrorMessage(e));

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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.

Thank you for catching this.

Seeing it reported now, I agree it looks a bit silly.

My rationale for changing this was that this was rendering an error that was generated in the process of unpacking as a simple warning, with no other context whatsoever, which could be confusing to a user when interpreting the runner log (example).

I'm still motivated to decorate it somehow, as reverting may not satisfy this concern, but I will think about a cleaner decoration that doesn't look weird/silly.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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.

Okay, this is what I came up with: 88bcf64

I've reworded the warnings to flow a bit more naturally for me, and to allow me to embed the error message in an indicative but non-invasive way.

Is this workable for you @aeisenberg ? Or do you have a strong preference for the previous state of affairs?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pr-checks/readme.md Outdated

@aeisenberg aeisenberg Dec 9, 2024

Copy link
Copy Markdown
Contributor

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.

I think we can simplify this. I can give some suggestions, but not quite right now.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@aeisenberg aeisenberg Dec 9, 2024

Copy link
Copy Markdown
Contributor

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.

See here for an alternative readme: https://github.com/github/codeql-action/compare/NlightNFotis/detect_use_proxy_when_streaming...aeisenberg/justfile-readme?quick_pull=1#diff-b90d48e45a6813fad7195d74075f05bdf05919291a02116fe8a6b67691b1266a

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@NlightNFotis NlightNFotis Dec 11, 2024

Copy link
Copy Markdown
Contributor Author

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.

Thank you for this! I agree it looks cleaner.

Will cherry-pick this in.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@henrymercer
Merge branch 'main' into NlightNFotis/detect_use_proxy_when_streaming
c6454d5
@henrymercer

henrymercer commented Dec 10, 2024

Copy link
Copy Markdown
Contributor

I've merged in main since we just did a release, and I want to make sure the merge strategy puts the changelog entry in the right place.

NlightNFotis reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aeisenberg and others added 4 commits December 11, 2024 11:27
@aeisenberg @NlightNFotis
Update PR checks readme instructions
9323695
@NlightNFotis
feat: change wording of error reporting when a failure occurs during …
88bcf64
…extraction
@NlightNFotis
fix: move changelog entry to appropriate place
9e8cd42
@NlightNFotis
Merge branch 'main' into NlightNFotis/detect_use_proxy_when_streaming
1e5b591
aeisenberg
aeisenberg approved these changes Dec 11, 2024
View reviewed changes

@aeisenberg aeisenberg left a comment

Copy link
Copy Markdown
Contributor

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.

Nice.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NlightNFotis reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@NlightNFotis
NlightNFotis merged commit c4bbe15 into main Dec 11, 2024
@NlightNFotis
NlightNFotis deleted the NlightNFotis/detect_use_proxy_when_streaming branch December 11, 2024 16:26
This was referenced Dec 12, 2024
Merge main into releases/v3 #2645
Merged
Merge releases/v3 into releases/v2 #2647
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@henrymercer henrymercer henrymercer left review comments
@aeisenberg aeisenberg aeisenberg approved these changes
@zutshisunakshi zutshisunakshi Awaiting requested review from zutshisunakshi

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@NlightNFotis NlightNFotis

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Enable streaming while respecting proxy settings

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@NlightNFotis @henrymercer @aeisenberg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.