Skip to content

Commit 314c7dc

Browse files
committed
Made Regex variables global
1 parent 7b7fb6b commit 314c7dc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/controller/queuejob/queuejob_controller_ex.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ import (
6767
// defaultBackoffTime is the default backoff time in seconds
6868
const defaultBackoffTime = 20
6969

70+
var (
71+
// Regex variables for extracting resource values
72+
cpuRegex = regexp.MustCompile(`cpu (\d+(\.\d+)?)`)
73+
memoryRegex = regexp.MustCompile(`memory (\d+(\.\d+)?)`)
74+
gpuRegex = regexp.MustCompile(`GPU (\d+)`)
75+
)
76+
7077
// XController the AppWrapper Controller type
7178
type XController struct {
7279
// MCAD configuration
@@ -972,10 +979,6 @@ func (qjm *XController) nodeChecks(histograms map[string]*dto.Metric, aw *arbv1.
972979

973980
// Function for calculating required resources to run AppWrapper and printing a log if there is a required increase for resources.
974981
func calculateRequiredResources(namespace string, appwrapperName string, requestedResources string, totalAvailable string) {
975-
cpuRegex := regexp.MustCompile(`cpu (\d+(\.\d+)?)`)
976-
memoryRegex := regexp.MustCompile(`memory (\d+(\.\d+)?)`)
977-
gpuRegex := regexp.MustCompile(`GPU (\d+)`)
978-
979982
// Requested resources values //
980983
requestedCPU := cpuRegex.FindStringSubmatch(requestedResources)
981984
requestedMemory := memoryRegex.FindStringSubmatch(requestedResources)

0 commit comments

Comments
 (0)