From 82ec0fbda9ab2090fea542403221be853332e003 Mon Sep 17 00:00:00 2001 From: Rajamohan Raj Date: Wed, 3 Jun 2020 20:57:11 +0000 Subject: Implement Priority Based Controller list As part of this patch, have implemented a priorityQueue based contoller list which shall contain placement contollers and action contollers listed based on their priority. Issue-ID: MULTICLOUD-1064 Signed-off-by: Rajamohan Raj Change-Id: Id1beac6e3b6ec5156f64a169042d171ff28e38d6 --- kud/tests/plugin_collection_v2.sh | 131 +++++++++++++++- src/orchestrator/pkg/appcontext/appcontext.go | 3 +- src/orchestrator/pkg/module/add_intents.go | 1 - src/orchestrator/pkg/module/instantiation.go | 20 ++- .../pkg/module/instantiation_scheduler_helper.go | 169 +++++++++++++++++++++ 5 files changed, 310 insertions(+), 14 deletions(-) create mode 100644 src/orchestrator/pkg/module/instantiation_scheduler_helper.go diff --git a/kud/tests/plugin_collection_v2.sh b/kud/tests/plugin_collection_v2.sh index 5ebed6ad..05ff4265 100755 --- a/kud/tests/plugin_collection_v2.sh +++ b/kud/tests/plugin_collection_v2.sh @@ -82,6 +82,8 @@ deploymentIntentGroupNameDesc="test_deployment_intent_group_desc" releaseName="test" intentToBeAddedinDeploymentIntentGroup="name_of_intent_to_be_added_in_deployment_group" intentToBeAddedinDeploymentIntentGroupDesc="desc_of_intent_to_be_added_in_deployment_group" +hpaIntentName="hpaIntentName" +trafficIntentName="trafficIntentName" chart_name="edgex" profile_name="test_profile" @@ -90,6 +92,28 @@ namespace="plugin-tests-namespace" cloud_region_id="kud" cloud_region_owner="localhost" + +# Controllers +genericPlacementIntent="genericPlacementIntent" +OVNintent="OVNintent" +OVNintentName="OVNintentName" +OVNHostName="OVNHostName" +OVNPort="9027" +CostBasedIntent="costBasedIntent" +CostBasedIntentName="CostBasedIntentName" +CostBasedHostName="OVNHostName" +CostBasedPort="9028" +hpaIntent="hpaIntent" +trafficIntent="trafficIntent" +gpcHostName="gpcHostName" +gpcPort="9029" +hpaControllerIntentName="hpaControllerIntentName" +hpaHostName="hpaHostName" +hpaPort="9030" +trafficControllerIntentName="trafficControllerIntentName" +trafficHostName="trafficHostName" +trafficPort="9031" + # Setup install_deps populate_CSAR_composite_app_helm "$csar_id" @@ -97,7 +121,20 @@ populate_CSAR_composite_app_helm "$csar_id" # BEGIN :: Delete statements are issued so that we clean up the 'orchestrator' collection # and freshly populate the documents, also it serves as a direct test # for all our DELETE APIs and an indirect test for all GET APIs +print_msg "Deleting controller ${genericPlacementIntent}" +delete_resource "${base_url}/controllers/${genericPlacementIntent}" + +print_msg "Deleting controller ${hpaIntent}" +delete_resource "${base_url}/controllers/${hpaIntent}" + +print_msg "Deleting controller ${trafficIntent}" +delete_resource "${base_url}/controllers/${trafficIntent}" +print_msg "Deleting controller ${CostBasedIntent}" +delete_resource "${base_url}/controllers/${CostBasedIntent}" + +print_msg "Deleting controller ${OVNintent}" +delete_resource "${base_url}/controllers/${OVNintent}" print_msg "Deleting intentToBeAddedinDeploymentIntentGroup" delete_resource "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups/${deploymentIntentGroupName}/intents/${intentToBeAddedinDeploymentIntentGroup}" @@ -135,6 +172,9 @@ delete_resource "${base_url}/projects/${project_name}/composite-apps/${composite print_msg "Deleting ${project_name}" delete_resource "${base_url}/projects/${project_name}" + + + # END :: Delete statements were issued so that we clean up the db # and freshly populate the documents, also it serves as a direct test # for all our DELETE APIs and an indirect test for all GET APIs @@ -415,7 +455,7 @@ call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${ # END: Registering DeploymentIntentGroup in the database # BEGIN: Adding intents to an intent group -print_msg "Adding the genericPlacement intent to the deploymentIntent group" +print_msg "Adding all the intents to the deploymentIntent group" payload="$(cat < 0 { + ce := heap.Pop(&pqPlacementCont).(*ControllerElement) + + prioritizedPlaControllerList = append(prioritizedPlaControllerList, ce.controller) + } + + pqActionCont := make(PriorityQueue, len(listAC)) + for i, eachAC := range listAC { + pqActionCont[i] = &ControllerElement{controller: eachAC.controller, index: i} + } + prioritizedActControllerList := make([]controller.Controller, 0) + heap.Init(&pqActionCont) + for pqActionCont.Len() > 0 { + ce := heap.Pop(&pqActionCont).(*ControllerElement) + prioritizedActControllerList = append(prioritizedActControllerList, ce.controller) + } + + prioritizedControlList := PrioritizedControlList{pPlaCont: prioritizedPlaControllerList, pActCont: prioritizedActControllerList} + + return prioritizedControlList, mapOfControllers, nil + +} -- cgit 1.2.3-korg