Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Conversation

qibobo
Copy link
Contributor

@qibobo qibobo commented Jan 7, 2021

I will add the UT and acceptance tests later

@openshift-ci-robot
Copy link
Collaborator

Hi @qibobo. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@codecov
Copy link

codecov bot commented Jan 7, 2021

Codecov Report

Merging #834 (2c48563) into master (ecbab0f) will not change coverage.
The diff coverage is 93.54%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #834   +/-   ##
=======================================
  Coverage   61.47%   61.47%           
=======================================
  Files          25       25           
  Lines        1918     1918           
=======================================
  Hits         1179     1179           
  Misses        568      568           
  Partials      171      171           
Impacted Files Coverage Δ
controllers/reconciler.go 75.00% <93.54%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecbab0f...2c48563. Read the comment docs.

@DhritiShikhar
Copy link
Contributor

/ok-to-test

@DhritiShikhar
Copy link
Contributor

@qibobo You would have to signoff your commit with git commit --amend --signoff for DCO PR check to pass.

@qibobo qibobo force-pushed the dev_qy_cannotdelete branch from 3bb3ede to 7eccb6b Compare January 8, 2021 08:18
@qibobo qibobo changed the title [WIP] fix issue SBR can not be deleted if backend service has been deleted #832 fix issue SBR can not be deleted if backend service has been deleted #832 Jan 8, 2021
@qibobo qibobo force-pushed the dev_qy_cannotdelete branch 2 times, most recently from fc9167b to 6a9e18e Compare January 10, 2021 08:18
@qibobo
Copy link
Contributor Author

qibobo commented Jan 13, 2021

@DhritiShikhar @isutton
Could you help review this PR?

