feat(tasks): add uploading task status#88
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please ensure your PR meets the following requirements:
Summary
This PR adds an explicit
uploadingtask state to the recorder/transfer flow and improves task recovery observability when upload triggering or completion is retried.It also standardizes recorder/transfer logs with device/task context, updates production dashboard task statistics, and refreshes design documentation for the callback-driven task lifecycle.
Motivation
upload_requestcould not be sent because Transfer was disconnected or timed out, operators had limited visibility into why a task remained unfinished.upload_completeevents needed to remain ACK-safe without re-triggering batch/order advancement.Changes
Modified Files
internal/api/handlers/task.go- Marks finished recordings asuploading, records upload request send errors, clears upload errors after successful send, and logs state transitions with device/task prefixes.internal/api/handlers/transfer.go- Completes tasks after verified upload ACK, keeps duplicate completed ACKs idempotent, logscompletedtransitions, and clears upload request errors after manual upload requests succeed.internal/api/handlers/axon_rpc.go- Standardizes recorder state/config logs with[RECORDER][device][task]style context.internal/api/handlers/production_dashboard.go- Includesuploadingin dashboard task counts and trends.internal/api/handlers/task_state_recovery_test.go- Adds coverage for finish callback upload timeout/disconnected recovery behavior.internal/api/handlers/recorder_axon_interaction_test.go- Updates recorder interaction coverage for the uploading lifecycle.internal/api/handlers/transfer_connection_takeover_test.go- Updates Transfer disconnect/takeover expectations for uploading tasks.internal/api/handlers/batch.go- Removes a stale task status trigger map left over from the removed task update API.internal/storage/database/migrations/000001_initial_schema.up.sql- Updates the initial task status enum definition for fresh installs.docs/designs/production-units.md- Documentsuploading, verified ACK completion, and duplicate ACK behavior.docs/designs/task-manage.md- Refreshes the task state machine to match recorder callbacks and Transfer upload events.docs/designs/upload-service-design.md- Aligns upload flow documentation with the new task state.Added Files
internal/api/handlers/task_uploading.go- Adds shared helpers for owned task uploading/failed/error-message transitions.internal/storage/database/migrations/000005_task_uploading_status.up.sql- Addsuploadingto the persisted task status enum.internal/storage/database/migrations/000005_task_uploading_status.down.sql- Provides rollback fromuploadingtoin_progressbefore removing the enum value.docs/designs/task-uploading-status.zh.html- Adds the UT/design validation document for the uploading status flow.Deleted Files
Type of Change
Impact Analysis
Breaking Changes
None.
Backward Compatibility
Fully backward compatible for API clients. Existing pre-upload task states remain accepted on upload completion for weak-network recovery, while the normal post-recording path now uses
uploading.Database migration adds the new
uploadingenum value and includes a rollback path that rewritesuploadingtasks toin_progressbefore removing the enum value.Testing
Test Environment
feat/task-uploading-status/tmp/go-buildto avoid read-only home cache issuesTest Cases
Commands run:
Manual Testing Steps
uploadingand triggers Transfer upload.[RECORDER][device][task]and[TRANSFER][device][task]messages.Test Coverage
Screenshots / Recordings
N/A. Backend flow and documentation change.
Performance Impact
Documentation
Related Issues
Additional Notes
upload_completeremains safe: Keystone still sendsupload_ack, but does not re-run batch/order advancement for tasks that were alreadycompleted.upload_requestsend failures keep the task inuploadingand writetasks.error_messagefor operator visibility instead of marking the taskfailed.Reviewers
N/A
Notes for Reviewers
OnRecordingFinish,onUploadComplete, andupload_failedhandling.uploadingtasks.Checklist for Reviewers