Merge branch 'aurora-scheduler:main' into master

This commit is contained in:
lenhattan86 2021-10-05 17:18:47 -07:00 committed by GitHub
commit c6adde03af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -103,6 +103,9 @@ func init() {
// Fetch Status
fetchCmd.AddCommand(fetchStatusCmd)
// fetch quota
fetchCmd.AddCommand(fetchQuotaCmd)
}
var fetchCmd = &cobra.Command{
@ -173,6 +176,13 @@ var fetchStatusCmd = &cobra.Command{
Run: fetchHostStatus,
}
var fetchQuotaCmd = &cobra.Command{
Use: "quota",
Short: "Fetch the quotas of given roles",
Long: `This command will print list of resource quotas with the aggregated resources for the given roles`,
Run: fetchQuota,
}
func fetchTasksConfig(cmd *cobra.Command, args []string) {
log.Infof("Fetching job configuration for [%s/%s/%s] \n", *env, *role, *name)
@ -381,3 +391,28 @@ func fetchJobs(cmd *cobra.Command, args []string) {
}
}
}
//fetchQuota gets quotas for roles in args
func fetchQuota(cmd *cobra.Command, args []string) {
for _, role := range args {
log.Infof("Fetching quota for role: %s \n", role)
result, err := client.GetQuota(role)
if err != nil {
log.Fatalf("error: %+v\n", err)
}
if toJson {
fmt.Println(internal.ToJSON(result))
} else {
fmt.Printf(" Quota: %v\n", internal.ToJSON(result.Quota.GetResources()))
fmt.Printf(" Aggregated Resources: \n")
fmt.Printf(" ProdSharedConsumption: %v\n", internal.ToJSON(result.ProdSharedConsumption.GetResources()))
fmt.Printf(" NonProdSharedConsumption: %v\n",
internal.ToJSON(result.NonProdSharedConsumption.GetResources()))
fmt.Printf(" ProdDedicatedConsumption: %v\n",
internal.ToJSON(result.ProdDedicatedConsumption.GetResources()))
fmt.Printf(" NonProdDedicatedConsumption: %v\n",
internal.ToJSON(result.NonProdDedicatedConsumption.GetResources()))
}
}
}

View file

@ -71,6 +71,7 @@ type Job struct {
URIs []URI `yaml:"uris"`
Metadata map[string]string `yaml:"labels"`
Service bool `yaml:"service"`
Priority int32 `yaml:"priority"`
Thermos []ThermosProcess `yaml:",flow,omitempty"`
Container *Container `yaml:"container,omitempty"`
CronSchedule *string `yaml:"cronSchedule,omitempty"`
@ -88,6 +89,7 @@ func (j *Job) ToRealis() (*realis.AuroraJob, error) {
RAM(j.RAM).
Disk(j.Disk).
IsService(j.Service).
Priority(j.Priority).
InstanceCount(j.Instances).
MaxFailure(j.MaxFailures)