Skip to content

Commit acf5246

Browse files
authored
CLOUDP-299766: support serverless with flex (#2107)
* support serverless with flex * test/helper/e2e switch to flex for basic deployment * fix helm test fixtures * remove deployment contract test as it relies on released AKO version
1 parent 5029061 commit acf5246

File tree

9 files changed

+186
-316
lines changed

9 files changed

+186
-316
lines changed

.github/workflows/test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ jobs:
169169
"privatelink",
170170
"private-endpoint",
171171
"project-settings",
172-
"serverless-pe",
172+
"serverless",
173173
"x509auth",
174174
"custom-roles",
175175
"teams",

internal/controller/atlasdeployment/serverless_deployment_test.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,95 @@ func TestHandleServerlessInstance(t *testing.T) {
556556
WithMessageRegexp("unable to retrieve list of serverless private endpoints from Atlas: failed to list private endpoints"),
557557
},
558558
},
559+
"serverless flex instance fails when private endpoints are set": {
560+
atlasDeployment: &akov2.AtlasDeployment{
561+
ObjectMeta: metav1.ObjectMeta{
562+
Name: "instance0",
563+
Namespace: "default",
564+
},
565+
Spec: akov2.AtlasDeploymentSpec{
566+
ProjectDualReference: akov2.ProjectDualReference{
567+
ProjectRef: &common.ResourceRefNamespaced{
568+
Name: "my-project",
569+
},
570+
},
571+
ServerlessSpec: &akov2.ServerlessSpec{
572+
Name: "instance0",
573+
ProviderSettings: &akov2.ServerlessProviderSettingsSpec{
574+
ProviderName: provider.ProviderServerless,
575+
BackingProviderName: "AWS",
576+
RegionName: "us-east-1",
577+
},
578+
Tags: []*akov2.TagSpec{
579+
{
580+
Key: "test",
581+
Value: "e2e",
582+
},
583+
},
584+
BackupOptions: akov2.ServerlessBackupOptions{
585+
ServerlessContinuousBackupEnabled: false,
586+
},
587+
TerminationProtectionEnabled: true,
588+
PrivateEndpoints: []akov2.ServerlessPrivateEndpoint{
589+
{
590+
Name: "spe1",
591+
CloudProviderEndpointID: "arn-12345",
592+
},
593+
},
594+
},
595+
},
596+
},
597+
deploymentInAtlas: &deployment.Serverless{
598+
ProjectID: "project-id",
599+
State: "IDLE",
600+
ServerlessSpec: &akov2.ServerlessSpec{
601+
Name: "instance0",
602+
ProviderSettings: &akov2.ServerlessProviderSettingsSpec{
603+
ProviderName: provider.ProviderServerless,
604+
BackingProviderName: "AWS",
605+
RegionName: "us-east-1",
606+
},
607+
Tags: []*akov2.TagSpec{
608+
{
609+
Key: "test",
610+
Value: "e2e",
611+
},
612+
},
613+
BackupOptions: akov2.ServerlessBackupOptions{
614+
ServerlessContinuousBackupEnabled: false,
615+
},
616+
TerminationProtectionEnabled: true,
617+
},
618+
},
619+
deploymentService: func() deployment.AtlasDeploymentsService {
620+
service := translation.NewAtlasDeploymentsServiceMock(t)
621+
622+
return service
623+
},
624+
sdkMock: func() *admin.APIClient {
625+
mockError := &admin.GenericOpenAPIError{}
626+
model := *admin.NewApiError()
627+
model.SetErrorCode("NOT_SERVERLESS_TENANT_CLUSTER")
628+
mockError.SetModel(model)
629+
630+
speClient := mockadmin.NewServerlessPrivateEndpointsApi(t)
631+
speClient.EXPECT().ListServerlessPrivateEndpoints(context.Background(), "project-id", "instance0").
632+
Return(admin.ListServerlessPrivateEndpointsApiRequest{ApiService: speClient})
633+
speClient.EXPECT().ListServerlessPrivateEndpointsExecute(mock.AnythingOfType("admin.ListServerlessPrivateEndpointsApiRequest")).
634+
Return(nil, &http.Response{}, mockError)
635+
636+
return &admin.APIClient{ServerlessPrivateEndpointsApi: speClient}
637+
},
638+
expectedResult: ctrl.Result{RequeueAfter: workflow.DefaultRetry},
639+
expectedConditions: []api.Condition{
640+
api.FalseCondition(api.ServerlessPrivateEndpointReadyType).
641+
WithReason(string(workflow.ServerlessPrivateEndpointFailed)).
642+
WithMessageRegexp("serverless private endpoints are not supported: "),
643+
api.FalseCondition(api.DeploymentReadyType).
644+
WithReason(string(workflow.ServerlessPrivateEndpointFailed)).
645+
WithMessageRegexp("serverless private endpoints are not supported: "),
646+
},
647+
},
559648
"serverless instance is updating when private endpoints are in progress": {
560649
atlasDeployment: &akov2.AtlasDeployment{
561650
ObjectMeta: metav1.ObjectMeta{

internal/controller/atlasdeployment/serverless_private_endpoint.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ func syncServerlessPrivateEndpoints(service *workflow.Context, projectID string,
6262
service.Log.Debugf("Syncing serverless private endpoints for deployment %s", deployment.Name)
6363

6464
atlasPrivateEndpoints, err := listServerlessPrivateEndpoints(service, projectID, deployment.Name)
65+
// This is a shimmed flex cluster, if there are private serverless endpoints configured, we have to return an error.
66+
if admin.IsErrorCode(err, "NOT_SERVERLESS_TENANT_CLUSTER") {
67+
if len(deployment.PrivateEndpoints) > 0 {
68+
return false, fmt.Errorf("serverless private endpoints are not supported: %w", err)
69+
}
70+
return true, nil
71+
}
72+
6573
if err != nil {
6674
return false, fmt.Errorf("unable to retrieve list of serverless private endpoints from Atlas: %w", err)
6775
}

test/contract/deployment/deployment_test.go

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)