Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate scores by collecting resource information from all edge devices #122

Merged
merged 3 commits into from
Sep 10, 2020
Merged

Conversation

tiokim
Copy link
Contributor

@tiokim tiokim commented Aug 26, 2020

Description

This is one of PRs related on the issue #121.
An edge orchestration is able to calculate all the scores based on the resource information gathered from other devices.
This function runs only when ExecOption's scoringType in REST API for executing a service is "resource" like below.

curl -X POST "localhost:56001/api/v1/orchestration/services" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"ServiceName\": \"hello-world\", \"ServiceInfo\": [{ \"ExecutionType\": \"container\", \"ExecCmd\": [ \"docker\", \"run\", \"-v\", \"/var/run:/var/run:rw\", \"hello-world\"], \"ExecOption\": {\"scoringType\":\"resource\"}}], \"StatusCallbackURI\": \"http://localhost:8888/api/v1/services/notification\"}"
{
    "ServiceName": "hello-world",
    "ServiceInfo": [
    {
        "ExecutionType": "container",
        "ExecCmd": [
            "docker",
            "run",
            "-v", "/var/run:/var/run:rw",
            "hello-world"
        ],
        "ExecOption": { "scoringType": "resource" }
    }],
    "StatusCallbackURI": "http://localhost:8888/api/v1/services/notification"
}

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

This PR is tested on the container by the REST API for executing a service.

  1. scoringType is "resource"
2020/08/26 09:09:09 externalhandler.go:89: [RestExternalInterface] APIV1RequestServicePost
2020/08/26 09:09:09 externalhandler.go:153: port:  54414
2020/08/26 09:09:09 senderresolver.go:70: returning:  curl
2020/08/26 09:09:09 externalhandler.go:158: requester:  curl
2020/08/26 09:09:09 orchestration_api.go:124: [RequestService] hello-world: [{container [docker run -v /var/run:/var/run:rw hello-world] map[scoringType:resource]}]
2020/08/26 09:09:09 orchestration_api.go:150: [RequestService] getCandidate
2020/08/26 09:09:09 orchestration_api.go:152: [0] Id       : edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243
2020/08/26 09:09:09 orchestration_api.go:153: [0] ExecType : container
2020/08/26 09:09:09 orchestration_api.go:154: [0] Endpoint : [10.113.70.227]
2020/08/26 09:09:09 orchestration_api.go:155:
2020/08/26 09:09:09 orchestration_api.go:152: [1] Id       : edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415
2020/08/26 09:09:09 orchestration_api.go:153: [1] ExecType : container
2020/08/26 09:09:09 orchestration_api.go:154: [1] Endpoint : [10.113.71.53]
2020/08/26 09:09:09 orchestration_api.go:155:
2020/08/26 09:09:09 restclient.go:157: [restclient] DoGetResourceRemoteDevice : endpoint[10.113.70.227]
2020/08/26 09:09:09 orchestration_api.go:417: [orchestrationapi] deviceResource
2020/08/26 09:09:09 orchestration_api.go:418: candidate Id       : edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415
2020/08/26 09:09:09 orchestration_api.go:419: candidate ExecType : container
2020/08/26 09:09:09 orchestration_api.go:420: candidate Endpoint : 10.113.71.53
2020/08/26 09:09:09 orchestration_api.go:421: candidate resource : map[cpuUsage:0.7594936708860759 cpuCount:4 cpuFreq:900 netBandwidth:1000 rtt:0.003407767]
2020/08/26 09:09:09 restclient.go:182: [restclient] respMsg From [10.113.70.227] : map[cpuCount:8 cpuFreq:4200 cpuUsage:0 netBandwidth:500 rtt:0.002952915]
2020/08/26 09:09:09 orchestration_api.go:417: [orchestrationapi] deviceResource
2020/08/26 09:09:09 orchestration_api.go:418: candidate Id       : edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243
2020/08/26 09:09:09 orchestration_api.go:419: candidate ExecType : container
2020/08/26 09:09:09 orchestration_api.go:420: candidate Endpoint : 10.113.70.227
2020/08/26 09:09:09 orchestration_api.go:421: candidate resource : map[netBandwidth:500 rtt:0.002952915 cpuCount:8 cpuFreq:4200 cpuUsage:0]
2020/08/26 09:09:09 restclient.go:62: [restclient] DoExecuteRemoteDevice : endpoint[10.113.70.227]
2020/08/26 09:09:09 restclient.go:85: [restclient] respMsg From [10.113.70.227] : map[Status:Started]
2020/08/26 09:09:09 orchestration_api.go:240: [orchestrationapi]  [{edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243 10.113.70.227 16.784057707434982 map[cpuCount:8 cpuFreq:4200 cpuUsage:0 netBandwidth:500 rtt:0.002952915] container} {edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415 10.113.71.53 11.653885351967045 map[rtt:0.003407767 cpuUsage:0.7594936708860759 cpuCount:4 cpuFreq:900 netBandwidth:1000] container}]
2020/08/26 09:09:09 route.go:125: From [10.113.71.53:54414] POST /api/v1/orchestration/services APIV1RequestServicePost 150.217346ms
2020/08/26 09:09:14 internalhandler.go:189: [RestInternalInterface] APIV1ServicemgrServicesNotificationServiceIDPost
2020/08/26 09:09:14 route.go:125: From [10.113.70.227:54600] POST /api/v1/servicemgr/services/notification/2 APIV1ServicemgrServicesNotificationServiceIDPost 1.574221ms
2020/08/26 09:09:14 orchestration_api.go:444: [orchestrationapi] service status changed [appNames:hello-world][status:Finished]

  1. scoringType is not included
