diff --git a/pkg/controller/queuejob/queuejob_controller_ex.go b/pkg/controller/queuejob/queuejob_controller_ex.go index dacb5f07..7d49b2c6 100644 --- a/pkg/controller/queuejob/queuejob_controller_ex.go +++ b/pkg/controller/queuejob/queuejob_controller_ex.go @@ -67,6 +67,13 @@ import ( // defaultBackoffTime is the default backoff time in seconds const defaultBackoffTime = 20 +var ( + // Regex variables for extracting resource values + cpuRegex = regexp.MustCompile(`cpu (\d+(\.\d+)?)`) + memoryRegex = regexp.MustCompile(`memory (\d+(\.\d+)?)`) + gpuRegex = regexp.MustCompile(`GPU (\d+)`) +) + // XController the AppWrapper Controller type type XController struct { // MCAD configuration @@ -972,10 +979,6 @@ func (qjm *XController) nodeChecks(histograms map[string]*dto.Metric, aw *arbv1. // Function for calculating required resources to run AppWrapper and printing a log if there is a required increase for resources. func calculateRequiredResources(namespace string, appwrapperName string, requestedResources string, totalAvailable string) { - cpuRegex := regexp.MustCompile(`cpu (\d+(\.\d+)?)`) - memoryRegex := regexp.MustCompile(`memory (\d+(\.\d+)?)`) - gpuRegex := regexp.MustCompile(`GPU (\d+)`) - // Requested resources values // requestedCPU := cpuRegex.FindStringSubmatch(requestedResources) requestedMemory := memoryRegex.FindStringSubmatch(requestedResources)