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

hybrik: fix bug with improper connections #211

Merged

Conversation

zsiec
Copy link
Member

@zsiec zsiec commented Jun 15, 2019

This is a small patch to address a bug that was causing incorrect connections to be constructed. Connections were generated referencing non-existent elements and some elements were left unconnected.

This is a small patch to address a bug that was causing incorrect connections to be constructed. Connections were generated referencing non-existent elements and some elements were left unconnected.
@codecov-io
Copy link

codecov-io commented Jun 15, 2019

Codecov Report

Merging #211 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #211   +/-   ##
=======================================
  Coverage   78.62%   78.62%           
=======================================
  Files          29       29           
  Lines        2914     2914           
=======================================
  Hits         2291     2291           
  Misses        372      372           
  Partials      251      251

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 3bfc86b...16eae21. Read the comment docs.

Copy link
Collaborator

@fsouza fsouza left a comment

Choose a reason for hiding this comment

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

Hi @zsiec, thank you very much for contributing! :D Overall looks good, but maybe we can avoid some repetition.

I had forgotten that we never added tests to the hybrik provider. Perhaps we can take a look at doing that next? x)

activeRunning = "running"
activeWaiting = "waiting"
hls = "hls"
transcodeElementIDTempate = "transcode_task_%s"
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo:

Suggested change
transcodeElementIDTempate = "transcode_task_%s"
transcodeElementIDTemplate = "transcode_task_%s"

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 catching

transcodeSuccessConnections[i] = hwrapper.ToSuccess{Element: "transcode_task" + strconv.Itoa(i)}
transcodeSuccessConnections := make([]hwrapper.ToSuccess, len(transcodeElementIds))
for i, id := range transcodeElementIds {
transcodeSuccessConnections[i] = hwrapper.ToSuccess{Element: id}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we range through elements and add element.UID to the transcodeSuccessConnections slice? Something like:

for i, e := range elements {
  transcodeSuccessConnections[i] = hwrapper.ToSuccess{Element: e.UID}
}

Then we don't need an additional slice, I think. And that would also keep the logic to generate the element id inside the monutTranscodeElement function.

If we do that, can you also make the constant transcodeElementIDTemplate local to that function?

Copy link
Member Author

@zsiec zsiec Jun 16, 2019

Choose a reason for hiding this comment

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

This change was made because elements holds a slice of all elements and in this case, not only the transcode task elements, but at least one source element created and appended before we run the logic to create the transcode task elements. (this was causing incorrect connections to be generated)

Rather than assume we have a single source element and doing a range over elements[1:] (along with assuming there are no elements between the source and the transcode tasks), I thought it would be less error prone to explicitly track transcode tasks. This allows us to freely add elements before the transcode elements without having to change that slice offset.

We can safely change
transcodeElementIds = append(transcodeElementIds, fmt.Sprintf(transcodeElementIDTemplate, taskIndex))
to
transcodeElementIds = append(transcodeElementIds, e.UID)

but we make use of transcodeElementIDTemplate again in presetsToTranscodeJob when generating connections to packagings tasks (line 293) (perhaps we could send the transcodeElementIDTemplate into mountTranscodeElement to keep it out of the global scope?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for clarifying! This makes sense, my bad x)

We can keep the code as is :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Cheers! I was tripped up by the code a few times myself, I think we can clean it up a little :)

addressing CR comments
@zsiec
Copy link
Member Author

zsiec commented Jun 16, 2019

@fsouza thanks for the review! This was a simple patch to get things working again, We will likely take a pass at rewriting it completely, similar to what we did for the new Bitmovin provider in #210. (although abstractions will diverge slightly as the Hybrik and Bitmovin APIs differ) We want to simplify the functions and reduce the amount of state that shares scope, and of course, add tests :)

Copy link
Contributor

@scentless-apprentice scentless-apprentice left a comment

Choose a reason for hiding this comment

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

🚀

@scentless-apprentice scentless-apprentice merged commit e4f8957 into video-dev:master Jun 17, 2019
@zsiec zsiec deleted the hybrik-provider-errors branch June 17, 2019 15:43
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.

4 participants