-
Notifications
You must be signed in to change notification settings - Fork 20
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
Consumer deletion #154
Consumer deletion #154
Conversation
a6f86da
to
b0fa117
Compare
b1c649f
to
a059a24
Compare
/ok-to-test |
aff98b5
to
ed27d5b
Compare
/assign @qiujian16 @morvencao @clyang82 |
The e2e case might sometimes fail with the same error in this PR #156. It has no relation to the current changes and won't be fixed here. |
pkg/dao/resource.go
Outdated
@@ -115,3 +116,10 @@ func (d *sqlResourceDao) All(ctx context.Context) (api.ResourceList, error) { | |||
} | |||
return resources, nil | |||
} | |||
|
|||
func (d *sqlResourceDao) FirstByConsumerName(ctx context.Context, consumerName string) (api.Resource, error) { |
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.
Why first?
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.
I just chose one(first) item to determine whether the resource exists for the consumer. Of course, we can choose to use the current FindByConsumerName to do that. The latter may need more memory footprint, cause it will load all the resources on the consumer to the memory. What do you think of it?
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.
yeah, I think we need to document this with the reason. Also what if the resource is marked as deleted or deleting? do we still block?
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.
Yes, I added comments for the FirstByConsumerName
.
If a resource is marked as deleted, we will still block the deletion.
pkg/services/consumer.go
Outdated
|
||
if e != gorm.ErrRecordNotFound { | ||
return handleGetError("Resource", "consumer_name", consumer.Name, e) | ||
} |
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.
return error with other type
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.
Done.
pkg/services/consumer.go
Outdated
return handleGetError("Resource", "consumer_name", consumer.Name, e) | ||
} | ||
|
||
// e is record not found |
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.
something to consider is, we need to block creation of resource before delete consumer.
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.
Thanks @qiujian16!
I think of two ways to block the resource creation when deleting the consumer.
Optional 1(the current): Hard delete the consumer, so there will be no deleting state for the consumer. And the resource creation will be blocked by the deleted consumer.
Optional 2: Delete the consumer softly(mark it as deleted), and add validation to check the consumer when creating resources. If the consumer is not found or marked as deleted, then block the resource creating.
This doesn't seem like an elegant way, as it requires checking each resource creation to ensure that.
The Optional 1 might be feasible for now. Do you have any other suggestions?
d404abb
to
604637e
Compare
/ok-to-test |
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
b76fa9b
to
baf8e76
Compare
Signed-off-by: myan <[email protected]>
021a1f0
to
5183cee
Compare
Signed-off-by: myan <[email protected]>
5183cee
to
b3db85a
Compare
Signed-off-by: myan <[email protected]>
Signed-off-by: myan <[email protected]>
04f7315
to
8c6acbc
Compare
Signed-off-by: myan <[email protected]>
8c6acbc
to
e687ffc
Compare
Signed-off-by: myan <[email protected]>
5789d89
to
83a2b71
Compare
Signed-off-by: myan <[email protected]>
83a2b71
to
4fa474d
Compare
Signed-off-by: myan <[email protected]>
Signed-off-by: myan [email protected]
Note:
Delete will remove the consumer from the storage:
TODO: Additional deletion options or strategies might be added in the future.