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

🎁 Source embedded hack scripts #222

Merged
merged 13 commits into from
Sep 6, 2023

Conversation

cardil
Copy link
Contributor

@cardil cardil commented Sep 7, 2022

Changes

  • 🎁 Source embedded hack scripts

/kind enhancement

Fixes #221

@knative-prow
Copy link

knative-prow bot commented Sep 7, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added kind/enhancement do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 7, 2022
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 8, 2022
@cardil cardil force-pushed the feature/source-embedded-hacks branch 2 times, most recently from d2dbbfd to 663e630 Compare September 8, 2022 19:23
Signed-off-by: Chris Suszyński <ksuszyns@redhat.com>
@cardil cardil force-pushed the feature/source-embedded-hacks branch from 663e630 to 4a77e40 Compare September 8, 2022 19:33
@cardil
Copy link
Contributor Author

cardil commented Sep 8, 2022

/test all

@cardil
Copy link
Contributor Author

cardil commented Sep 9, 2022

This works pretty well, as can be seen in example usage PR: knative-extensions/kn-plugin-event#220. See example build 1568204500513067008.

I have some doubts:

  1. The extracted files are not getting removed when the scripts end. On a developer's box, this might be a nuisance. After a while, people would have a large amount of hack scripts extracted to their /tmp directory. I wonder, is that a problem? It's straightforward to clean up - rm -rf /tmp/knative.*.
  2. The hack scripts are getting extracted to ARTIFACTS subdirectory. So, the scripts get saved as Prow build artifacts. Maybe better would be to save them to an unrelated temp directory. Or, perhaps we like to save them there, to allow for easier debugging. IDK.
  3. I think it would be a good idea to set --verbose flag automatically on Prow build. This could be a follow-up, OFC.

/assign @kvmware
/assign @upodroid
/cc @mgencur

@knative-prow knative-prow bot requested a review from mgencur September 9, 2022 12:07
@cardil cardil marked this pull request as ready for review September 9, 2022 12:07
@cardil cardil changed the title [WIP] 🎁 Source embedded hack scripts 🎁 Source embedded hack scripts Sep 9, 2022
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 9, 2022
@krsna-m
Copy link
Contributor

krsna-m commented Sep 9, 2022

I have some doubts:

  1. I don't like the idea of lingering files. I think a tmp directory that won't be used normally should be used so that you can rm -rf <dir_name> each pass to ensure that we are working with a clean env.
  2. I think that should be a flag. Normally adding to artifacts is not desirable imo, but I see the case of someone wanting to debug and passing a flag to include them.

@cardil
Copy link
Contributor Author

cardil commented Sep 9, 2022

Re @kvmware:

  1. I don't like the idea of lingering files. I think a tmp directory that won't be used normally should be used so that you can rm -rf <dir_name> each pass to ensure that we are working with a clean env.

I don't like untidy programming as well. The problem is that it's hard to know, is it safe already to delete those files. We execute those scripts in all kinds of different ways. We might try adding some trap to remove files at EXIT signal, but it might backfire in some cases.

The other thing is that, most of the runs are leaving report files either way. Personally, I often use export ARTIFACTS=/tmp/knative-junk before doing any development, so everything is contained in a single "junk" folder. That's easy to clean up afterwards.

Also, /tmp should be cleared with reboot, and those hack scripts are only a couple KiB in size. People would need to run literally millions of times, without reboot, to have real impact on a modern laptop drive.

  1. I think that should be a flag. Normally adding to artifacts is not desirable imo, but I see the case of someone wanting to debug and passing a flag to include them.

Fair enough. This sounds like a good idea to follow up in separate PR, later.

@krsna-m
Copy link
Contributor

krsna-m commented Sep 9, 2022

lgtm with followup pr/issue for discussed above.

@upodroid
Copy link
Member

upodroid commented Sep 9, 2022

lgtm

can you try and do some thing like /tmp/HASH/knative and delete /tmp/HASH/knative after each run ?

@krsna-m
Copy link
Contributor

krsna-m commented Sep 9, 2022

lgtm

can you try and do some thing like /tmp/HASH/knative and delete /tmp/HASH/knative after each run ?

Something like that would be desirable and would be fulfil the ask I had here: I don't like the idea of lingering files. I think a tmp directory that won't be used normally should be used so that you can rm -rf <dir_name> each pass to ensure that we are working with a clean env.

@cardil
Copy link
Contributor Author

cardil commented Sep 13, 2022

lgtm

can you try and do some thing like /tmp/HASH/knative and delete /tmp/HASH/knative after each run ?

Let me repeat once again. The problem is that it's hard to know, is it safe already to delete those files. We execute those scripts in all kinds of different ways.

When we delete those files at EXIT, they might be read by the parent script even when we push the scripts to a unique folder each source time.

Also, even if that is not the case currently, people could easily introduce such erroneous behavior in the future. And that would be very hard to figure out.

@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2022
@cardil cardil force-pushed the feature/source-embedded-hacks branch from 2bae62a to cb0b65c Compare November 3, 2022 13:47
@cardil
Copy link
Contributor Author

cardil commented Nov 3, 2022

✋ This PR should be ready for re-review.

I changed:

  • The extract directory to be static, so subsequent calls just extract the scripts to the same dir. No cleaning is needed, I think.
  • There's automatic verbose mode when running on CI (Prow, Jenkins)
  • Tests are using the script extract from the same code (all other repos will use full path: knative.dev/hack/cmd/script)

@krsna-m
Copy link
Contributor

krsna-m commented Nov 15, 2022

lgtm 👍

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2022
@cardil cardil mentioned this pull request Mar 14, 2023
17 tasks
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 4, 2023
@cardil cardil force-pushed the feature/source-embedded-hacks branch from 01daf18 to 1f57234 Compare September 4, 2023 19:32
@cardil
Copy link
Contributor Author

cardil commented Sep 4, 2023

I'd like to test this before merging

/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 4, 2023
@cardil
Copy link
Contributor Author

cardil commented Sep 6, 2023

The testing PR knative-extensions/kn-plugin-event#307 works well. We can go ahead with merging this.

/hold cancel

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 6, 2023
Copy link
Member

@upodroid upodroid left a comment

Choose a reason for hiding this comment

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

LGTM

Thank you for working on this.

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 6, 2023
@knative-prow
Copy link

knative-prow bot commented Sep 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cardil, upodroid

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

@knative-prow knative-prow bot merged commit f63d16e into knative:main Sep 6, 2023
15 checks passed
@cardil cardil deleted the feature/source-embedded-hacks branch September 6, 2023 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hacks needs to be sourced without the vendor directory
4 participants