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

✨ Add /tasks patch; return 202 for task actions and updates. #660

Merged
merged 10 commits into from
Jun 14, 2024

Conversation

jortel
Copy link
Contributor

@jortel jortel commented Jun 14, 2024

Adds patch endpoints for:

  • /tasks
  • /taskgroups

The Update() methods on both Task and Taskgroup support both PUT and PATCH depending on the http method. They also support delegation from Submit() which mainly sets the state=Ready.

Updated to return 202 (accepted) on success.

  • put /tasks/:id
  • patch /tasks/:id
  • put /tasks/:id/cancel

BaseHandler.modBody() removed.

Add patch support to binding client.

Adds API test for task patch.

closes: #661
closes: #662

Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
const (
LocatorParam = "locator"
)

Copy link
Contributor Author

@jortel jortel Jun 14, 2024

Choose a reason for hiding this comment

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

hint: LocatorParam unused. The /tasks now supports filtering.

api/task.go Outdated
@@ -55,10 +51,11 @@ func (h TaskHandler) AddRoutes(e *gin.Engine) {
routeGroup.POST(TasksRoot, h.Create)
routeGroup.GET(TaskRoot, h.Get)
routeGroup.PUT(TaskRoot, h.Update)
routeGroup.PATCH(TaskRoot, Transaction, h.Patch)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hint: add patch.

routeGroup.DELETE(TaskRoot, h.Delete)
routeGroup.GET(TasksReportQueueRoot, h.Queued)
// Actions
routeGroup.PUT(TaskSubmitRoot, h.Submit, h.Update)
routeGroup.PUT(TaskSubmitRoot, Transaction, h.Submit)
Copy link
Contributor Author

@jortel jortel Jun 14, 2024

Choose a reason for hiding this comment

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

hint: with complexity delegated to the task manager, simpler to implement submit as a patch and no longer chain submit; state=Ready; update().
BaseHandler.modBody() should probably go away.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
}

// Submit godoc
// @summary Submit a task.
// @description Submit a task.
// @description Patch and submit a task.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hint: Much better for the caller to be able to patch a task when submitting rather than update. This will support submit with minimal or no patch.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
@jortel jortel marked this pull request as ready for review June 14, 2024 18:22
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
ctx.Request.Body = io.NopCloser(bfr)
return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hint: removed in favor of simpler, more direct approach.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
task/manager.go Outdated
@@ -188,23 +188,19 @@ func (m *Manager) Update(db *gorm.DB, requested *Task) (err error) {
task.TTL = requested.TTL
task.Data = requested.Data
task.ApplicationID = requested.ApplicationID
task.BucketID = requested.BucketID
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hint: fixes taskgroup bucket propagation broken in multi-provider pr.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
Copy link
Collaborator

@mansam mansam left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -150,6 +150,7 @@ func (m *Manager) Create(db *gorm.DB, requested *Task) (err error) {
task.TTL = requested.TTL
task.Data = requested.Data
task.ApplicationID = requested.ApplicationID
task.BucketID = requested.BucketID
Copy link
Contributor Author

@jortel jortel Jun 14, 2024

Choose a reason for hiding this comment

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

hint: fixes task group bucket propagation. ^ broken by earlier multi-provider PR.
noticed while regression testing.

Signed-off-by: Jeff Ortel <jortel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Return 202 (accepted) for task update and cancel. ✨ Add patch support for /tasks and /taskgroups.
2 participants