-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exposing functionality in armadactl, adding tests, modifying preemptO…
…nQueue behaviour, fixing bugs
- Loading branch information
1 parent
4edccef
commit afce23a
Showing
24 changed files
with
709 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package utils | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/armadaproject/armada/pkg/api" | ||
) | ||
|
||
func QueueNameValidation(queueName string) error { | ||
if queueName == "" { | ||
return fmt.Errorf("cannot provide empty queue name") | ||
} | ||
return nil | ||
} | ||
|
||
func LabelSliceAsMap(labels []string) (map[string]string, error) { | ||
mapToReturn := make(map[string]string) | ||
for _, label := range labels { | ||
splitLabel := strings.Split(label, "=") | ||
if len(splitLabel) != 2 { | ||
return nil, fmt.Errorf("invalid label: %s", label) | ||
} | ||
mapToReturn[splitLabel[0]] = splitLabel[1] | ||
} | ||
return mapToReturn, nil | ||
} | ||
|
||
type ActiveJobState string | ||
|
||
const ( | ||
UNKNOWN ActiveJobState = "unknown" | ||
QUEUED ActiveJobState = "queued" | ||
LEASED ActiveJobState = "leased" | ||
PENDING ActiveJobState = "pending" | ||
RUNNING ActiveJobState = "running" | ||
) | ||
|
||
func ActiveJobStateFromString(v string) (ActiveJobState, error) { | ||
switch v { | ||
case "queued": | ||
return QUEUED, nil | ||
case "leased": | ||
return LEASED, nil | ||
case "pending": | ||
return PENDING, nil | ||
case "running": | ||
return RUNNING, nil | ||
default: | ||
return UNKNOWN, errors.New(`must be one of "queued", "leased", "pending", "running"`) | ||
} | ||
} | ||
|
||
func ApiJobStateFromActiveJobState(s ActiveJobState) api.JobState { | ||
switch s { | ||
case QUEUED: | ||
return api.JobState_QUEUED | ||
case LEASED: | ||
return api.JobState_LEASED | ||
case PENDING: | ||
return api.JobState_PENDING | ||
case RUNNING: | ||
return api.JobState_RUNNING | ||
case UNKNOWN: | ||
return api.JobState_UNKNOWN | ||
default: | ||
return api.JobState_UNKNOWN | ||
} | ||
} | ||
|
||
func (s *ActiveJobState) String() string { | ||
return string(*s) | ||
} | ||
|
||
func (s *ActiveJobState) Set(v string) error { | ||
switch v { | ||
case "queued", "leased", "pending", "running": | ||
*s = ActiveJobState(v) | ||
return nil | ||
default: | ||
return errors.New(`must be one of "queued", "leased", "pending", "running"`) | ||
} | ||
} | ||
|
||
func (s *ActiveJobState) Type() string { | ||
return "ActiveJobState" | ||
} |
Oops, something went wrong.