logger.Info("Executing unbinding steps...")
// here just build a servicebinder with necessary fields to do unbind
ensureDefaults(sbr.Spec.Application)
sb := &serviceBinder{
Copy link
Contributor

Choose a reason for hiding this comment

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

could we use buildServiceBinder() here? How is this instance different from the existing instance, i.e. why unbind cannot be performed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pedjak
In current reconcile process, to do the unbind, it needs to buildServiceContexts and buildBinding, and buildServiceBinder. When the backing service has been deleted and it tries to delete the SBR, buildServiceContexts fail and requeue, then fail and requeue..... The SBR can not be deleted.

The reason here I did not use the buildServiceBinder is that it needs the result buildServiceContexts and buildBinding, which will fall as I mentioned above. And for unbind, I think there is no need to buildServiceContexts and buildBinding because the results of them are not necessary to do the unbind.

Copy link
Contributor

Choose a reason for hiding this comment

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

@qibobo thanks for explanation. If I understand correctly, the issue here is that buildServiceContexts()is not aware of the fact that service binding is about to be deleted. However, it would be good that the change inside Reconcile() function is as small as possible. Hence, how about this: instead of creating servicebinder manually, how about that we use buildServiceBinder as before, but we creating empty service context if we recognize that deletion is in progress? Something like:

serviceCtxs, err := buildServiceContexts(...)
if err != nil {
   if sbr.GetDeletionTimestamp() != nil {
      serviceCtxs = serviceContextList{}
   } else {
	//handle service not found error
	if k8serrors.IsNotFound(err) {
        ...
        }

I believe this is the only change we need to perform in the reconcile function.

@qibobo qibobo force-pushed the dev_qy_cannotdelete branch from 6a9e18e to 2b47941 Compare January 14, 2021 12:17
@qibobo
Copy link
Contributor Author

qibobo commented Jan 14, 2021

/retest

@qibobo qibobo force-pushed the dev_qy_cannotdelete branch from 2b47941 to 62a1752 Compare January 14, 2021 13:37
if err != nil {
logger.Error(err, "Failed to update SBR conditions", "sbr", sbr)
if sbr.GetDeletionTimestamp() != nil {
serviceCtxs = serviceContextList{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't make sense to execute buildServiceContexts only if the GetDeletionTimestamp() != nil check fails?

@isutton isutton changed the title fix issue SBR can not be deleted if backend service has been deleted #832 Fix issue where a ServiceBinding can not be deleted if the backend service has been previously deleted Jan 14, 2021
@@ -648,3 +649,98 @@ func TestBindTwoSbrsWithSingleApplication(t *testing.T) {
require.Equal(t, sbrName2, dep.Spec.Template.Spec.Containers[0].EnvFrom[1].SecretRef.LocalObjectReference.Name)
})
}

// TestApplicationByName tests discovery of application by name
func TestUnBind(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is scenario we test here, can you reflect with the function name? If the scenario is the same as the new introduced acceptance test, we can then avoid introducing this test fully.

@qibobo
Copy link
Contributor Author

qibobo commented Jan 28, 2021

@isutton @pedjak Fixed.

Copy link
Contributor

@pedjak pedjak left a comment

Choose a reason for hiding this comment

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

lgtm, please squash and restructure a bit the commit message, something like:

Fix ServiceBinding removal when service not exist

@qibobo qibobo force-pushed the dev_qy_cannotdelete branch 2 times, most recently from 45d086a to 2cecfb4 Compare January 28, 2021 14:37
@qibobo
Copy link
Contributor Author

qibobo commented Jan 29, 2021

@pedjak
done

@pedjak pedjak changed the title Fix issue where a ServiceBinding can not be deleted if the backend service has been previously deleted Fix ServiceBinding removal when service not exist Jan 29, 2021
@pedjak
Copy link
Contributor

pedjak commented Jan 29, 2021

/retest

@pedjak
Copy link
Contributor

pedjak commented Jan 29, 2021

/lgtm
/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pedjak

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

@pedjak pedjak added this to the v0.5.0 milestone Jan 29, 2021
@qibobo
Copy link
Contributor Author

qibobo commented Feb 1, 2021

@pedjak
rebased and need lgtm again.

@pedjak
Copy link
Contributor

pedjak commented Feb 1, 2021

/lgtm

@openshift-merge-robot openshift-merge-robot merged commit 0efd994 into redhat-developer:master Feb 1, 2021
akashshinde added a commit to akashshinde/service-binding-operator that referenced this pull request Feb 3, 2021
added naming strategy and deprecated namePrefix and globalNamePrefix

Fix acceptance tests

fix etcd acceptance test

Added flexible strategy naming docs

Added doc to describe naming strategy

remove service level naming strategy

removed NamingStrategy field from service API

revert back to default naming strategy

Fix regression: previously create test namespace is used across test runs (redhat-developer#850)

This fixes regression introduced in PR redhat-developer#848 - we should reuse created test namespace
across multiple runs of acceptance tests

Signed-off-by: Predrag Knezevic <[email protected]>

Use k8s api condition type for status.conditions (redhat-developer#851)

Condition type got available in 1.19 API. Hence, we can drop the usage of
github.com/openshift/custom-resource-status library.

Signed-off-by: Predrag Knezevic <[email protected]>

Fix ServiceBinding removal when service not exist (redhat-developer#834)

Signed-off-by: qibobo <[email protected]>

Refactor

Fix acceptance tests and revert back the docs

go fmt

Fix failures

Fix acceptance test
akashshinde added a commit to akashshinde/service-binding-operator that referenced this pull request Feb 4, 2021
added naming strategy and deprecated namePrefix and globalNamePrefix

Fix acceptance tests

fix etcd acceptance test

Added flexible strategy naming docs

Added doc to describe naming strategy

remove service level naming strategy

removed NamingStrategy field from service API

revert back to default naming strategy

Fix regression: previously create test namespace is used across test runs (redhat-developer#850)

This fixes regression introduced in PR redhat-developer#848 - we should reuse created test namespace
across multiple runs of acceptance tests

Signed-off-by: Predrag Knezevic <[email protected]>

Use k8s api condition type for status.conditions (redhat-developer#851)

Condition type got available in 1.19 API. Hence, we can drop the usage of
github.com/openshift/custom-resource-status library.

Signed-off-by: Predrag Knezevic <[email protected]>

Fix ServiceBinding removal when service not exist (redhat-developer#834)

Signed-off-by: qibobo <[email protected]>

Refactor

Fix acceptance tests and revert back the docs

go fmt

Fix failures

Fix acceptance test
akashshinde added a commit to akashshinde/service-binding-operator that referenced this pull request Feb 4, 2021
added naming strategy and deprecated namePrefix and globalNamePrefix

Fix acceptance tests

fix etcd acceptance test

Added flexible strategy naming docs

Added doc to describe naming strategy

remove service level naming strategy

removed NamingStrategy field from service API

revert back to default naming strategy

Fix regression: previously create test namespace is used across test runs (redhat-developer#850)

This fixes regression introduced in PR redhat-developer#848 - we should reuse created test namespace
across multiple runs of acceptance tests

Signed-off-by: Predrag Knezevic <[email protected]>

Use k8s api condition type for status.conditions (redhat-developer#851)

Condition type got available in 1.19 API. Hence, we can drop the usage of
github.com/openshift/custom-resource-status library.

Signed-off-by: Predrag Knezevic <[email protected]>

Fix ServiceBinding removal when service not exist (redhat-developer#834)

Signed-off-by: qibobo <[email protected]>

Refactor

Fix acceptance tests and revert back the docs

go fmt

Fix failures

Fix acceptance test
akashshinde added a commit that referenced this pull request Feb 5, 2021
added naming strategy and deprecated namePrefix and globalNamePrefix

Fix acceptance tests

fix etcd acceptance test

Added flexible strategy naming docs

Added doc to describe naming strategy

remove service level naming strategy

removed NamingStrategy field from service API

revert back to default naming strategy

Fix regression: previously create test namespace is used across test runs (#850)

This fixes regression introduced in PR #848 - we should reuse created test namespace
across multiple runs of acceptance tests

Signed-off-by: Predrag Knezevic <[email protected]>

Use k8s api condition type for status.conditions (#851)

Condition type got available in 1.19 API. Hence, we can drop the usage of
github.com/openshift/custom-resource-status library.

Signed-off-by: Predrag Knezevic <[email protected]>

Fix ServiceBinding removal when service not exist (#834)

Signed-off-by: qibobo <[email protected]>

Refactor

Fix acceptance tests and revert back the docs

go fmt

Fix failures

Fix acceptance test

Signed-off-by: akashshinde <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants