Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build-push-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ runs:
using: "composite"
steps:
- name: Check out code
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.5.3
if: ${{ inputs.forked == false }}
with:
submodules: true
fetch-depth: 0
- name: Check out code for forked PR
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.5.3
if: ${{ inputs.forked == true }}
with:
ref: ${{github.event.pull_request.head.sha}}
Expand Down
13 changes: 11 additions & 2 deletions .github/actions/cleanup-pe/cleanall.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ func cleanAllAWSPE(region string, subnets []string) error {
}

if len(subnetOutput.Subnets) == 0 {
return fmt.Errorf("no subnets found")
continue
}
subnetID := subnetOutput.Subnets[0].SubnetId

fmt.Printf("Listing private endpoints in subnet %s at region %s", *subnetID, region)
endpoints, err := svc.DescribeVpcEndpoints(&ec2.DescribeVpcEndpointsInput{})
if err != nil {
return fmt.Errorf("error fething all vpcEP: %v", err)
Expand All @@ -56,6 +57,8 @@ func cleanAllAWSPE(region string, subnets []string) error {
}
}

fmt.Printf("Found %d private endpoints in subnet %s at region %s", len(endpointIDs), *subnetID, region)

err = deleteAWSPEsByID(svc, endpointIDs)
if err != nil {
return err
Expand Down Expand Up @@ -92,6 +95,7 @@ func cleanAllAzurePE(ctx context.Context, resourceGroupName, azureSubscriptionID
peClient := network.NewPrivateEndpointsClient(azureSubscriptionID)
peClient.Authorizer = authorizer

fmt.Printf("Listing private endpoints at %s", resourceGroupName)
peList, err := peClient.List(ctx, resourceGroupName)
if err != nil {
return fmt.Errorf("error fething all PE: %v", err)
Expand All @@ -106,6 +110,8 @@ func cleanAllAzurePE(ctx context.Context, resourceGroupName, azureSubscriptionID
}
}

fmt.Printf("Found %d private endpoints at %s", len(endpointNames), resourceGroupName)

for _, peName := range endpointNames {
_, errDelete := peClient.Delete(ctx, resourceGroupName, peName)
if errDelete != nil {
Expand All @@ -129,10 +135,12 @@ func cleanAllGCPPE(ctx context.Context, projectID, vpc, region string, subnets [
for _, subnet := range subnets {
subnetURL := formSubnetURL(region, subnet, projectID)

fmt.Printf("Listing forward rules at %s", subnetURL)
forwardRules, err := computeService.ForwardingRules.List(projectID, region).Do()
if err != nil {
return fmt.Errorf("error while listing forwarding rules: %v", err)
}
log.Printf("Found %d forward rule(s)", len(forwardRules.Items))

counter := 0
for _, forwardRule := range forwardRules.Items {
Expand All @@ -147,7 +155,7 @@ func cleanAllGCPPE(ctx context.Context, projectID, vpc, region string, subnets [
forwardRule.Name, forwardRule.Network)
}
}
log.Printf("deleted %d GCP Forfard rules", counter)
log.Printf("deleted %d GCP Forward rules", counter)

time.Sleep(time.Second * 20) // need to wait for GCP to delete the forwarding rule
err = deleteGCPAddressBySubnet(computeService, projectID, region, subnetURL)
Expand All @@ -160,6 +168,7 @@ func cleanAllGCPPE(ctx context.Context, projectID, vpc, region string, subnets [
}

func deleteGCPAddressBySubnet(service *compute.Service, projectID, region, subnetURL string) error {
fmt.Printf("Listing addresses at %s", subnetURL)
addressList, err := service.Addresses.List(projectID, region).Do()
if err != nil {
return fmt.Errorf("error while listing addresses: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2 v2.2.1
github.com/Azure/go-autorest/autorest v0.11.29
Expand All @@ -23,7 +23,7 @@ require (
github.com/pborman/uuid v1.2.1
github.com/sethvargo/go-password v0.2.0
github.com/stretchr/testify v1.8.4
go.mongodb.org/atlas v0.28.0
go.mongodb.org/atlas v0.29.0
go.mongodb.org/mongo-driver v1.11.7
go.uber.org/zap v1.24.0
golang.org/x/sync v0.2.0
Expand Down Expand Up @@ -110,7 +110,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.9.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU=
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY=
Expand Down Expand Up @@ -399,8 +399,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/atlas v0.28.0 h1:CelAXtmiM36tdifSDwWdDH1nNbdvq0M2XfUR8208JxA=
go.mongodb.org/atlas v0.28.0/go.mod h1:L4BKwVx/OeEhOVjCSdgo90KJm4469iv7ZLzQms/EPTg=
go.mongodb.org/atlas v0.29.0 h1:vBo4Qe8u2GKn8ZEiw8vLCv8lmxryhea6kUWY0ZJL8OU=
go.mongodb.org/atlas v0.29.0/go.mod h1:L4BKwVx/OeEhOVjCSdgo90KJm4469iv7ZLzQms/EPTg=
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down Expand Up @@ -446,8 +446,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,12 @@ func (r *AtlasDeploymentReconciler) deleteDeploymentFromAtlas(
return err
}

deleteDeploymentFunc := atlasClient.AdvancedClusters.Delete
if deployment.IsServerless() {
deleteDeploymentFunc = atlasClient.ServerlessInstances.Delete
_, err = atlasClient.ServerlessInstances.Delete(ctx, project.Status.ID, deployment.GetDeploymentName())
} else {
_, err = atlasClient.AdvancedClusters.Delete(ctx, project.Status.ID, deployment.GetDeploymentName(), nil)
}

_, err = deleteDeploymentFunc(ctx, project.Status.ID, deployment.GetDeploymentName())

var apiError *mongodbatlas.ErrorResponse
if errors.As(err, &apiError) && apiError.ErrorCode == atlas.ClusterNotFound {
log.Info("Deployment doesn't exist or is already deleted")
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/actions/cloud/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"time"

"google.golang.org/api/googleapi"

Expand Down Expand Up @@ -36,12 +37,9 @@ type gcpNetwork struct {

const (
// TODO get from GCP
GoogleProjectID = "atlasoperator" // Google Cloud Project ID
GoogleVPC = "atlas-operator-test" // VPC Name
GoogleSubnetName = "atlas-operator-subnet-leo" // Subnet Name
googleConnectPrefix = "ao" // Private Service Connect Endpoint Prefix

gcpSubnetIPMask = "10.0.0.%d"
GoogleProjectID = "atlasoperator" // Google Cloud Project ID
googleConnectPrefix = "ao" // Private Service Connect Endpoint Prefix
gcpSubnetIPMask = "10.0.0.%d"
)

func (a *GCPAction) InitNetwork(vpcName, region string, subnets map[string]string, cleanup bool) (string, error) {
Expand Down Expand Up @@ -328,6 +326,8 @@ func (a *GCPAction) deleteSubnet(ctx context.Context, subnetName, region string)
func (a *GCPAction) createVirtualAddress(ctx context.Context, name, subnet, region string) (string, error) {
a.t.Helper()

rand.Seed(time.Now().UnixNano())

ip := fmt.Sprintf(gcpSubnetIPMask, rand.IntnRange(10, 120))
if subnet == Subnet2Name {
ip = fmt.Sprintf(gcpSubnetIPMask, rand.IntnRange(150, 250))
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/actions/cloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"path"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"

. "github.com/onsi/gomega"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"
"github.com/onsi/ginkgo/v2/dsl/core"

"github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1/provider"
Expand Down
21 changes: 12 additions & 9 deletions test/e2e/actions/deploy/deploy_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ func CreateProject(testData *model.TestDataProvider) {
err := testData.K8SClient.Create(testData.Context, testData.Project)
Expect(err).ShouldNot(HaveOccurred(), "Project %s was not created", testData.Project.GetName())
Eventually(func(g Gomega) {
condition, _ := k8s.GetProjectStatusCondition(testData.Context, testData.K8SClient, status.ReadyType,
testData.Resources.Namespace, testData.Project.GetName())
g.Expect(condition).Should(Equal("True"))
}).Should(Succeed(), "Project %s was not created", testData.Project.GetName())
})
By(fmt.Sprintf("Wait for Project %s", testData.Project.GetName()), func() {
Eventually(func() bool {
condition, _ := k8s.GetProjectStatusCondition(
testData.Context,
testData.K8SClient,
status.ReadyType,
testData.Resources.Namespace,
testData.Project.GetName(),
)
g.Expect(condition).To(Equal("True"))

statuses := kube.GetProjectStatus(testData)
return statuses.ID != ""
}, 5*time.Minute, 5*time.Second).Should(BeTrue(), "Project %s is not ready", kube.GetProjectStatus(testData))
g.Expect(statuses.ID).ToNot(BeEmpty())
}).WithTimeout(10*time.Minute).WithPolling(10*time.Second).
Should(Succeed(), "Project %s was not created", testData.Project.GetName())
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/int/datafederation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = Describe("AtlasDataFederation", Label("AtlasDataFederation"), func() {
if manualDeletion && createdProject != nil {
By("Deleting the deployment in Atlas manually", func() {
// We need to remove the deployment in Atlas manually to let project get removed
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), createdProject.ID(), createdDataFederation.Name)
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), createdProject.ID(), createdDataFederation.Name, nil)
Expect(err).NotTo(HaveOccurred())
Eventually(checkAtlasDeploymentRemoved(createdProject.Status.ID, createdDataFederation.Name), 600, interval).Should(BeTrue())
createdDataFederation = nil
Expand Down
4 changes: 2 additions & 2 deletions test/int/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment"), func() {
if manualDeletion && createdProject != nil {
By("Deleting the deployment in Atlas manually", func() {
// We need to remove the deployment in Atlas manually to let project get removed
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), createdProject.ID(), createdDeployment.GetDeploymentName())
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), createdProject.ID(), createdDeployment.GetDeploymentName(), nil)
Expect(err).NotTo(HaveOccurred())
Eventually(checkAtlasDeploymentRemoved(createdProject.Status.ID, createdDeployment.GetDeploymentName()), 600, interval).Should(BeTrue())
createdDeployment = nil
Expand Down Expand Up @@ -1292,7 +1292,7 @@ func checkAtlasDeploymentRemoved(projectID string, deploymentName string) func()
}

func deleteAtlasDeployment(projectID string, deploymentName string) error {
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), projectID, deploymentName)
_, err := atlasClient.AdvancedClusters.Delete(context.Background(), projectID, deploymentName, nil)
return err
}

Expand Down