-
Notifications
You must be signed in to change notification settings - Fork 101
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
Make CreateOrUpdate controller async for link resources #5006
Conversation
…tputResources instead of ResourceData
SecretValues map[string]rp.SecretValueReference | ||
RecipeData datamodel.RecipeData | ||
} | ||
// type DeploymentOutput struct { |
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.
Was this supposed to be commented out?
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
|
||
// AsyncOperationTimeout returns the timeput for the operation. | ||
func (b *Operation[P, T]) AsyncOperationTimeout() time.Duration { | ||
if b.resourceOptions.AsyncOperationTimeout == 0 { |
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.
Can you please add the simple unittest for this ?
if b.resourceOptions.AsyncOperationTimeout == 0 { | |
if b.resourceOptions.AsyncOperationTimeout == time.Time{} { |
@@ -332,6 +333,7 @@ func AddRoutes(ctx context.Context, router *mux.Router, pathBase string, isARM b | |||
rp_frontend.PrepareRadiusResource[*datamodel.VolumeResource], | |||
vol_ctrl.ValidateRequest, | |||
}, | |||
AsyncOperationTimeout: time.Duration(2) * time.Minute, |
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.
this is unnecessary.
I made huge change in the morning. Please rebase this branch with main. |
Rebased with main. |
// AsyncOperationTimeout returns the timeput for the operation. | ||
func (b *Operation[P, T]) AsyncOperationTimeout() time.Duration { | ||
if b.resourceOptions.AsyncOperationTimeout == 0 { | ||
return time.Duration(2) * time.Minute |
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.
Can this be a constant?
// AsyncOperationTimeout returns the timeput for the operation. | ||
func (b *Operation[P, T]) AsyncOperationTimeout() time.Duration { | ||
if b.resourceOptions.AsyncOperationTimeout == 0 { | ||
return time.Duration(2) * time.Minute |
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.
is there a reason for the 2 min AsyncOperationTimeout?
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.
this is the default timeout for all the resources, and we can override it for each resource by sending a timeout for each operation.
@@ -362,6 +362,9 @@ func AddRoutes(ctx context.Context, router *mux.Router, pathBase string, isARM b | |||
frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ | |||
RequestConverter: converter.VolumeResourceModelFromVersioned, | |||
ResponseConverter: converter.VolumeResourceModelToVersioned, | |||
UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.VolumeResource]{ |
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.
Should this be a delete filter?
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 think it should. Nice catch.
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.
figuered delete/update filters are not required and removed it
@@ -2,8 +2,38 @@ | |||
// Copyright (c) Microsoft Corporation. | |||
// Licensed under the MIT License. | |||
// ------------------------------------------------------------ | |||
|
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.
The file mostly has recipe related data. shouldn't this be in a recipe file instead? we have a task for it. #5035
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 think its better to move these to linkrp as these are used by differnet packages inside linkrp to avoid cyclic dependency
// Parameters are key/value parameters to pass into the recipe at deployment | ||
Parameters map[string]any `json:"parameters,omitempty"` | ||
} | ||
|
||
const ( | ||
DaprInvokeHttpRoutesResourceType = "Applications.Link/daprInvokeHttpRoutes" |
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.
👌
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.
Added a few comments and questions but looks good to me so far. Let me know when this PR takes its final shape and then I can review it again. Thanks for this change.
@@ -54,6 +55,9 @@ type ResourceOptions[T any] struct { | |||
|
|||
// UpdateFilters is a slice of filters that execute prior to updating a resource. | |||
UpdateFilters []UpdateFilter[T] | |||
|
|||
// AsyncOperationTimeout is the default timeout duration of async put operation. | |||
AsyncOperationTimeout time.Duration |
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.
Is this the best place to put this property?
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 think so, as this can accessed for all the operations for the resource.
// AsyncOperationTimeout returns the timeput for the operation. | ||
func (b *Operation[P, T]) AsyncOperationTimeout() time.Duration { | ||
if b.resourceOptions.AsyncOperationTimeout == 0 { | ||
return time.Duration(2) * time.Minute |
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.
There should be a Default const for this somewhere in the code.
@@ -362,6 +362,9 @@ func AddRoutes(ctx context.Context, router *mux.Router, pathBase string, isARM b | |||
frontend_ctrl.ResourceOptions[datamodel.VolumeResource]{ | |||
RequestConverter: converter.VolumeResourceModelFromVersioned, | |||
ResponseConverter: converter.VolumeResourceModelToVersioned, | |||
UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.VolumeResource]{ |
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 think it should. Nice catch.
@@ -6,6 +6,7 @@ | |||
package datamodel | |||
|
|||
import ( | |||
"github.com/project-radius/radius/pkg/linkrp" |
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 this create a cyclic dependency problem anytime soon?
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.
in that case we can move it all to linkrp instead. I create a types.go inside linkrp to remove the cyclic dependency
@@ -30,19 +30,3 @@ func getTestModels20220315privatepreview() (input *v20220315privatepreview.Redis | |||
|
|||
return input, dataModel, output | |||
} | |||
|
|||
func getTestModelsForGetAndListApis20220315privatepreview() (input *v20220315privatepreview.RedisCacheResource, dataModel *datamodel.RedisCache, output *v20220315privatepreview.RedisCacheResource) { |
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 are we deleting this data for Get and List? Was this a wrong naming? Because we are moving the Put and Delete.
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.
We dont use this anymore as we moved list and get as part of the generic controller
UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ | ||
rp_frontend.PrepareRadiusResource[*datamodel.MongoDatabase], | ||
}, | ||
AsyncOperationTimeout: time.Duration(10) * time.Minute, |
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.
👍
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.
This shouldn't affect the time of our functional tests, right?
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 thats correct, as out functional tests run in parallel
UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ | ||
rp_frontend.PrepareRadiusResource[*datamodel.MongoDatabase], | ||
}, | ||
AsyncOperationTimeout: time.Duration(15) * time.Minute, |
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.
🤣
frontend_ctrl.ResourceOptions[datamodel.MongoDatabase]{ | ||
RequestConverter: converter.MongoDatabaseDataModelFromVersioned, | ||
ResponseConverter: converter.MongoDatabaseDataModelToVersioned, | ||
UpdateFilters: []frontend_ctrl.UpdateFilter[datamodel.MongoDatabase]{ |
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.
Not sure if I remember the details of UpdateFilters and DeleteFilters but should this be DeleteFilters?
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.
figured we dont need delete/update filters and removed it
6dfac16
to
7ef7d11
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 but left a few more comments and some may need addressing.
I would also get another thumbs up btw.
// AsyncOperationTimeout returns the timeput for the operation. | ||
func (b *Operation[P, T]) AsyncOperationTimeout() time.Duration { | ||
if b.resourceOptions.AsyncOperationTimeout == 0 { | ||
return defaultAsyncPutTimeout |
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.
but this function is not only used for put calls, right? delete timeout should be different?
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.
currently we use the same default timeout duration for put and delete, i.e 2 mins and we can override it by providing timeout in routes
nil, | ||
nil, | ||
errors.New("error getting object"), | ||
}, |
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.
Do you also want to test PATCH calls?
|
||
deploymentDataModel, ok := dataModel.(rpv1.DeploymentDataModel) | ||
if !ok { | ||
return ctrl.NewFailedResult(v1.ErrorDetails{Message: "deployment data model conversion error"}), nil |
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.
Should we give more details? Like which data model and something like that?
// ResourceInfo name and id of the resource | ||
type ResourceInfo struct { | ||
Name string `json:"name"` | ||
ID string `json:"id"` | ||
} | ||
|
||
type Runtime struct { | ||
Kubernetes Kubernetes `json:"kubernetes,omitempty"` | ||
} | ||
|
||
type Kubernetes struct { | ||
// Namespace is set to the applicationNamespace when the Link is application-scoped, and set to the environmentNamespace when the Link is environment scoped | ||
Namespace string `json:"namespace"` | ||
// EnvironmentNamespace is set to environment namespace. | ||
EnvironmentNamespace string `json:"environmentNamespace"` | ||
} |
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.
If these are also being used by corerp, we should move them to the rp package.
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.
these are currently used only in linkrp
deploymentDataModel, ok := dataModel.(rpv1.DeploymentDataModel) | ||
if !ok { | ||
return ctrl.NewFailedResult(v1.ErrorDetails{Message: "deployment data model conversion error"}), err | ||
} |
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.
We can move this check after L61 before rendering and deploying.
Merging to unblock next round of work. The failures are flakiness on the delete path of an Azure resource. |
# Description Addressing few pr comments from #5006 ## Issue reference <!-- We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation. --> Fixes: #issue_number ## Checklist Please make sure you've completed the relevant tasks for this PR, out of the following list: * [x] Code compiles correctly * [ ] Adds necessary unit tests for change * [ ] Adds necessary E2E tests for change * [x] Unit tests passing * [ ] Extended the documentation / Created issue for it
# Description - Refactor to have single DeploymentObject for linkrp and corerp - refactor the deployment.Delete signature to take only outputresources - add a new async controller for createorupdate for linkrp ## Issue reference <!-- We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation. --> Fixes: https://dev.azure.com/azure-octo/Incubations/_workitems/edit/5788 ## Checklist Please make sure you've completed the relevant tasks for this PR, out of the following list: * [x] Code compiles correctly * [ ] Adds necessary unit tests for change * [ ] Adds necessary E2E tests for change * [x] Unit tests passing * [ ] Extended the documentation / Created issue for it
# Description Addressing few pr comments from #5006 ## Issue reference <!-- We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation. --> Fixes: #issue_number ## Checklist Please make sure you've completed the relevant tasks for this PR, out of the following list: * [x] Code compiles correctly * [ ] Adds necessary unit tests for change * [ ] Adds necessary E2E tests for change * [x] Unit tests passing * [ ] Extended the documentation / Created issue for it
Description
Issue reference
Fixes: https://dev.azure.com/azure-octo/Incubations/_workitems/edit/5788
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: