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

Mark half of the Orchestrators on Staging as 'untrusted' #1064

Merged
merged 2 commits into from
May 17, 2022

Conversation

thomshutt
Copy link
Contributor

@thomshutt thomshutt commented May 17, 2022

What does this pull request do? Explain your changes. (required)

When a new flag is passed, mark 50% of the Orchestrators as "untrusted" to allow us to test Fast Verification on Staging, where there are no community Orchestrators.

Specific updates (required)

  • Add boolean "half-region-orchestrators-untrusted" parameter.
  • Mark every other O as untrusted when this is passed.

How did you test each of these updates (required)

  • Deploying to Staging to test

Does this pull request close any open issues?

No

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@thomshutt thomshutt requested a review from a team as a code owner May 17, 2022 10:46
@vercel
Copy link

vercel bot commented May 17, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
livepeer-com ✅ Ready (Inspect) Visit Preview May 17, 2022 at 3:40PM (UTC)

export async function regionsGetter() {
const [regions, cursor] = await db.region.find({}, { limit: 100 });
export function regionsGetter(halfRegionOrchestratorsUntrusted = false) {
return async function regionsGetter2() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@livepeer/video-user I feel like this is probably not the optimal way, so would appreciate any pointers on how I should be doing it!

Copy link
Member

Choose a reason for hiding this comment

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

I think this works fine! One syntax sugar you could use to make this look a little better would be a lambda function, replacing async function regionsGetter2() { with async () => {. Mostly a stylistic choice anyway.

Another alternative, to avoid this helper function that returns a function (which I find a little confusing sometimes) is to curry the new boolean variable on the call site where you need this function with zero arguments instead. That is, instead of returning a function here you could just make this function receive the boolean and return the regions, and in app-router you do:
orchestratorGetters.push(() => regionsGetter(halfUntrusted...)).

This also fixes the issue of using the return value of this function (another function) when we actually want the final list of regions.

This is a totally optional/stylistic change anyway, only raising the possibility since you were a little concerned about the current version here.

@codecov
Copy link

codecov bot commented May 17, 2022

Codecov Report

Merging #1064 (01dc1ba) into master (6985670) will decrease coverage by 0.01144%.
The diff coverage is 40.00000%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #1064         +/-   ##
===================================================
- Coverage   46.12903%   46.11759%   -0.01145%     
===================================================
  Files             64          64                 
  Lines           4030        4031          +1     
  Branches         679         679                 
===================================================
  Hits            1859        1859                 
- Misses          1972        1973          +1     
  Partials         199         199                 
Impacted Files Coverage Δ
packages/api/src/app-router.ts 54.05405% <0.00000%> (-0.74048%) ⬇️
packages/api/src/parse-cli.ts 31.70732% <ø> (ø)
packages/api/src/controllers/region.js 74.07407% <66.66667%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6985670...01dc1ba. Read the comment docs.

Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM! Only one required change to the JSON response, to return the Os instead of the function. Nvm I had misunderstood that one. This is good to go!

packages/api/src/controllers/region.js Show resolved Hide resolved
export async function regionsGetter() {
const [regions, cursor] = await db.region.find({}, { limit: 100 });
export function regionsGetter(halfRegionOrchestratorsUntrusted = false) {
return async function regionsGetter2() {
Copy link
Member

Choose a reason for hiding this comment

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

I think this works fine! One syntax sugar you could use to make this look a little better would be a lambda function, replacing async function regionsGetter2() { with async () => {. Mostly a stylistic choice anyway.

Another alternative, to avoid this helper function that returns a function (which I find a little confusing sometimes) is to curry the new boolean variable on the call site where you need this function with zero arguments instead. That is, instead of returning a function here you could just make this function receive the boolean and return the regions, and in app-router you do:
orchestratorGetters.push(() => regionsGetter(halfUntrusted...)).

This also fixes the issue of using the return value of this function (another function) when we actually want the final list of regions.

This is a totally optional/stylistic change anyway, only raising the possibility since you were a little concerned about the current version here.

@@ -197,7 +198,9 @@ export default async function makeApp(params: CliArgs) {

if (returnRegionInOrchestrator) {
app.use((req, res, next) => {
req.orchestratorsGetters.push(regionsGetter);
req.orchestratorsGetters.push(
regionsGetter(halfRegionOrchestratorsUntrusted)
Copy link
Member

Choose a reason for hiding this comment

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

Contextualizing the other comment, if regionsGetter is made to return the orchestrators directly instead of a function, here you could have:
() => regionsGetter(halfRegionO...)

Then this function indirection stays localized here, which is where we actually need it. Other places can just use regionGetter (like the API controllers are using now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome, that's what I was looking for thanks! Much nicer to curry it at the calling site and keep the actual function clean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants