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

Reserved network locations for Studio and KDP #12703

Conversation

LianaHarris360
Copy link
Member

Summary

This pull request allows the use of NetworkLocation models and associated architecture to interact with Studio and KDP.

Details

  • Removes dynamic field and its setter from model NetworkLocation after migrating to field location_type.
  • Updates the task reset_connection_states to create or update reserved network locations for Studio and KDP using URLs from Kolibri's options.ini file. Uses hardcoded IDs for these locations, resets their connection states similarly to static locations, and for KDP locations, sets the application to Kolibri Data Portal without enqueuing a perform_network_location_update task.
  • Updates the viewset and serializer for NetworkLocations model to annotate a dynamic attribute on the response when location_type is dynamic, only allow static models to be created (and set the location_type to static when creating them), and exclude KDP and Studio if syncable filter is not provided.

Notes

  • As noted in this comment, KDP does respond to information requests; so preventing request to KDP's location within the method update_connection_status was not implemented.
  • Studio lacks an instance ID, so we hash the URL to generate one. This approach doesn't work for KDP, which already has an instance ID not derived from the URL. The ID can be hardcoded, but it can't be a UUID generated from the URL like in Studio.

References

Closes #10431


Testing checklist

  • 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

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

Reviewer checklist

  • 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

@LianaHarris360 LianaHarris360 added the DEV: backend Python, databases, networking, filesystem... label Oct 3, 2024
@pcenov
Copy link
Member

pcenov commented Oct 7, 2024

Hi @LianaHarris360 and @marcellamaki no issues observed while regression testing the content import from studio and syncing to KDP.

@bjester bjester self-assigned this Oct 8, 2024
Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

Mainly just questions, as I'm not sure I understand all of the reasoning behind some of the changes.

kolibri/core/discovery/tasks.py Outdated Show resolved Hide resolved
kolibri/core/discovery/api.py Outdated Show resolved Hide resolved
kolibri/core/discovery/serializers.py Outdated Show resolved Hide resolved
kolibri/core/discovery/well_known.py Outdated Show resolved Hide resolved
kolibri/core/discovery/api.py Outdated Show resolved Hide resolved
Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Changes look correct to me! It appears there is just one clarification to take care of, otherwise all everything else seems fine to me. I'll leave the final approval to @bjester. Thanks @LianaHarris360

Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the feedback so far. There's just one lingering issue with the API

kolibri/core/discovery/serializers.py Show resolved Hide resolved
Comment on lines 42 to 53
if syncable == "1":
# Include KDP's reserved location
queryset = NetworkLocation.objects.filter(
Q(location_type=LocationTypes.Static)
| Q(id=DATA_PORTAL_BASE_INSTANCE_ID)
)
elif syncable == "0":
# Include Studio's reserved location
queryset = NetworkLocation.objects.filter(
Q(location_type=LocationTypes.Static)
| Q(id=CENTRAL_CONTENT_BASE_INSTANCE_ID)
)
Copy link
Member

Choose a reason for hiding this comment

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

This isn't quite 100% to what we need. For background, the reasoning behind this filter is to return locations that either are syncable (for facility data syncing) or can be used for content import. Studio can be used for content import but syncing. KDP can be used for syncing but not content import. As coded, this wouldn't return dynamic locations, which are similar to static in that we assume they can do both.

Copy link
Member Author

Choose a reason for hiding this comment

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

So this filter should consistently return static and dynamic locations, and only include KDP/Studio reserved locations based on the syncable value?

Copy link
Member

Choose a reason for hiding this comment

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

Yep!

Copy link
Member

@bjester bjester left a comment

Choose a reason for hiding this comment

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

LGTM

@bjester bjester merged commit d29abf8 into learningequality:develop Nov 20, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reserved network locations for Studio and KDP
4 participants