Skip to content

Commit

Permalink
Move Storage Urls from Tenant Metadata to Service Level (#9849)
Browse files Browse the repository at this point in the history
* FRS-Echo-Openapis-POC

* Update openapi.json

* Update openapi.json

* Upload openapi.yaml

* Update openapi.json

* Update openapi.json

* Update openapi.json

* Update openapi.json

* Remove openapi

* Move the tenant's urls to cluster

* Change the runnerFactory.ts

* Refactor the configmap

* Remove unnecessary packages

* Change the url validation method

* Change the falsy check

* Add the historian_storage_url

* Change the config files

* Change to internalHistorianUrlOverride

* Resolve storage url

* Let the server only read from cluster for storage urls
  • Loading branch information
tianzhu007 authored Apr 19, 2022
1 parent ae93fdb commit 0f2488d
Show file tree
Hide file tree
Showing 23 changed files with 187 additions and 54 deletions.
3 changes: 2 additions & 1 deletion server/charts/historian/templates/historian-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ data:
},
"restGitService": {
"disableGitCache": {{ .Values.historian.restGitService.disableGitCache }}
}
},
"storageUrl": "{{ .Values.historian.storageUrl }}"
}
1 change: 1 addition & 0 deletions server/charts/historian/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ historian:
cert: historian_cert
ingressClass: ingress_class
riddler: riddler_url
storageUrl: historian_storage_url
error:
track: true
endpoint: "error_tracking_endpoint"
Expand Down
28 changes: 20 additions & 8 deletions server/historian/packages/historian-base/src/routes/git/blobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function create(
tenantId: string,
authorization: string,
body: git.ICreateBlobParams): Promise<git.ICreateBlobResponse> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createBlob(body);
}

Expand All @@ -39,7 +45,13 @@ export function create(
authorization: string,
sha: string,
useCache: boolean): Promise<git.IBlob> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getBlob(sha, useCache);
}

Expand All @@ -63,7 +75,7 @@ export function create(
response,
false,
201);
});
});

/**
* Retrieves the given blob from the repository
Expand All @@ -78,7 +90,7 @@ export function create(
blobP,
response,
useCache);
});
});

/**
* Retrieves the given blob as an image
Expand All @@ -97,10 +109,10 @@ export function create(
}
response.status(200).write(Buffer.from(blob.content, "base64"), () => response.end());
},
(error) => {
response.status(error?.code ?? 400).json(error?.message ?? error);
});
});
(error) => {
response.status(error?.code ?? 400).json(error?.message ?? error);
});
});

return router;
}
16 changes: 14 additions & 2 deletions server/historian/packages/historian-base/src/routes/git/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function create(
tenantId: string,
authorization: string,
params: ICreateCommitParams): Promise<ICommit> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createCommit(params);
}

Expand All @@ -39,7 +45,13 @@ export function create(
authorization: string,
sha: string,
useCache: boolean): Promise<ICommit> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getCommit(sha, useCache);
}

Expand Down
40 changes: 35 additions & 5 deletions server/historian/packages/historian-base/src/routes/git/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,38 @@ export function create(
};

async function getRefs(tenantId: string, authorization: string): Promise<git.IRef[]> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getRefs();
}

async function getRef(tenantId: string, authorization: string, ref: string): Promise<git.IRef> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getRef(ref);
}

async function createRef(
tenantId: string,
authorization: string,
params: ICreateRefParamsExternal): Promise<git.IRef> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createRef(params);
}

Expand All @@ -50,15 +68,27 @@ export function create(
authorization: string,
ref: string,
params: IPatchRefParamsExternal): Promise<git.IRef> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.updateRef(ref, params);
}

async function deleteRef(
tenantId: string,
authorization: string,
ref: string): Promise<void> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.deleteRef(ref);
}

Expand Down
16 changes: 14 additions & 2 deletions server/historian/packages/historian-base/src/routes/git/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,24 @@ export function create(
tenantId: string,
authorization: string,
params: git.ICreateTagParams): Promise<git.ITag> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createTag(params);
}

async function getTag(tenantId: string, authorization: string, tag: string): Promise<git.ITag> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getTag(tag);
}

Expand Down
16 changes: 14 additions & 2 deletions server/historian/packages/historian-base/src/routes/git/trees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function create(
tenantId: string,
authorization: string,
params: git.ICreateTreeParams): Promise<git.ITree> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createTree(params);
}

Expand All @@ -40,7 +46,13 @@ export function create(
sha: string,
recursive: boolean,
useCache: boolean): Promise<git.ITree> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getTree(sha, recursive, useCache);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export function create(
authorization: string,
sha: string,
count: number): Promise<git.ICommitDetails[]> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getCommits(sha, count);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function create(
authorization: string,
path: string,
ref: string): Promise<any> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getContent(path, ref);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export function create(
authorization: string,
sha: string,
useCache: boolean): Promise<IHeader> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getHeader(sha, useCache);
}

Expand All @@ -40,7 +46,13 @@ export function create(
authorization: string,
sha: string,
useCache: boolean): Promise<any> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getFullTree(sha, useCache);
}

Expand Down
25 changes: 19 additions & 6 deletions server/historian/packages/historian-base/src/routes/summaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { AsyncLocalStorage } from "async_hooks";
import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse} from "@fluidframework/server-services-client";
import { IWholeFlatSummary, IWholeSummaryPayload, IWriteSummaryResponse } from "@fluidframework/server-services-client";
import { IThrottler } from "@fluidframework/server-services-core";
import { IThrottleMiddlewareOptions, throttle, getParam } from "@fluidframework/server-services-utils";
import { Router } from "express";
Expand Down Expand Up @@ -32,15 +32,27 @@ export function create(
authorization: string,
sha: string,
useCache: boolean): Promise<IWholeFlatSummary> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.getSummary(sha, useCache);
}

async function createSummary(
tenantId: string,
authorization: string,
params: IWholeSummaryPayload): Promise<IWriteSummaryResponse> {
const service = await utils.createGitService(tenantId, authorization, tenantService, cache, asyncLocalStorage);
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
cache,
asyncLocalStorage);
return service.createSummary(params);
}

Expand All @@ -49,6 +61,7 @@ export function create(
authorization: string,
softDelete: boolean): Promise<boolean[]> {
const service = await utils.createGitService(
config,
tenantId,
authorization,
tenantService,
Expand All @@ -74,7 +87,7 @@ export function create(
response,
// Browser caching for summary data should be disabled for now.
false);
});
});

router.post("/repos/:ignored?/:tenantId/git/summaries",
throttle(throttler, winston, commonThrottleOptions),
Expand All @@ -87,7 +100,7 @@ export function create(
false,
undefined,
201);
});
});

router.delete("/repos/:ignored?/:tenantId/git/summaries",
throttle(throttler, winston, commonThrottleOptions),
Expand All @@ -102,7 +115,7 @@ export function create(
summaryP,
response,
false);
});
});

return router;
}
Loading

0 comments on commit 0f2488d

Please sign in to comment.