Skip to content

Conversation

@vasilevp
Copy link
Contributor

@vasilevp vasilevp commented Mar 5, 2021

No description provided.

@vasilevp vasilevp changed the title Implement delete retry loop CLOUDP-82115: Implement delete retry loop Mar 5, 2021
Copy link
Contributor

@antonlisovenko antonlisovenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one suggestion to deeper check the error on removal.

Thanks for finding the bug with Spec.Name!!


for time.Now().Before(timeout) {
_, err = atlasClient.Clusters.Delete(context.Background(), project.Status.ID, cluster.Spec.Name)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think if we check here the error that is returned in case the cluster is already removed - and break the loop in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


for time.Now().Before(timeout) {
_, err = atlasClient.Projects.Delete(context.Background(), project.Status.ID)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same as above

By("Removing Atlas Cluster " + createdCluster.Name)
Expect(k8sClient.Delete(context.Background(), createdCluster)).To(Succeed())
Eventually(checkAtlasClusterRemoved(createdProject.Status.ID, createdCluster.Name), 600, interval).Should(BeTrue())
Eventually(checkAtlasClusterRemoved(createdProject.Status.ID, createdCluster.Spec.Name), 600, interval).Should(BeTrue())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

By("Removing Atlas Project " + createdProject.Status.ID)
Eventually(removeAtlasProject(createdProject.Status.ID), 600, interval).Should(BeTrue())
Expect(k8sClient.Delete(context.Background(), createdProject)).To(Succeed())
Eventually(checkAtlasProjectRemoved(createdProject.Status.ID), 60, interval).Should(BeTrue())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] do you know if we still need Eventually here? If there are no clusters then the project is supposed to get removed immediately or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some time could pass between a call to k8sClient.Delete and the actual API call. Also, we could always stumble upon a network issue and fail prematurely

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, right, we remove the resource in K8s, not in Atlas

@vasilevp vasilevp requested a review from antonlisovenko March 5, 2021 16:39
for time.Now().Before(timeout) {
_, err = atlasClient.Projects.Delete(context.Background(), project.Status.ID)
var apiError *mongodbatlas.ErrorResponse
if errors.As(err, &apiError) && apiError.ErrorCode == atlas.ClusterNotFound {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be atlas.ProjectNotFound?

Copy link
Contributor

@antonlisovenko antonlisovenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vasilevp vasilevp merged commit 10c6cb5 into main Mar 11, 2021
@vasilevp vasilevp deleted the CLOUDP-82115-loop-delete branch March 11, 2021 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants