Fixes for Issues with Beacon Tasks #1928
Open
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.
I received a report that beacon tasks could not be cancelled because of a database issue. It turns out that listing beacon tasks was not possible because of a related root issue.
When cancelling a beacon task, saving the object after updating the state field caused GORM to write the timestamp for the
created_at
column as an integer. When thecreated_at
column was read back in, GORM was trying to convert the integer value into atime.Time
object which it did not like. Sincecreated_at
is only modified at creation time, there is no need to update the entire object usingSave()
. This PR updates only theState
field when a task is cancelled which avoids messing with thecreated_at
field.When listing beacon tasks, something similar was happening. When we were selecting tasks using
.Select()
to avoid grabbing therequest
andresponse
columns, that bypasses GORM's field to column mapping, and GORM tries to cast the timestamp into atime.Time
object unsuccessfully. This PR grabs the entire object and instructs theToProtobuf
function to omit theRequest
andResponse
fields.While I was going down these rabbit holes, I noticed that if you cancelled a task and specified its ID (
tasks cancel [ID]
), the server panicked. It looks like theRequest
column was pulled and when passed back to the server, it panicked. This PR nils those fields before sending the task to the server.