2020/08/26 09:07:26 externalhandler.go:89: [RestExternalInterface] APIV1RequestServicePost
2020/08/26 09:07:26 externalhandler.go:153: port:  54350
2020/08/26 09:07:26 senderresolver.go:70: returning:  curl
2020/08/26 09:07:26 externalhandler.go:158: requester:  curl
2020/08/26 09:07:26 orchestration_api.go:124: [RequestService] hello-world: [{container [docker run -v /var/run:/var/run:rw hello-world] map[]}]
2020/08/26 09:07:26 orchestration_api.go:150: [RequestService] getCandidate
2020/08/26 09:07:26 orchestration_api.go:152: [0] Id       : edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243
2020/08/26 09:07:26 orchestration_api.go:153: [0] ExecType : container
2020/08/26 09:07:26 orchestration_api.go:154: [0] Endpoint : [10.113.70.227]
2020/08/26 09:07:26 orchestration_api.go:155:
2020/08/26 09:07:26 orchestration_api.go:152: [1] Id       : edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415
2020/08/26 09:07:26 orchestration_api.go:153: [1] ExecType : container
2020/08/26 09:07:26 orchestration_api.go:154: [1] Endpoint : [10.113.71.53]
2020/08/26 09:07:26 orchestration_api.go:155:
2020/08/26 09:07:26 restclient.go:121: [restclient] DoGetScoreRemoteDevice : endpoint[10.113.70.227]
2020/08/26 09:07:26 orchestration_api.go:334: [orchestrationapi] deviceScore
2020/08/26 09:07:26 orchestration_api.go:335: candidate Id       : edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415
2020/08/26 09:07:26 orchestration_api.go:336: candidate ExecType : container
2020/08/26 09:07:26 orchestration_api.go:337: candidate Endpoint : 10.113.71.53
2020/08/26 09:07:26 orchestration_api.go:338: candidate score    : 10.519956207454118
2020/08/26 09:07:26 restclient.go:146: [restclient] respMsg From [10.113.70.227] : map[ScoreValue:16.821653074808697]
2020/08/26 09:07:26 orchestration_api.go:334: [orchestrationapi] deviceScore
2020/08/26 09:07:26 orchestration_api.go:335: candidate Id       : edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243
2020/08/26 09:07:26 orchestration_api.go:336: candidate ExecType : container
2020/08/26 09:07:26 orchestration_api.go:337: candidate Endpoint : 10.113.70.227
2020/08/26 09:07:26 orchestration_api.go:338: candidate score    : 16.821653074808697
2020/08/26 09:07:26 restclient.go:62: [restclient] DoExecuteRemoteDevice : endpoint[10.113.70.227]
2020/08/26 09:07:26 restclient.go:85: [restclient] respMsg From [10.113.70.227] : map[Status:Started]
2020/08/26 09:07:26 orchestration_api.go:240: [orchestrationapi]  [{edge-orchestration-1ffe80c4-6b60-4ae2-8b3a-68b9d803c243 10.113.70.227 16.821653074808697 map[] container} {edge-orchestration-f323e2a4-624b-4eb7-8da2-a6b9b2813415 10.113.71.53 10.519956207454118 map[] container}]
2020/08/26 09:07:26 route.go:125: From [10.113.71.53:54350] POST /api/v1/orchestration/services APIV1RequestServicePost 179.182239ms
2020/08/26 09:07:31 internalhandler.go:189: [RestInternalInterface] APIV1ServicemgrServicesNotificationServiceIDPost
2020/08/26 09:07:31 orchestration_api.go:444: [orchestrationapi] service status changed [appNames:hello-world][status:Finished]
2020/08/26 09:07:31 route.go:125: From [10.113.70.227:54508] POST /api/v1/servicemgr/services/notification/1 APIV1ServicemgrServicesNotificationServiceIDPost 2.064848ms

Test Configuration:

  • Firmware version: Ubuntu 16.04, RPi2
  • Hardware: x86-64, ARM
  • Edge Orchestration Release: Baobab

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

tiokim added 3 commits August 26, 2020 09:26
 - REST API to fetch resource information of an edge device
 - Calculate scores based on the collected resources from all edge devices

Signed-off-by: Taewan Kim <[email protected]>
Copy link
Contributor

@MoonkiHong MoonkiHong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it allows multiple approaches to get capabilities for the offloading target candidate as well as the existing scoring manager, it is good to me.

@MoonkiHong
Copy link
Contributor

Since it allows multiple approaches to get capabilities for the offloading target candidate as well as the existing scoring manager, it is good to me.

@t25kim Merged. We are expecting your upcoming suggestion and contributions to fully cover the enhancement of the calculation mechanism as well as allowing maximum flexibility to developers to leave the current mechanism as it is from our community.

@MoonkiHong MoonkiHong merged commit 22ce49b into lf-edge:master Sep 10, 2020
@tiokim tiokim deleted the c_mgt branch September 10, 2020 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants