Repository navigation
feat: Instance-Aware Networking (RequestInterceptor) - #677
Conversation
Develop to main v1.4
Develop to main v1.5
Develop to main v1.5.1
Develop to main. Release v2
Develop to main v2.1
Release v2.2 (Ulmo.1)
Release v2.3 (Verawood.1)
…erceptor) Reuses the tenants branch's already-built host-rewrite approach (renamed tenant -> instance): API is still constructed once against the app's default ConfigProtocol.baseURL, and RequestInterceptor.adapt(...) re-targets any request built against that host at the currently selected instance's baseURL, preserving path/query/fragment. Requests that already point elsewhere (SSO webviews, third-party SDKs) are left untouched. refreshToken(...) prefers the selected instance's baseURL/ oAuthClientId, falling back to the app config for single-instance deployments or before an instance is picked. instanceStore comes in via the InstanceProvider protocol, already registered in DI by PR-2 -- no new DI wiring beyond passing it through to RequestInterceptor's initializer.
|
Thanks for the pull request, @RawanMatar89! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
|
@RawanMatar89 Stop, nooooooo... And inside a JSON you are setup all the instances. As example something like this: We need to support JSON file by URL or locally by DIRECTORY_FILE value. We need them both. Please, do not remove config.yaml🙌 |
@ivan-stepanok 😄 I don't think we're actually disagreeing on the shape here, let me untangle it: The URL-or-local-file JSON directory you're describing is exactly what's already built on the branch this PR stacks on — The one thing that did change is the outer local app config — instead of keeping that as YAML and adding a separate JSON directory format on top, it's now JSON too ( If there's something specific relying on |
|
Thanks, @RawanMatar89 – the remote catalog looks good, and I'm fine with JSON becoming the build-time config source. The plist output is unchanged, so nothing shifts at runtime. A few things I'd like in before this merges, though: A migration path. Anyone upgrading with an existing YAML config in their Docs in the same PR. Pick one format. None of this is a blocker on the approach – just don't want to hand operators a silent break and stale docs. |
|
Thank you @IvanStepanok 🙏🏻 all three are fair, and none of them are done yet, so no pushback: Migration path: confirmed the gap. I'll add an explicit check up front and ship a small converter script alongside it, since the schema didn't reshape anything moving formats. Will push all three as part of this PR before asking for another look. 🙌 |
process_config.py previously just fell into the generic "config files not found" exit when config.json didn't exist yet, with no indication that config.yaml (retired in 85aa83f) was the reason. fail_if_unmigrated_yaml_config now detects a leftover config.yaml with no sibling config.json and fails with a message naming both files and the converter to run. Add config_script/yaml_to_json_config.py: a small standalone converter (reuses this project's existing PyYAML/json deps, no new dependency) so operators don't hand-write the JSON. See Ivan's review on openedx#677.
Last two YAML files in default_config/ -- everything else there has been JSON since 85aa83f. Converts config_settings.yaml -> config_settings.json and each environment's file_mappings.yaml -> file_mappings.json (via yaml_to_json_config.py), updates process_config.py and whitelabel.py (which duplicates the same config_settings/file_mappings parsing) to read JSON instead. Addresses Ivan's review on openedx#677: migration path, docs, and one format instead of JSON+YAML side by side in the same folder.
|
Hi @IvanStepanok, the three changes from your last review are in. Pushed and ready for another look. 👀 One thing worth flagging before you dig in: these are stacked PRs, so this one's diff only makes sense on top of the branches below it. Branch names show the order — infra/01-tenant-model → infra/02-tenant-store → infra/03-remote-config-fetch → infra/04-instance-aware-networking (this one). Could we review and approve/merge in that order, starting from infra/01-tenant-model? Reviewing this one in isolation will show you everything from the branches underneath it too, which makes it harder to tell what's actually new here. One naming note: any branch still says "tenant" was created before we agreed on the tenant → instance rename, and its content is already renamed to instance throughout. Just a stale branch name, not a leftover reference. |
The merge-base changed after approval.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #677 +/- ##
==============================
==============================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The merge-base changed after approval.
The merge-base changed after approval.
The merge-base changed after approval.
The merge-base changed after approval.
…e-aware-networking
Base branch
infra/03-remote-config-fetchDescription
Routes outgoing requests through the currently selected instance's host and credentials instead of the app-level config, and refreshes tokens against that instance too. This is where the instance model (PR-1) and instance selection (PR-2) actually start affecting network traffic — before this PR,
InstanceStoretracked a selection but nothing used it.What's in this PR
RequestInterceptorinstanceStore: InstanceProviderdependency (already registered by PR-2 — no new DI wiring needed).adapt(...)now rewrites the host/scheme/port of any request built against the app's base URL to the selected instance'sbaseURL, via a newrewriteHostIfNeeded(_:). Path and query are left untouched. A request with no selected instance, or one not built against the app base URL in the first place (e.g. an SSO webview, a third-party SDK call), passes through unmodified.refreshToken(...)now prefers the selected instance'sbaseURL/oAuthClientIdover the app-level config, falling back to app config when no instance is selected.token_typestays app-level (unchanged) — no instance-level override for that field exists yet.DI
NetworkAssembly.swift:RequestInterceptorregistration now resolves and passesInstanceProvider.Tests
RequestInterceptorTests.swift(new): selected-instance host rewrite (host/path/query preserved correctly), no-instance-selected passthrough, and non-app-base-URL requests left untouched.Out of scope