Skip to content

Commit

Permalink
Made Regex variables global
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbins228 committed Nov 8, 2023
1 parent 7b7fb6b commit 314c7dc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 314c7dc

Please sign in to comment.