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

Use seg duration to time out remote transcoders. #1511

Merged
merged 9 commits into from
May 26, 2020
Merged

Conversation

j0sh
Copy link
Collaborator

@j0sh j0sh commented May 21, 2020

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

As described in #1478 , orchestrator timeouts for a remote T need to be adjusted to handle longer segment durations.

In addition to transmitting the duration from the B to the O in net.SegData , the duration also needs to be made available to the orchestrator's remote transcoder manager to make use of it. The remote transcoder manager follows the Transcoder interface, which offers nowhere to put the duration:

Transcode(job string, fname string, profiles []ffmpeg.VideoProfile) (*TranscodeData, error)

Since both the orchestrator and broadcaster make use of core.SegTranscodingMetadata (CSTMD), which has similar fields as net.SegData, we formalize this relationship [1] and extract mappings ( 1, 2 ) to / from each: the latter for propagation over the wire, and the former for propagation throughout the codebase.

Having the Transcoder interface take a CSTMD effectively subsumes the job and profiles parameters, with CSTMD.ManifestID and CSTMD.Profiles respectively. From there, there is little reason not to also incorporate the fname parameter, resulting in the this interface:

Transcode(md *SegTranscodingMetadata) (*TranscodeData, error)

The O-T protocol is also adjusted to take net.SegData. Although not strictly necessary since the standalone transcoder does not currently require the duration [2], this has the side effect of a small reduction in technical debt for standalone T, due to reuse of the mappings between net.SegData and CSTMD . Any fields that are added to these structs, such as a denominator for the framerate (#1474 (comment)) will be available by default to standalone T. Back-compat logic that is developed within the mappings will also carry over.

[1] We could have opted to carry net.SegData throughout the codebase rather than making use of CSTMD, but the back-compat in net.SegData requires some translation before its fields can be used within the codebase, eg around profiles. This gives us the ability to evolve each structure as needed. We've already done so with the incorporation of the Fname field to CSTMD which isn't necessary over the wire.

[2] The transcoder will need the duration as soon as it's ready to be incorporated into the load balancer.

Specific updates (required)

  • cmd, core: Typo fixes. 286a520
  • net: Regenerate proto with segment duration. 5f03718
  • core, server: Use net.SegData in the O-T protocol. … 4457979
  • server, net: Send segment duration over the wire. 3358454
  • server: Refactor test cases to use coreSegMetadata. … fe29742
  • core: Add input filename to SegTranscodingMetadata. … b9d3907
  • core, server: Pass SegTranscodingMetadata to transcoder. b1189c8
  • core: Set remote transcoder timeout based on segment duration. 21568b1

How did you test each of these updates (required)

  • Unit testing
  • Manual testing

Does this pull request close any open issues?

Checklist:

  • README and other documentation updated
  • Node runs in OSX and devenv
  • All tests in ./test.sh pass

Copy link
Contributor

@darkdarkdragon darkdarkdragon left a comment

Choose a reason for hiding this comment

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

Looks good, just couple of small suggestions

server/rpc.go Outdated
os = segData.Storage[0]
}

dur := time.Duration(int64(segData.Duration) * int64(time.Millisecond))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
dur := time.Duration(int64(segData.Duration) * int64(time.Millisecond))
dur := time.Duration(segData.Duration) * time.Millisecond

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in b7a6479

// Deprecated by segData. Job the segment belongs to.
string job = 2;

// Deprecated by fullProfiles. Set of presets to transcode into.
bytes profiles = 17;
Copy link
Contributor

Choose a reason for hiding this comment

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

recommended way of deprecating fields

Suggested change
bytes profiles = 17;
bytes profiles = 17 [deprecated=true];

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very nice - didn't know about this annotation! Actually, kept this line in place since we still "use" it via setting an invalid value to induce failures. Added a comment to the protobuf indicating this in 4d95785

According to the protobuf docs, this is a no-op in all languages except Java, where it emits a warning. My concern is that if golang ever picks this up - golang only has errors, no warnings - this could cause code to stop compiling and the annotation would have to be removed. I'm not entirely sure about the implications of this, so it seems safer to just keep things as-is.

net/lp_rpc.proto Outdated
bytes profiles = 17;

// Transcoding profiles to use. Supersedes `profiles` field

// Deprecated by segData. Transcoding configuration to use.
repeated VideoProfile fullProfiles = 33;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
repeated VideoProfile fullProfiles = 33;
repeated VideoProfile fullProfiles = 33 [deprecated=true];

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made this reserved in 4d95785

net/lp_rpc.proto Outdated
// Deprecated fields. May still be populated sometimes for back compat

// Deprecated by segData. Job the segment belongs to.
string job = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

recommended way of deprecating field that's not used anymore

Suggested change
string job = 2;
// string job = 2;
reserved 2;
reserved "job";

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, reserved the number in 4d95785 . Didn't reserve the field name since we don't do JSON, so there should not be a conflict. (Can still add that in if you feel it should be there though.)

Base automatically changed from ja/passthruestimate to master May 22, 2020 17:52
@j0sh
Copy link
Collaborator Author

j0sh commented May 22, 2020

Addressed comments via fixup, and also made a clean-up pass through the protobuf file to remove trailing whitespace in 98ab212. Cosmetic changes; nothing functional.

Copy link
Contributor

@darkdarkdragon darkdarkdragon left a comment

Choose a reason for hiding this comment

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

LGTM

net/lp_rpc.proto Outdated Show resolved Hide resolved
server/ot_rpc.go Show resolved Hide resolved
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

LGTM pending green CI

@j0sh j0sh force-pushed the ja/remotetimeout branch from 89a3acf to dace5d5 Compare May 26, 2020 22:31
@j0sh j0sh merged commit dace5d5 into master May 26, 2020
@j0sh j0sh deleted the ja/remotetimeout branch May 26, 2020 22:32
@j0sh
Copy link
Collaborator Author

j0sh commented May 26, 2020

Rebased, merged

@j0sh j0sh mentioned this pull request Jun 3, 2020
6 tasks
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.

3 participants