This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 549
New RestServer Architecture: RestServer -> DB -> ApiServer; P0 Items #4761
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
4d24735
Compact PR (#4758)
hzy46 3039d89
fix
hzy46 eec3e80
fix
hzy46 429dc4e
trigger
hzy46 dbe94ac
fix
hzy46 c2adce5
fix
hzy46 642c868
fix
hzy46 e46f0ac
fix
hzy46 c6900f6
fix
hzy46 e4e7e72
fix
hzy46 b2ec6f5
Merge branch 'master' of github.com:microsoft/pai into zhiyuhe/db_int…
hzy46 4a64f65
fix rbac
hzy46 3850a10
fix
hzy46 a3e2cab
change rest-server & initializer
hzy46 d2ed448
fix
hzy46 197ca82
fix
hzy46 d235d4e
fix
hzy46 1cb37d0
fix
hzy46 54d219f
change license comment
hzy46 345d3af
fix lint
hzy46 e608c5e
fix
hzy46 979fe5d
fix
hzy46 94d8ae9
fix
hzy46 fd13d0e
resolve conflicts
hzy46 2dce698
fluentd fix
hzy46 e459a88
fix
hzy46 a20d16f
fix
hzy46 77352f4
fix
hzy46 7355131
fix
hzy46 da47640
fix
hzy46 bcd1b3c
fix
hzy46 ae73bfe
fix
hzy46 e203fd4
fix
hzy46 7c4878d
fix
hzy46 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Database Controller | ||
|
||
<center> | ||
<img src="./images/dbc_structure.png" width="100%"> | ||
</center> | ||
|
||
Database Controller is designed to manage job status in database and API server. To be brief, we treat records in database as the ground truth, and synchronize them to the API server. | ||
|
||
Database Controller contains 3 main components: write merger, poller and watcher. Here is an example of job lifetime controlled by these 3 components: | ||
|
||
1. User submits framework request to rest-server. | ||
2. Rest-server forwards the request to write merger. | ||
3. Write merger saves it to database, mark `synced=false`, and return. | ||
4. User is notified the framework request is successfully created. | ||
5. Poller finds the `synced=false` request, and synchronize it to the API server. | ||
6. Now watcher finds the framework is created in API server. So it sends the event to write merger. | ||
7. Write merger receives the watched event, mark `synced=true`, and update job status according to the event. | ||
8. The job finishes. Watcher sends this event to write merger. | ||
9. Write merger receives the watched event, mark `completed=true`, and update job status according to the event. | ||
10. Poller finds the `completed=true` request, delete it from API server. | ||
11. Watcher sends the delete event to write merger. | ||
12. Write merger receives the watched event, mark `deleted=true`. | ||
|
||
## Development | ||
|
||
**Environment:** Node.js 8.17.0, use `yarn install` to install all dependencies under `src/`. To set environmental variables, create a `.env` file under `src`. | ||
|
||
**Lint:** Run `npm run lint -- --fix` under `src/` or `sdk/`. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
.git | ||
|
||
# Directory for submitted jobs' json file and scripts | ||
frameworklauncher/ | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
version/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Database Controller | ||
|
||
See [here](../../docs/database_controller.md). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
pushd $(dirname "$0") > /dev/null | ||
|
||
mkdir -m 777 -p "../version" | ||
cp -arf "../../../version/PAI.VERSION" "../version/" | ||
echo `git rev-parse HEAD` > "../version/COMMIT.VERSION" | ||
|
||
popd > /dev/null |
21 changes: 21 additions & 0 deletions
21
src/database-controller/build/database-controller.common.dockerfile
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
FROM node:carbon | ||
|
||
WORKDIR /database-controller | ||
|
||
COPY ./src ./src | ||
COPY ./sdk ./sdk | ||
COPY ./version ./version | ||
|
||
WORKDIR src | ||
|
||
RUN yarn install | ||
|
||
RUN npm install json -g | ||
RUN json -I -f package.json -e "this.paiVersion=\"`cat ../version/PAI.VERSION`\"" | ||
RUN json -I -f package.json -e "this.paiCommitVersion=\"`cat ../version/COMMIT.VERSION`\"" | ||
|
||
|
||
CMD ["sleep", "infinity"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
service_type: "common" | ||
|
||
# general settings | ||
# Log level of all logs. You can choose from error, warn, info, http, verbose, debug, and silly. | ||
log-level: info | ||
# Whether to enable retain mode. | ||
# If someone submits a framework directly without accessing database, we can find the framework in write merger. | ||
# For these frameworks, if retain mode is on, we will ignore them. | ||
# If retain mode is off (it is the default setting), we will delete the frameworks to maintain ground-truth in database. | ||
retain-mode: false | ||
# The global timeout for all calls to Kubernetes API server. | ||
k8s-connection-timeout-second: 120 | ||
# The timeout for calls to write merger. | ||
write-merger-connection-timeout-second: 120 | ||
|
||
# write merger | ||
# The serving port for write merger. | ||
write-merger-port: 9748 | ||
# Max connection number to database in write merger. | ||
write-merger-max-db-connection: 50 | ||
|
||
# db poller | ||
# Polling interval of database poller. Default value is 120. | ||
db-poller-interval-second: 120 | ||
# Max connection number to database in write merger. | ||
db-poller-max-db-connection: 10 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
import copy | ||
import logging | ||
|
||
|
||
class DatabaseController(object): | ||
def __init__(self, cluster_conf, service_conf, default_service_conf): | ||
self.cluster_conf = cluster_conf | ||
self.service_conf = self.merge_service_configuration(service_conf, default_service_conf) | ||
self.logger = logging.getLogger(__name__) | ||
|
||
@staticmethod | ||
def merge_service_configuration(overwrite_srv_cfg, default_srv_cfg): | ||
if overwrite_srv_cfg is None: | ||
return default_srv_cfg | ||
srv_cfg = default_srv_cfg.copy() | ||
for k in overwrite_srv_cfg: | ||
srv_cfg[k] = overwrite_srv_cfg[k] | ||
return srv_cfg | ||
|
||
def get_master_ip(self): | ||
for host_conf in self.cluster_conf["machine-list"]: | ||
if "pai-master" in host_conf and host_conf["pai-master"] == "true": | ||
return host_conf["hostip"] | ||
|
||
def validation_pre(self): | ||
return True, None | ||
|
||
def run(self): | ||
result = copy.deepcopy(self.service_conf) | ||
result['write-merger-url'] = 'http://{}:{}'.format(self.get_master_ip(), result['write-merger-port']) | ||
return result | ||
|
||
def validation_post(self, conf): | ||
return True, None |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not need manual recovery-mode if we already have auto recover in init container? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw Note that during recover do not serve any http request just recover
In reply to: 466150363 [](ancestors = 466150363)