Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGDAPI-4472 CRO can reconnect in the case of a postgres cr recreation #513

Merged
merged 1 commit into from
Oct 25, 2022

Conversation

valerymo
Copy link
Contributor

@valerymo valerymo commented Sep 19, 2022

Overview

Jira: https://issues.redhat.com/browse/MGDAPI-4472

WHAT

If a postgres is removed from the cluster in a case where the RDS is still in place, recreation of a postgres cr could reconnect with the RDS and CRO puts back in place the requried connection details into the cluster for applications to reconnect.

SCENARIO

Install CRO, install a Postgres cr, Delete the namespace which removes CRO and the postgres but not the DB because the CRO controller wont have time to cleanup.

Reinstall CRO and the Postgres cr. Does it put back the connection secret etc. If not update the logic in CRO to cover this.

Verification

  • Clone this branch
  • Run make cluster/prepare
  • Run make run
  • Follow as in Scenario

Checklist

Please see Scenario - CRO recovers Postgres CR after deletion

@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #513 (134cc55) into master (4e1bd20) will increase coverage by 0.02%.
The diff coverage is 69.23%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
+ Coverage   68.44%   68.46%   +0.02%     
==========================================
  Files          38       38              
  Lines        5099     5109      +10     
==========================================
+ Hits         3490     3498       +8     
- Misses       1254     1255       +1     
- Partials      355      356       +1     
Impacted Files Coverage Δ
pkg/providers/aws/provider_postgres.go 63.51% <69.23%> (+0.22%) ⬆️

@@ -379,6 +379,14 @@ func (p *PostgresProvider) reconcileRDSInstance(ctx context.Context, cr *v1alpha
Database: *foundInstance.DBName,
Port: int(*foundInstance.Endpoint.Port),
}

if !annotations.Has(cr, ResourceIdentifierAnnotation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this path isn't covered by unit tests. Would you be able to add a test case for it, if possible?

Copy link
Contributor Author

@valerymo valerymo Oct 2, 2022

Choose a reason for hiding this comment

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

@cecobask Thank you for comment and discussion.
Updated and retested. Thanks

@cecobask
Copy link
Contributor

Verification:

  • Created an AWS CCS cluster
  • Ran CRO locally
  • Created a Postgres CR and waited for completion
  • Deleted the CRO namespace - had to manually remove the cloud-resources-operator.integreatly.org/finalizers finalizer from the Postgres CR in order to proceed
  • Ran CRO locally again
  • Created another Postgres CR with the same spec as earlier
  • Confirmed that CRO reconnected to the existing RDS instance and had the secret reference in place

@valerymo I'm ready to place an lgtm but I'll wait until the unit test case for the missing coverage is added 👍🏻

@valerymo valerymo force-pushed the valery_MGDAPI-4472 branch 2 times, most recently from a1532b1 to 7425bd1 Compare October 2, 2022 16:21
@cecobask
Copy link
Contributor

cecobask commented Oct 6, 2022

Thank you for adding the test cases, @valerymo!
/lgtm

@valerymo
Copy link
Contributor Author

/test codecov/patch

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 18, 2022

@valerymo: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test coverage
  • /test e2e
  • /test format
  • /test gosec
  • /test images
  • /test unit
  • /test vendor

Use /test all to run all jobs.

In response to this:

/test codecov/patch

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@valerymo
Copy link
Contributor Author

/test coverage

@cecobask
Copy link
Contributor

/test all

Copy link
Contributor

@cecobask cecobask left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 18, 2022
@@ -128,7 +128,7 @@ cluster/seed/managed/postgressnapshot:

.PHONY: cluster/clean
cluster/clean:
@$(KUSTOMIZE) build config/crd | kubectl delete -f -
@$(KUSTOMIZE) build config/crd | oc delete -f -
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason to use oc over kubectl here?

Copy link
Contributor Author

@valerymo valerymo Oct 20, 2022

Choose a reason for hiding this comment

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

@laurafitzgerald I didn't have kubectl locally : ), and i found that it was the only place where oc was not used but kubectl, so I changed it to oc, as in other places in Makefile. Thank you for comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, ignore please my reply, regarding rebase & missing kubectl. I looked at not correct Makefile.
So answer - I didn't have kubectl locally : ), and this is the only place where kubectl was used, so didn't see any reason to use it

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok. no problem. I think we had agreed a long time ago that we would use kubectl in all cases where possible and only oc where we had to but looks like it's used elsewhere so I think this is fine.

if err := client.Update(ctx, cr); err != nil {
return "failed to add annotation", err
}
return "", nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use cro.StatusEmpty here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I will check

@cecobask
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 25, 2022
@laurafitzgerald
Copy link
Collaborator

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cecobask, laurafitzgerald

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit eefff91 into integr8ly:master Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants