Skip to content

Conversation

@hermanschaaf
Copy link
Member

@hermanschaaf hermanschaaf commented Jan 27, 2023

Right now, if a plugin is hosted in anywhere on the cloudquery org, it can only be downloaded if it is part of the cloudquery/cloudquery monorepo. This makes it impossible to temporarily host cq-source-* type plugins as other cloudquery repos, as can be done with community plugins on other orgs.

This changes the download logic to first check the monorepo, but fall back to the community standard of cq-source-* if it's A) cloudquery org and B) the monorepo download attempt resulted in a 404. If both fail with 404, the attempt is aborted. Other status codes are retried.

It would have been better if we could know, somehow, when a plugin is hosted in the monorepo or outside it, but right now this is not possible unless we change the spec in some way.

This change allows us to use the CLI to download https://github.com/cloudquery/cq-source-simple-analytics

@github-actions github-actions bot added feat and removed feat labels Jan 27, 2023
@github-actions
Copy link

github-actions bot commented Jan 27, 2023

⏱️ Benchmark results

Comparing with 5a97453

  • DefaultConcurrencyDFS-2 resources/s: 9,414 ⬇️ 24.08% decrease vs. 5a97453
  • DefaultConcurrencyRoundRobin-2 resources/s: 12,391 ⬇️ 0.12% decrease vs. 5a97453
  • Glob-2 ns/op: 283.6 ⬆️ 33.85% increase vs. 5a97453
  • TablesWithChildrenDFS-2 resources/s: 27,061 ⬇️ 4.75% decrease vs. 5a97453
  • TablesWithChildrenRoundRobin-2 resources/s: 23,736 ⬇️ 24.13% decrease vs. 5a97453
  • TablesWithRateLimitingDFS-2 resources/s: 28.39 ⬇️ 0.32% decrease vs. 5a97453
  • TablesWithRateLimitingRoundRobin-2 resources/s: 837.4 ⬆️ 1.97% increase vs. 5a97453
  • BufferedScanner-2 ns/op: 11.97 ⬆️ 21.61% increase vs. 5a97453
  • LogReader-2 ns/op: 40.26 ⬆️ 23.03% increase vs. 5a97453

resp.Body.Close()
return i, nil
}
time.Sleep(RetryWaitTime)
Copy link
Member

@disq disq Jan 27, 2023

Choose a reason for hiding this comment

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

Why not keep retry logic as-is and just don't retry on 404? Also with the logic above, looks like for each retry URLs would start from index 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Until now we have retried on 404s, so I wanted to keep that behavior the same. But maybe we shouldn't 🤷 Though 404s can happen for other reasons, like the plugin version still being in the process of being published. So with this updated logic things are exactly the same as before, but if it's the cloudquery repo we also check the secondary url on 404 before sleeping for the next try.

Copy link
Member

@erezrokah erezrokah Jan 29, 2023

Choose a reason for hiding this comment

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

The retry logic was added due to #291 (503 GitHub errors).
I don't think we've seen other error codes so I think we don't need to retry on 404

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the context @erezrokah, I'll update this to not retry on 404s, but fall back if there are more urls to try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated 👍 I also added an integration test that tries out the various cases

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2023

Codecov Report

Base: 46.73% // Head: 47.15% // Increases project coverage by +0.42% 🎉

Coverage data is based on head (fffe9b1) compared to base (5a97453).
Patch coverage: 76.27% of modified lines in pull request are covered.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #632      +/-   ##
==========================================
+ Coverage   46.73%   47.15%   +0.42%     
==========================================
  Files          69       70       +1     
  Lines        6591     6721     +130     
==========================================
+ Hits         3080     3169      +89     
- Misses       3078     3106      +28     
- Partials      433      446      +13     
Impacted Files Coverage Δ
registry/download.go 68.46% <76.27%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions github-actions bot added feat and removed feat labels Jan 31, 2023
@kodiakhq kodiakhq bot merged commit 9e1501e into main Jan 31, 2023
@kodiakhq kodiakhq bot deleted the download-from-alternative-urls branch January 31, 2023 09:44
kodiakhq bot pushed a commit that referenced this pull request Feb 1, 2023
🤖 I have created a release *beep* *boop*
---


## [1.33.0](v1.32.0...v1.33.0) (2023-02-01)


### Features

* Support downloading plugins from other cloudquery repos ([#632](#632)) ([9e1501e](9e1501e))


### Bug Fixes

* **deps:** Update golang.org/x/exp digest to f062dba ([#641](#641)) ([c6ec154](c6ec154))
* **deps:** Update google.golang.org/genproto digest to 1c01626 ([#642](#642)) ([fc9f338](fc9f338))
* **deps:** Update module github.com/avast/retry-go/v4 to v4.3.2 ([#643](#643)) ([2f6a2e8](2f6a2e8))
* **deps:** Update module github.com/getsentry/sentry-go to v0.17.0 ([#644](#644)) ([fb33f8c](fb33f8c))
* **deps:** Update module github.com/rs/zerolog to v1.29.0 ([#645](#645)) ([e864963](e864963))
* **deps:** Update module github.com/schollz/progressbar/v3 to v3.13.0 ([#646](#646)) ([c2146d3](c2146d3))
* **deps:** Update module golang.org/x/net to v0.5.0 ([#647](#647)) ([417c99d](417c99d))
* **deps:** Update module golang.org/x/text to v0.6.0 ([#649](#649)) ([a91c7dc](a91c7dc))
* **deps:** Update module google.golang.org/grpc to v1.52.3 ([#650](#650)) ([48d96ee](48d96ee))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
@erezrokah
Copy link
Member

Opened #655 as a follow up as I'm not sure the current URL logic for community plugins is what we want

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants