Skip to content

Commit 3b0d907

Browse files
authored
endpoint and monitoring schedule - requeue on delete (#93)
Description of changes: - add requeue on delete for endpoint and monitoring schedule - corresponding integ test changes - monitoring schedule custom code refactor to use common pkg - return the status of observed resource from sdkFind post delete Testing: ``` pytest tests/test_monitoring_schedule.py pytest tests/test_endpoint.py ``` PR build Pending: rebase on #92 for unit tests to pass By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent cf4b8b9 commit 3b0d907

File tree

25 files changed

+188
-148
lines changed

25 files changed

+188
-148
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
ack_generate_info:
2-
build_date: "2021-09-01T01:05:16Z"
2+
build_date: "2021-09-01T08:44:58Z"
33
build_hash: 07d7ea755625b2cac93bbf293bf5a8cab24ecb68
44
go_version: go1.16.4 linux/amd64
55
version: v0.13.0
66
api_directory_checksum: a0f6457435f0a16addd9cf7d0acef2830722bd78
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.38.11
99
generator_config_info:
10-
file_checksum: 5431bfc09117e092ee89a98edcbad6934363dea2
10+
file_checksum: 8624689ea5b08289d25ad897c5f8cf5afc96b0ea
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation
14-
timestamp: 2021-09-01 01:05:19.682637714 +0000 UTC
14+
timestamp: 2021-09-01 08:45:01.42242216 +0000 UTC

apis/v1alpha1/generator.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ resources:
8080
code: rm.customUpdateEndpointSetOutput(ko)
8181
sdk_delete_pre_build_request:
8282
template_path: common/sdk_delete_pre_build_request.go.tpl
83+
sdk_delete_post_request:
84+
template_path: common/sdk_delete_post_request.go.tpl
8385
fields:
8486
EndpointStatus:
8587
is_read_only: true
@@ -402,16 +404,16 @@ resources:
402404
- InvalidParameterValue
403405
- MissingParameter
404406
hooks:
405-
sdk_create_post_set_output:
406-
code: rm.customSetOutput(desired, aws.String("Pending"), ko)
407407
sdk_read_one_post_set_output:
408-
code: rm.customSetOutput(r, resp.MonitoringScheduleStatus, ko)
408+
code: rm.customSetOutput(&resource{ko}, resp.MonitoringScheduleStatus)
409409
sdk_update_pre_build_request:
410-
template_path: monitoring_schedule/sdk_update_pre_build_request.go.tpl
410+
template_path: common/sdk_update_pre_build_request.go.tpl
411411
sdk_update_post_set_output:
412-
code: rm.customSetOutput(desired, aws.String("Pending"), ko)
412+
code: rm.customSetOutput(&resource{ko}, aws.String("Pending"))
413413
sdk_delete_pre_build_request:
414-
template_path: monitoring_schedule/sdk_delete_pre_build_request.go.tpl
414+
template_path: common/sdk_delete_pre_build_request.go.tpl
415+
sdk_delete_post_request:
416+
template_path: common/sdk_delete_post_request.go.tpl
415417
fields:
416418
MonitoringScheduleStatus:
417419
is_read_only: true
@@ -475,7 +477,7 @@ resources:
475477
sdk_read_one_post_build_request:
476478
template_path: model_package/set_resource_name_as_arn.go.tpl
477479
sdk_update_pre_build_request:
478-
template_path: model_package/sdk_update_pre_build_request.go.tpl
480+
template_path: common/sdk_update_pre_build_request.go.tpl
479481
sdk_create_post_build_request:
480482
template_path: model_package/sdk_create_post_build_request.go.tpl
481483
fields:

generator.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ resources:
8080
code: rm.customUpdateEndpointSetOutput(ko)
8181
sdk_delete_pre_build_request:
8282
template_path: common/sdk_delete_pre_build_request.go.tpl
83+
sdk_delete_post_request:
84+
template_path: common/sdk_delete_post_request.go.tpl
8385
fields:
8486
EndpointStatus:
8587
is_read_only: true
@@ -402,16 +404,16 @@ resources:
402404
- InvalidParameterValue
403405
- MissingParameter
404406
hooks:
405-
sdk_create_post_set_output:
406-
code: rm.customSetOutput(desired, aws.String("Pending"), ko)
407407
sdk_read_one_post_set_output:
408-
code: rm.customSetOutput(r, resp.MonitoringScheduleStatus, ko)
408+
code: rm.customSetOutput(&resource{ko}, resp.MonitoringScheduleStatus)
409409
sdk_update_pre_build_request:
410-
template_path: monitoring_schedule/sdk_update_pre_build_request.go.tpl
410+
template_path: common/sdk_update_pre_build_request.go.tpl
411411
sdk_update_post_set_output:
412-
code: rm.customSetOutput(desired, aws.String("Pending"), ko)
412+
code: rm.customSetOutput(&resource{ko}, aws.String("Pending"))
413413
sdk_delete_pre_build_request:
414-
template_path: monitoring_schedule/sdk_delete_pre_build_request.go.tpl
414+
template_path: common/sdk_delete_pre_build_request.go.tpl
415+
sdk_delete_post_request:
416+
template_path: common/sdk_delete_post_request.go.tpl
415417
fields:
416418
MonitoringScheduleStatus:
417419
is_read_only: true
@@ -475,7 +477,7 @@ resources:
475477
sdk_read_one_post_build_request:
476478
template_path: model_package/set_resource_name_as_arn.go.tpl
477479
sdk_update_pre_build_request:
478-
template_path: model_package/sdk_update_pre_build_request.go.tpl
480+
template_path: common/sdk_update_pre_build_request.go.tpl
479481
sdk_create_post_build_request:
480482
template_path: model_package/sdk_create_post_build_request.go.tpl
481483
fields:

pkg/resource/endpoint/hooks.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ package endpoint
1515

1616
import (
1717
"context"
18+
"errors"
1819
"fmt"
1920
"strings"
2021

2122
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
23+
ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue"
2224
svcapitypes "github.com/aws-controllers-k8s/sagemaker-controller/apis/v1alpha1"
2325
svccommon "github.com/aws-controllers-k8s/sagemaker-controller/pkg/common"
2426
"github.com/aws/aws-sdk-go/aws"
@@ -40,6 +42,11 @@ var (
4042
lastEndpointConfigForUpdateAnnotation = fmt.Sprintf("%s/last-endpoint-config-for-update", resourceGK.Group)
4143

4244
FailureReasonInternalServiceErrorPrefix = "Request to service failed"
45+
46+
requeueWaitWhileDeleting = ackrequeue.NeededAfter(
47+
errors.New(resourceName+" is Deleting."),
48+
ackrequeue.DefaultRequeueAfterDuration,
49+
)
4350
)
4451

4552
// customDescribeEndpointSetOutput sets the resource ResourceSynced condition to False if endpoint is

pkg/resource/endpoint/sdk.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"CreationTime": "0001-01-01T00:00:00.109Z",
3+
"DataCaptureConfig": null,
4+
"EndpointArn": "arn:aws:sagemaker:us-west-2:123456789012:endpoint/xgboost-endpoint",
5+
"EndpointConfigName": "xgboost-endpoint-single-variant-config",
6+
"EndpointName": "xgboost-endpoint",
7+
"EndpointStatus": "Deleting",
8+
"FailureReason": null,
9+
"LastDeploymentConfig": null,
10+
"LastModifiedTime": "0001-01-01T00:00:00.109Z",
11+
"ProductionVariants": [
12+
{
13+
"CurrentInstanceCount": 2,
14+
"CurrentWeight": 1,
15+
"DeployedImages": [
16+
{
17+
"ResolutionTime": "0001-01-01T00:00:00.109Z",
18+
"ResolvedImage": "433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost@sha256:54004f910467ebf7cfa71b5523b81695d103abf21a37d38dc84d63ab8d510c35",
19+
"SpecifiedImage": "433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest"
20+
}
21+
],
22+
"DesiredInstanceCount": 2,
23+
"DesiredWeight": 1,
24+
"VariantName": "variant-1"
25+
}
26+
]
27+
}
28+

pkg/resource/endpoint/testdata/test_suite.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ tests:
185185
desired_state: "v1alpha1/delete/desired/inservice_before_delete.yaml"
186186
svc_api:
187187
- operation: DeleteEndpointWithContext
188+
- operation: DescribeEndpointWithContext
189+
output_fixture: "sdkapi/describe/deleting.json"
188190
invoke: Delete
189191
expect:
190-
error: nil
191-
# TODO: add test for wait until deleted. Feature to be implemented in a separate PR
192+
latest_state: "v1alpha1/delete/observed/deleting_no_error.yaml"
193+
error: "Endpoint is Deleting."
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: sagemaker.services.k8s.aws/v1alpha1
2+
kind: Endpoint
3+
metadata:
4+
creationTimestamp: null
5+
name: xgboost-endpoint
6+
spec:
7+
endpointConfigName: xgboost-endpoint-single-variant-config
8+
endpointName: xgboost-endpoint
9+
tags:
10+
- key: confidentiality
11+
value: public
12+
- key: environment
13+
value: testing
14+
- key: customer
15+
value: test-user
16+
status:
17+
ackResourceMetadata:
18+
arn: arn:aws:sagemaker:us-west-2:123456789012:endpoint/xgboost-endpoint
19+
ownerAccountID: ""
20+
conditions:
21+
- lastTransitionTime: "0001-01-01T00:00:00Z"
22+
message: Endpoint is in Deleting status.
23+
status: "False"
24+
type: ACK.ResourceSynced
25+
- message: Endpoint is Deleting.
26+
status: "True"
27+
type: ACK.Recoverable
28+
creationTime: "0001-01-01T00:00:00Z"
29+
endpointStatus: Deleting
30+
lastModifiedTime: "0001-01-01T00:00:00Z"
31+
productionVariants:
32+
- currentInstanceCount: 2
33+
currentWeight: 1
34+
deployedImages:
35+
- resolutionTime: "0001-01-01T00:00:00Z"
36+
resolvedImage: 433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost@sha256:54004f910467ebf7cfa71b5523b81695d103abf21a37d38dc84d63ab8d510c35
37+
specifiedImage: 433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest
38+
desiredInstanceCount: 2
39+
desiredWeight: 1
40+
variantName: variant-1

pkg/resource/feature_group/sdk.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/hyper_parameter_tuning_job/sdk.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)