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 22, 2023
1 parent d94454d commit b189216
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 @@ -66,6 +66,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 @@ -925,10 +932,6 @@ func (qjm *XController) chooseAgent(ctx context.Context, qj *arbv1.AppWrapper) s

// 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 b189216

Please sign in to comment.