Skip to content

Commit

Permalink
enable deletion of resource if job is complete (aws-controllers-k8s#16)
Browse files Browse the repository at this point in the history
- enable deletion of resource if job is complete
- reduce custom code by using callback hooks
  • Loading branch information
surajkota authored and ryansteakley committed May 18, 2021
1 parent 63f766f commit 526ae9c
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 8 deletions.
47 changes: 39 additions & 8 deletions generator.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
operations:
<<<<<<< HEAD
<<<<<<< HEAD
=======
CreateTrainingJob:
set_output_custom_method_name: customCreateTrainingJobSetOutput
>>>>>>> 5eb5b19 (Add Requeue logic for Job Style resources till completion (#10))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
DescribeTrainingJob:
set_output_custom_method_name: customDescribeTrainingJobSetOutput
StopTrainingJob:
operation_type: Delete
resource_name: TrainingJob
CreateProcessingJob:
set_output_custom_method_name: customCreateProcessingJobSetOutput
DescribeProcessingJob:
set_output_custom_method_name: customDescribeProcessingJobSetOutput
StopProcessingJob:
operation_type: Delete
resource_name: ProcessingJob
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
=======
CreateTransformJob:
set_output_custom_method_name: customCreateTransformJobSetOutput
Expand All @@ -37,6 +37,11 @@ operations:
CreateEndpoint:
set_output_custom_method_name: customCreateEndpointSetOutput
>>>>>>> 03f0cbe (Introduce endpointconfig and endpoint controller)
=======
StopTransformJob:
operation_type: Delete
resource_name: TransformJob
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
DescribeEndpoint:
set_output_custom_method_name: customDescribeEndpointSetOutput
UpdateEndpoint:
Expand All @@ -50,10 +55,6 @@ operations:
RetainAllVariantProperties: true
DeleteEndpoint:
custom_implementation: customDeleteEndpoint
CreateHyperParameterTuningJob:
set_output_custom_method_name: customCreateHyperParameterTuningJobSetOutput
DescribeHyperParameterTuningJob:
set_output_custom_method_name: customDescribeHyperParameterTuningJobSetOutput
StopHyperParameterTuningJob:
operation_type: Delete
resource_name: HyperParameterTuningJob
Expand Down Expand Up @@ -151,6 +152,7 @@ resources:
- MalformedQueryString
- InvalidAction
- UnrecognizedClientException
<<<<<<< HEAD
<<<<<<< HEAD
# Custom error
- EndpointUpdateError
Expand All @@ -161,6 +163,11 @@ resources:
>>>>>>> 03f0cbe (Introduce endpointconfig and endpoint controller)
=======
>>>>>>> 5ccff0e (Adding Terminal Conditions (#12))
=======
hooks:
sdk_create_post_set_output:
code: rm.customSetOutput(r, aws.String(svcsdk.EndpointStatusCreating), ko)
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
fields:
EndpointStatus:
is_read_only: true
Expand Down Expand Up @@ -252,13 +259,19 @@ resources:
- InvalidAction
- UnrecognizedClientException
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
hooks:
sdk_create_post_set_output:
code: rm.customSetOutput(r, aws.String(svcsdk.TrainingJobStatusInProgress), ko)
sdk_delete_pre_build_request:
template_path: training_job/sdk_delete_pre_build_request.go.tpl
<<<<<<< HEAD
=======
>>>>>>> 5ccff0e (Adding Terminal Conditions (#12))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
fields:
TrainingJobStatus:
is_read_only: true
Expand Down Expand Up @@ -304,15 +317,21 @@ resources:
- InvalidAction
- UnrecognizedClientException
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
hooks:
sdk_delete_pre_build_request:
template_path: processing_job/sdk_delete_pre_build_request.go.tpl
sdk_create_post_set_output:
code: rm.customSetOutput(r, aws.String(svcsdk.ProcessingJobStatusInProgress), ko)
sdk_read_one_post_set_output:
code: rm.customSetOutput(r, resp.ProcessingJobStatus, ko)
<<<<<<< HEAD
=======
>>>>>>> 5ccff0e (Adding Terminal Conditions (#12))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
fields:
ProcessingJobStatus:
is_read_only: true
Expand Down Expand Up @@ -351,17 +370,23 @@ resources:
- InvalidAction
- UnrecognizedClientException
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
hooks:
sdk_delete_pre_build_request:
template_path: transform_job/sdk_delete_pre_build_request.go.tpl
sdk_create_post_set_output:
code: rm.customSetOutput(r, aws.String(svcsdk.TransformJobStatusInProgress), ko)
sdk_read_one_post_set_output:
code: rm.customSetOutput(r, resp.TransformJobStatus, ko)
<<<<<<< HEAD
=======
>>>>>>> 5e70629 (Adding Transform Job (#4))
=======
>>>>>>> 5ccff0e (Adding Terminal Conditions (#12))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
fields:
TransformJobStatus:
is_read_only: true
Expand Down Expand Up @@ -403,17 +428,23 @@ resources:
- InvalidAction
- UnrecognizedClientException
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
hooks:
sdk_delete_pre_build_request:
template_path: hyper_parameter_tuning_job/sdk_delete_pre_build_request.go.tpl
sdk_create_post_set_output:
code: rm.customSetOutput(r, aws.String(svcsdk.HyperParameterTuningJobStatusInProgress), ko)
sdk_read_one_post_set_output:
code: rm.customSetOutput(r, resp.HyperParameterTuningJobStatus, ko)
<<<<<<< HEAD
=======
>>>>>>> d40a0ca (HyperParameterJob controller (#5))
=======
>>>>>>> 5ccff0e (Adding Terminal Conditions (#12))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
fields:
HyperParameterTuningJobStatus:
is_read_only: true
Expand Down
8 changes: 8 additions & 0 deletions pkg/resource/endpoint/custom_set_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
corev1 "k8s.io/api/core/v1"
)

<<<<<<< HEAD
<<<<<<< HEAD
// customDescribeEndpointSetOutput sets the resource ResourceSynced condition to False if endpoint is
=======
Expand All @@ -43,6 +44,9 @@ func (rm *resourceManager) customCreateEndpointSetOutput(

// customDescribeEndpointSetOutput sets the resource in TempOutofSync if endpoint is
>>>>>>> 03f0cbe (Introduce endpointconfig and endpoint controller)
=======
// customDescribeEndpointSetOutput sets the resource ResourceSynced condition to False if endpoint is
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
// being modified by AWS
func (rm *resourceManager) customDescribeEndpointSetOutput(
ctx context.Context,
Expand Down Expand Up @@ -79,8 +83,12 @@ func (rm *resourceManager) customDescribeEndpointSetOutput(
return ko, nil
}

<<<<<<< HEAD
// customUpdateEndpointSetOutput sets the resource in TempOutofSync if endpoint is
>>>>>>> 03f0cbe (Introduce endpointconfig and endpoint controller)
=======
// customUpdateEndpointSetOutput sets the resource ResourceSynced condition to False if endpoint is
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
// being updated. At this stage we know call to updateEndpoint was successful.
func (rm *resourceManager) customUpdateEndpointSetOutput(
ctx context.Context,
Expand Down
4 changes: 4 additions & 0 deletions pkg/resource/endpoint/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/resource/hyper_parameter_tuning_job/custom_set_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package hyper_parameter_tuning_job

import (
<<<<<<< HEAD
<<<<<<< HEAD
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
Expand All @@ -27,10 +28,15 @@ import (
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
"github.com/aws/aws-sdk-go/aws"
>>>>>>> 5eb5b19 (Add Requeue logic for Job Style resources till completion (#10))
=======
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
svcsdk "github.com/aws/aws-sdk-go/service/sagemaker"
corev1 "k8s.io/api/core/v1"
)

<<<<<<< HEAD
<<<<<<< HEAD
=======
// customCreateHyperParameterTuningJobSetOutput sets the resource in TempOutofSync if HyperParameterTuningJob is
Expand Down Expand Up @@ -58,6 +64,8 @@ func (rm *resourceManager) customDescribeHyperParameterTuningJobSetOutput(
}

>>>>>>> 5eb5b19 (Add Requeue logic for Job Style resources till completion (#10))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
// customSetOutput sets ConditionTypeResourceSynced condition to True or False
// based on the hyperParameterTuningJobStatus on AWS so the reconciler can determine if a
// requeue is needed
Expand Down
14 changes: 14 additions & 0 deletions pkg/resource/hyper_parameter_tuning_job/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/resource/processing_job/custom_set_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package processing_job

import (
<<<<<<< HEAD
<<<<<<< HEAD
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
Expand All @@ -27,10 +28,15 @@ import (
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
"github.com/aws/aws-sdk-go/aws"
>>>>>>> 5eb5b19 (Add Requeue logic for Job Style resources till completion (#10))
=======
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
svcsdk "github.com/aws/aws-sdk-go/service/sagemaker"
corev1 "k8s.io/api/core/v1"
)

<<<<<<< HEAD
<<<<<<< HEAD
=======
// customCreateProcessingJobSetOutput sets the resource in TempOutofSync if ProcessingJob is
Expand Down Expand Up @@ -58,6 +64,8 @@ func (rm *resourceManager) customDescribeProcessingJobSetOutput(
}

>>>>>>> 5eb5b19 (Add Requeue logic for Job Style resources till completion (#10))
=======
>>>>>>> 3c1fc55 (enable deletion of resource if job is complete (#16))
// customSetOutput sets ConditionTypeResourceSynced condition to True or False
// based on the processingJobStatus on AWS so the reconciler can determine if a
// requeue is needed
Expand Down
14 changes: 14 additions & 0 deletions pkg/resource/processing_job/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 526ae9c

Please sign in to comment.