Skip to content

Commit

Permalink
-add resource JobQueue
Browse files Browse the repository at this point in the history
Signed-off-by: wotolom <car_929@yahoo.de>
  • Loading branch information
wotolom committed May 12, 2022
1 parent ea17dac commit 437f6ed
Show file tree
Hide file tree
Showing 15 changed files with 1,521 additions and 2 deletions.
20 changes: 18 additions & 2 deletions apis/batch/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ignore:
resource_names:
- Job
- SchedulingPolicy
- JobQueue
- JobDefinition
field_paths:
- CreateComputeEnvironmentInput.ServiceRole
Expand All @@ -16,6 +15,11 @@ ignore:
- UpdateComputeEnvironmentInput.ComputeResources.SecurityGroupIds
- CreateComputeEnvironmentInput.ComputeResources.DesiredvCpus
- UpdateComputeEnvironmentInput.ComputeResources.DesiredvCpus
- CreateJobQueueInput.JobQueueName
- CreateJobQueueInput.State
- UpdateJobQueueInput.State
- CreateJobQueueInput.ComputeEnvironmentOrder
- UpdateJobQueueInput.ComputeEnvironmentOrder
resources:
ComputeEnvironment:
fields:
Expand All @@ -28,4 +32,16 @@ resources:
is_read_only: true
from:
operation: DescribeComputeEnvironments
path: ComputeEnvironments.State
path: ComputeEnvironments.State
JobQueue:
fields:
Status:
is_read_only: true
from:
operation: DescribeJobQueues
path: JobQueues.Status
State:
is_read_only: true
from:
operation: DescribeJobQueues
path: JobQueues.State
55 changes: 55 additions & 0 deletions apis/batch/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,58 @@ type CustomComputeEnvironmentParameters struct {
// +optional
SecurityGroupIDSelector *xpv1.Selector `json:"securityGroupIdSelector,omitempty"`
}

// CustomJobQueueParameters includes custom additional fields for JobQueue
type CustomJobQueueParameters struct {
// Custom parameter to control the state of the job queue. The valid values are ENABLED or DISABLED.
//
// The state of the job queue. If the job queue state is ENABLED, it is able to accept jobs.
// If the job queue state is DISABLED, new jobs can't be added to the queue, but jobs already in the queue can finish.
// +optional
DesiredState *string `json:"desiredState,omitempty"`

// The set of compute environments mapped to a job queue and their order relative
// to each other. The job scheduler uses this parameter to determine which compute
// environment should run a specific job. Compute environments must be in the
// VALID state before you can associate them with a job queue. You can associate
// up to three compute environments with a job queue. All of the compute environments
// must be either EC2 (EC2 or SPOT) or Fargate (FARGATE or FARGATE_SPOT); EC2
// and Fargate compute environments can't be mixed.
//
// All compute environments that are associated with a job queue must share
// the same architecture. Batch doesn't support mixing compute environment architecture
// types in a single job queue.
//
// ComputeEnvironmentOrder is a required field
ComputeEnvironmentOrder []*CustomComputeEnvironmentOrder `json:"computeEnvironmentOrder"`
}

// CustomComputeEnvironmentOrder includes custom additional fields for ComputeEnvironmentOrder
type CustomComputeEnvironmentOrder struct {
// The Amazon Resource Name (ARN) of the compute environment.
//
// ComputeEnvironment is a required field
// +crossplane:generate:reference:type=github.com/crossplane/provider-aws/apis/batch/v1alpha1.ComputeEnvironment
// +crossplane:generate:reference:extractor=github.com/crossplane/provider-aws/apis/batch/v1alpha1.ComputeEnvironmentARN()
// +crossplane:generate:reference:refFieldName=ComputeEnvironmentRef
// +crossplane:generate:reference:selectorFieldName=ComputeEnvironmentSelector
ComputeEnvironment *string `json:"computeEnvironment,omitempty"`

// ComputeEnvironmentRef is a reference to ComputeEnvironment used to set
// the ComputeEnvironment.
// +optional
ComputeEnvironmentRef *xpv1.Reference `json:"computeEnvironmentRef,omitempty"`

// ComputeEnvironmentsSelector selects a reference to ComputeEnvironment used
// to set the ComputeEnvironment.
// +optional
ComputeEnvironmentSelector *xpv1.Selector `json:"computeEnvironmentSelector,omitempty"`

// The order of the compute environment. Compute environments are tried in ascending
// order. For example, if two compute environments are associated with a job
// queue, the compute environment with a lower order integer value is tried
// for job placement first.
//
// Order is a required field
Order *int64 `json:"order,omitempty"`
}
20 changes: 20 additions & 0 deletions apis/batch/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v1alpha1

import (
"github.com/crossplane/crossplane-runtime/pkg/reference"
"github.com/crossplane/crossplane-runtime/pkg/resource"
)

// ComputeEnvironmentARN returns ARN of the ComputeEnvironment resource.
func ComputeEnvironmentARN() reference.ExtractValueFn {
return func(mg resource.Managed) string {
cr, ok := mg.(*ComputeEnvironment)
if !ok {
return ""
}
if cr.Status.AtProvider.ComputeEnvironmentARN == nil {
return ""
}
return *cr.Status.AtProvider.ComputeEnvironmentARN
}
}
Loading

0 comments on commit 437f6ed

Please sign in to comment.