fix(store): differentiate os / on-prem enterprise / hosted deployments#814
Open
claude[bot] wants to merge 2 commits into
Open
fix(store): differentiate os / on-prem enterprise / hosted deployments#814claude[bot] wants to merge 2 commits into
claude[bot] wants to merge 2 commits into
Conversation
Previously isHosted was derived from a substring check against 'hosted.mender.io', which also matched per-PR preview deployments such as os-pr-2012.staging.hosted.mender.io, wrongly flagging them as a hosted production environment. Derive the hosted domains from the locations constant and treat a host as hosted when it equals or is a subdomain of one of them (so regular staging hosts like staging.hosted.mender.io stay hosted), while excluding per-PR preview deployments identified by a leading <component>-pr-<number> label. The explicit isHosted feature flag still forces hosted mode. Signed-off-by: Claude <noreply@anthropic.com>
…point Core init previously only fetched the organization when hasMultitenancy, isHosted or isEnterprise was already true, so a non-hosted deployment that never pre-set those flags could not be recognised as enterprise even when it exposed the organization endpoint. Always probe getUserOrganization after parseEnvironmentInfo (so the final isHosted value is available) and classify the deployment from the outcome: a reachable endpoint on a non-hosted deployment marks it multitenant enterprise (setFeatures hasMultitenancy/isEnterprise true), an unreachable one marks it a single-tenant OS install (both false). Hosted deployments are left untouched so their enterprise status stays plan-derived via getIsEnterprise. The rejection is caught so core init still resolves. The store setupTests server is exported so tests can override the organization handler to exercise the failure path. Signed-off-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Manuel Zedel · Slack thread
What changed
hosted.mender.io, so every PR preview under*.staging.hosted.mender.io(e.g.os-pr-2012.staging.hosted.mender.io) counted as a hosted instance. After, the real hosted hosts —hosted.mender.io,eu.hosted.mender.io,hosted.mender.cn, and staging hosts likestaging.hosted.mender.io— are recognized, while per-PR preview deployments (a leading-pr-<number>subdomain label) are excluded.getUserOrganizationwas only fetched when a multitenancy/hosted/enterprise flag was already set, so an on-prem enterprise install could not be distinguished from OS. After, core init always probes the organization endpoint and writes the result to the store: a non-hosted install where the org endpoint is reachable is classified as on-prem enterprise; if the probe fails it is treated as OS; hosted is unchanged. Combined with the hosted flag, this separates OS / on-prem enterprise / hosted.How
packages/store/src/storehooks.ts:parseEnvironmentInfobuilds the hosted-domain list from thelocationsconstant and usesisHostedHostname()(a domain match minus a-pr-<n>preview check) instead of the substring test. A newprobeOrganizationCapabilitiesthunk runs afterparseEnvironmentInfo, reads the resolvedisHosted, dispatchesgetUserOrganization().unwrap(), and on success (non-hosted) sets{ hasMultitenancy: true, isEnterprise: true }viasetFeatures, and on failure sets them false.retrieveCoreDatasequences the probe and no longer gates on pre-set flags.packages/store/src/storehooks.test.tsxfor the hostname cases and the three probe outcomes;packages/store/setupTests.tsexports the mswserverfor handler overrides.Testing
npx turbo run test-ci lint format:check --filter=@northern.tech/store→ 267 tests pass, lint + format clean.Notes / follow-ups
-pr-<number>preview-host pattern is inferred — no authoritative naming convention was found in the repo or CI config. If preview deployments use a different subdomain shape, theisHostedHostname()preview check will need adjusting.