From c220d9c4a5ccbcf1780ff882923b037f5ef2e46d Mon Sep 17 00:00:00 2001 From: Frikky Date: Tue, 23 Jan 2024 01:30:11 +0100 Subject: [PATCH] Minor fixes for queue management onprem --- frontend/src/components/BillingStats.jsx | 6 +- frontend/src/views/Admin.jsx | 105 +++++++++++++---------- functions/onprem/orborus/orborus.go | 37 +++++--- 3 files changed, 91 insertions(+), 57 deletions(-) diff --git a/frontend/src/components/BillingStats.jsx b/frontend/src/components/BillingStats.jsx index 81ea7100..a91c275a 100644 --- a/frontend/src/components/BillingStats.jsx +++ b/frontend/src/components/BillingStats.jsx @@ -421,7 +421,11 @@ const AppStats = (defaultprops) => { }> - ${apprunCost} + {selectedOrganization.lead_info.customer === false && selectedOrganization.lead_info.pov === false ? + 0 + : + apprunCost + } Period Cost diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index be7711af..1bacd611 100755 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -1011,62 +1011,62 @@ If you're interested, please let me know a time that works for you, or set up a responseJson.sync_features = {}; } - if (responseJson.lead_info !== undefined && responseJson.lead_info !== null) { - var leads = [] - if (responseJson.lead_info.contacted) { - leads.push("contacted") - } + if (responseJson.lead_info !== undefined && responseJson.lead_info !== null) { + var leads = [] + if (responseJson.lead_info.contacted) { + leads.push("contacted") + } - if (responseJson.lead_info.customer) { - leads.push("customer") - } + if (responseJson.lead_info.customer) { + leads.push("customer") + } - if (responseJson.lead_info.old_customer) { - leads.push("old customer") - } + if (responseJson.lead_info.old_customer) { + leads.push("old customer") + } - if (responseJson.lead_info.old_lead) { - leads.push("old lead") - } + if (responseJson.lead_info.old_lead) { + leads.push("old lead") + } - if (responseJson.lead_info.tech_partner) { - leads.push("tech partner") - } + if (responseJson.lead_info.tech_partner) { + leads.push("tech partner") + } - if (responseJson.lead_info.creator) { - leads.push("creator") - } + if (responseJson.lead_info.creator) { + leads.push("creator") + } - if (responseJson.lead_info.opensource) { - leads.push("open source") - } + if (responseJson.lead_info.opensource) { + leads.push("open source") + } - if (responseJson.lead_info.demo_done) { - leads.push("demo done") - } + if (responseJson.lead_info.demo_done) { + leads.push("demo done") + } - if (responseJson.lead_info.pov) { - leads.push("pov") - } + if (responseJson.lead_info.pov) { + leads.push("pov") + } - if (responseJson.lead_info.lead) { - leads.push("lead") - } + if (responseJson.lead_info.lead) { + leads.push("lead") + } - if (responseJson.lead_info.student) { - leads.push("student") - } + if (responseJson.lead_info.student) { + leads.push("student") + } - if (responseJson.lead_info.internal) { - leads.push("internal") - } + if (responseJson.lead_info.internal) { + leads.push("internal") + } - if (responseJson.lead_info.sub_org) { - leads.push("sub_org") - } + if (responseJson.lead_info.sub_org) { + leads.push("sub_org") + } - setSelectedStatus(leads) - } + setSelectedStatus(leads) + } setSelectedOrganization(responseJson) var lists = { @@ -1503,6 +1503,19 @@ If you're interested, please let me know a time that works for you, or set up a }) .then((responseJson) => { setEnvironments(responseJson); + + // Helper info for users in case they have a large queue and don't know about queue flushing + if (responseJson !== undefined && responseJson !== null && responseJson.length > 0) { + for (var i = 0; i < responseJson.length; i++) { + const env = responseJson[i]; + + // Check if queuesize is too large + if (env.queue !== undefined && env.queue !== null && env.queue > 100) { + toast("Queue size for " + env.name + " is very large. We recommend you to reduce it by flushing the queue before continuing."); + break + } + } + } }) .catch((error) => { toast(error.toString()); @@ -2405,6 +2418,10 @@ If you're interested, please let me know a time that works for you, or set up a { + if (!isCloud || userdata.support !== true) { + return + } + e.preventDefault(); e.stopPropagation(); @@ -4269,7 +4286,7 @@ If you're interested, please let me know a time that works for you, or set up a //console.log("Show CPU alert: ", showCPUAlert) - const queueSize = environment.queue !== undefined && environment.queue !== null ? environment.queue < 0 ? 0 : environment.queue > 99 ? ">99" : environment.queue : 0 + const queueSize = environment.queue !== undefined && environment.queue !== null ? environment.queue < 0 ? 0 : environment.queue > 1000 ? ">1000" : environment.queue : 0 return ( diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index ed141a1d..793fe383 100755 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -396,16 +396,16 @@ func deployServiceWorkers(image string) { } innerContainerName := fmt.Sprintf("shuffle-workers") - cnt, _ := findActiveSwarmNodes() + cnt, err := findActiveSwarmNodes() + if err != nil { + log.Printf("[ERROR] Failed to find active swarm nodes: %s. Defaulting to 1", err) + } + nodeCount := uint64(1) if cnt > 0 { nodeCount = uint64(cnt) } - if cnt == 0 { - cnt = 1 - } - appReplicas := os.Getenv("SHUFFLE_APP_REPLICAS") appReplicaCnt := 1 if len(appReplicas) > 0 { @@ -477,6 +477,7 @@ func deployServiceWorkers(image string) { fmt.Sprintf("SHUFFLE_LOGS_DISABLED=%s", os.Getenv("SHUFFLE_LOGS_DISABLED")), fmt.Sprintf("DEBUG_MEMORY=%s", os.Getenv("DEBUG_MEMORY")), fmt.Sprintf("SHUFFLE_APP_SDK_TIMEOUT=%s", os.Getenv("SHUFFLE_APP_SDK_TIMEOUT")), + fmt.Sprintf("SHUFFLE_MAX_SWARM_NODES=%d", os.Getenv("SHUFFLE_MAX_SWARM_NODES")), }, //Hosts: []string{ // innerContainerName, @@ -927,7 +928,7 @@ func findActiveSwarmNodes() (int64, error) { ctx := context.Background() nodes, err := dockercli.NodeList(ctx, types.NodeListOptions{}) if err != nil { - return 0, err + return 1, err } nodeCount := int64(0) @@ -938,13 +939,21 @@ func findActiveSwarmNodes() (int64, error) { } } - return nodeCount, nil + // Check for SHUFFLE_MAX_NODES + // Make it into a number and check if it's lower than nodeCount + maxNodesString := os.Getenv("SHUFFLE_MAX_SWARM_NODES") + if len(maxNodesString) > 0 { + maxNodes, err := strconv.ParseInt(maxNodesString, 10, 64) + if err != nil { + return nodeCount, err + } - /* - containers, err := dockercli.ContainerList(ctx, types.ContainerListOptions{ - All: true, - }) - */ + if nodeCount > maxNodes { + nodeCount = maxNodes + } + } + + return nodeCount, nil } // Get IP @@ -1634,6 +1643,10 @@ func main() { env = append(env, fmt.Sprintf("SHUFFLE_INTERNAL_HTTPS_PROXY=%s", overrideHttpsProxy)) } + if len(os.Getenv("SHUFFLE_MAX_SWARM_NODES")) > 0 { + env = append(env, fmt.Sprintf("SHUFFLE_MAX_SWARM_NODES=%s", os.Getenv("SHUFFLE_MAX_SWARM_NODES"))) + } + err = deployWorker(workerImage, containerName, env, execution) zombiecounter += 1 if err == nil {