Service isolation Design

    Target

    1. Support forwarding the service according to the routing label by parsing the label of the request
    2. Tag Registration and Modification of Support Services

    2. Design

    2.1 Technical Architecture

    1. The overall technical architecture mainly modifies the point. The RestFul request needs to carry label parameter information such as routing label, and then the corresponding label will be parsed when the Gateway forwards to complete the route forwarding of the interface. The whole is shown in the figure below ![arc](/projects/Linkis-1.2.0-en/455d0ae9e3e732c91d748869adbb445c.png)
    1. If there are multiple corresponding services marked with the same roteLabel, it will be forwarded randomly
    2. If the corresponding routeLabel does not have a corresponding service, the interface fails directly

    2.2 Business Architecture

    1. This feature is mainly to complete the Restful tenant isolation and forwarding function. The modules designed by the function point are as follows:

    [Input] The input is the restful request requesting Gatway, and only the request with the roure label to be used in the parameter will be processed. [Processing process] The Gateway will determine whether the request has a corresponding RouteLabel, and if it exists, it will be forwarded based on the RouteLabel. The call sequence diagram is as follows:

    4. DDL:

    add route label for entrance

    1. echo "spring.eureka.instance.metadata-map.route=et1" >> $LINKIS_CONF_DIR/linkis-cg-entrance.properties
    2. sh $LINKIS_HOME/sbin/linkis-damemon.sh restart cg-entrance

    Time

    Use route label

    1. url:/api/v1/entrance/submit
    2. {
    3. "executionContent": {"code": "echo 1", "runType": "shell"},
    4. "params": {"variable": {}, "configuration": {}},
    5. "source": {"scriptPath": "ip"},
    6. "labels": {
    7. "engineType": "shell-1",
    8. "userCreator": "peacewong-IDE",
    9. "route": "et1"
    10. }
    11. }

    will be routed to a fixed service:

    1. {
    2. "method": "/api/entrance/submit",
    3. "message": "OK",
    4. "data": {
    5. "taskID": 45158,
    6. "execID": "exec_id018030linkis-cg-entrancelocalhost:9205IDE_peacewong_shell_0"
    7. }
    8. }

    or linkis-cli:

    Use non-existing label

    submit task:

    1. url:/api/v1/entrance/submit
    2. {
    3. "params": {"variable": {}, "configuration": {}},
    4. "source": {"scriptPath": "ip"},
    5. "labels": {
    6. "engineType": "shell-1",
    7. "userCreator": "peacewong-IDE",
    8. "route": "et1"
    9. }
    10. }
    1. "method": "/api/rest_j/v1/entrance/submit",
    2. "status": 1,
    3. "message": "GatewayErrorException: errCode: 11011 ,desc: Cannot route to the corresponding service, URL: /api/rest_j/v1/entrance/submit RouteLabel: [{\"stringValue\":\"et2\",\" labelKey\":\"route\",\"feature\":null,\"modifiable\":true,\"featureKey\":\"feature\",\"empty\":false}] ,ip: localhost ,port: 9101 ,serviceKind: linkis-mg-gateway",
    4. "data": {
    5. "data": "{\r\n \"executionContent\": {\"code\": \"echo 1\", \"runType\": \"shell\"},\r\n \"params \": {\"variable\": {}, \"configuration\": {}},\r\n \"source\": {\"scriptPath\": \"ip\"},\r\ n \"labels\": {\r\n \"engineType\": \"shell-1\",\r\n \"userCreator\": \"peacewong-IDE\",\r\n \" route\": \"et2\"\r\n }\r\n}"
    6. }
    7. }

    submit task:

    1. url:/api/v1/entrance/submit
    2. {
    3. "executionContent": {"code": "echo 1", "runType": "shell"},
    4. "params": {"variable": {}, "configuration": {}},
    5. "source": {"scriptPath": "ip"},
    6. "labels": {
    7. "engineType": "shell-1",
    8. "userCreator": "peacewong-IDE"
    9. }

    6. Non-functional design:

    6.1 Security

    No security issues are involved, restful requires login authentication

    6.2 Performance

    It has little impact on Gateway forwarding performance, and caches the corresponding label and instance data

    6.3 Capacity

    not involving