-
Notifications
You must be signed in to change notification settings - Fork 89
Fix ServiceBinding removal when service not exist #834
Fix ServiceBinding removal when service not exist #834
Conversation
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 Once the patch is verified, the new status will be reflected by the 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 Report
@@ Coverage Diff @@
## master #834 +/- ##
=======================================
Coverage 61.47% 61.47%
=======================================
Files 25 25
Lines 1918 1918
=======================================
Hits 1179 1179
Misses 568 568
Partials 171 171
Continue to review full report at Codecov.
|
/ok-to-test |
@qibobo You would have to signoff your commit with |
3bb3ede
to
7eccb6b
Compare
fc9167b
to
6a9e18e
Compare
@DhritiShikhar @isutton |
logger.Info("Executing unbinding steps...") | ||
// here just build a servicebinder with necessary fields to do unbind | ||
ensureDefaults(sbr.Spec.Application) | ||
sb := &serviceBinder{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
6a9e18e
to
2b47941
Compare
/retest |
2b47941
to
62a1752
Compare
if err != nil { | ||
logger.Error(err, "Failed to update SBR conditions", "sbr", sbr) | ||
if sbr.GetDeletionTimestamp() != nil { | ||
serviceCtxs = serviceContextList{} |
There was a problem hiding this comment.
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?
@@ -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) { |
There was a problem hiding this comment.
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.
62a1752
to
0554fdb
Compare
0554fdb
to
ae5978a
Compare
There was a problem hiding this 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
45d086a
to
2cecfb4
Compare
@pedjak |
/retest |
/lgtm |
[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 |
Signed-off-by: qibobo <[email protected]>
2cecfb4
to
2c48563
Compare
@pedjak |
/lgtm |
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
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
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
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]>
I will add the UT and acceptance tests later