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

Content import peer discovery #6011

Merged
merged 20 commits into from
Nov 14, 2019
Merged

Content import peer discovery #6011

merged 20 commits into from
Nov 14, 2019

Conversation

indirectlylit
Copy link
Contributor

@indirectlylit indirectlylit commented Oct 30, 2019

Summary

builds off of #5660

Reviewer guidance

Work-in-progress

References

#5660


Contributor Checklist

PR process:

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Testing:

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

Reviewer Checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@indirectlylit indirectlylit added the changelog Important user-facing changes label Oct 30, 2019
@indirectlylit indirectlylit added this to the 0.13.0 milestone Oct 30, 2019
@indirectlylit indirectlylit added the work-in-progress Not ready for review label Oct 30, 2019
@indirectlylit indirectlylit changed the title Content import peer discovery [new] Content import peer discovery Oct 30, 2019
"""Retrieve a list of dicts with information about the discovered Kolibri instances on the local network,
filtering out those that can't be accessed at the specified port (via attempting to open a socket)."""
if not ZEROCONF_STATE["listener"]:
initialize_zeroconf_listener()
Copy link
Contributor

@micahscopes micahscopes Nov 6, 2019

Choose a reason for hiding this comment

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

This is going to be taken out so that we don't end up with multiple zeroconf listeners.

Instead, the single zeroconf listener will pickle the latest list of instances, and various workers will access the pickled list.

continue
if not _is_port_open(instance["ip"], instance["port"], timeout=timeout):
continue
instance["self"] = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This will get moved into the zeroconf discovery handler.

Copy link
Member

Choose a reason for hiding this comment

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

(and can just be excluded off the bat)



def _is_port_open(host, port, timeout=1):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
Copy link
Contributor

@micahscopes micahscopes Nov 6, 2019

Choose a reason for hiding this comment

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

Add a little local cache so that this check isn't done too frequently for a given peer, but so that the check is done:

  • immediately following discovery
  • after a while (~ 20 seconds?)

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest having it be a "shared" cache (not just local memory), using Django's cache backend, because it might be different web service processes handling the sequential queries.

@indirectlylit indirectlylit added the TAG: user strings Application text that gets translated label Nov 10, 2019
@codecov
Copy link

codecov bot commented Nov 13, 2019

Codecov Report

Merging #6011 into develop will increase coverage by 0.77%.
The diff coverage is 78.52%.

Impacted Files Coverage Δ
...ageContentPage/SelectNetworkAddressModal/index.vue 63.63% <0%> (-6.37%) ⬇️
...ManageContentPage/SelectNetworkAddressModal/api.js 0% <0%> (ø) ⬆️
kolibri/core/discovery/api.py 100% <100%> (ø) ⬆️
kolibri/plugins/device/assets/src/apiResources.js 100% <100%> (ø) ⬆️
kolibri/core/discovery/api_urls.py 100% <100%> (ø) ⬆️
kolibri/utils/server.py 46.24% <25%> (-0.71%) ⬇️
kolibri/utils/cli.py 70.55% <45.45%> (-0.88%) ⬇️
...ge/SelectNetworkAddressModal/SelectAddressForm.vue 81.33% <74.07%> (-6.39%) ⬇️
kolibri/core/discovery/utils/network/search.py 92.85% <92.85%> (ø)
kolibri/utils/logger.py 73.43% <0%> (-15.63%) ⬇️
... and 13 more

Copy link
Contributor Author

@indirectlylit indirectlylit left a comment

Choose a reason for hiding this comment

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

Awesome thanks @micahscopes

There are a few outstanding notes from @jamalex and I left a few very minor comments also. I'll merge this in and we'll continue the work in subsequent PRs

Also opened this: #6059

@@ -5,6 +5,7 @@
v-if="stage === Stages.SELECT_ADDRESS"
@cancel="resetContentWizardState"
@click_add_address="goToAddAddress"
@click_search_address="goToSearchAddress"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

conventionally we use camelCase for events. I see that this matches the others in the component so this is fine, but would be nice to refactor later for consistency

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. I didn't bother to go that in-depth. That code is copied from another file and looking at it now, is going to be deleted anyway.

/>
</div>
</template>

<hr v-if="discoveredAddresses.length > 0">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in subsequent work, let's make sure this is styled as a one-pixel solid line using the theme color $themeTokens.fineLine

this.intervalId = clearInterval(this.intervalId);
}
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as in another PR here: #5631 (comment)

@rtibbles
Copy link
Member

Woot

@rtibbles rtibbles deleted the zeroconf branch November 14, 2019 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog Important user-facing changes TAG: user strings Application text that gets translated work-in-progress Not ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants