ci: Replace DataDog CI with custom upload script (#169)

* ci: Replace DataDog CI with custom upload script

This will reduce CI time by ~6 minutes across all of
our runners. It's a bit janky, but I believe worth
the slight maintainance burden.

* Fix test race when job would complete too early

* Fix job cancelation override

* Fix race where provisioner job is inserted before project version
This commit is contained in:
Kyle Carberry
2022-02-07 11:32:32 -06:00
committed by GitHub
parent 4cd026103f
commit 3002a27dd1
9 changed files with 248 additions and 74 deletions

View File

@ -126,17 +126,32 @@ func (api *api) postWorkspaceHistoryByUser(rw http.ResponseWriter, r *http.Reque
// This must happen in a transaction to ensure history can be inserted, and
// the prior history can update it's "after" column to point at the new.
err = api.Database.InTx(func(db database.Store) error {
// Generate the ID before-hand so the provisioner job is aware of it!
workspaceHistoryID := uuid.New()
provisionerJobID := uuid.New()
workspaceHistory, err = db.InsertWorkspaceHistory(r.Context(), database.InsertWorkspaceHistoryParams{
ID: uuid.New(),
CreatedAt: database.Now(),
UpdatedAt: database.Now(),
WorkspaceID: workspace.ID,
ProjectVersionID: projectVersion.ID,
BeforeID: priorHistoryID,
Name: namesgenerator.GetRandomName(1),
Initiator: user.ID,
Transition: createBuild.Transition,
ProvisionJobID: provisionerJobID,
})
if err != nil {
return xerrors.Errorf("insert workspace history: %w", err)
}
input, err := json.Marshal(workspaceProvisionJob{
WorkspaceHistoryID: workspaceHistoryID,
WorkspaceHistoryID: workspaceHistory.ID,
})
if err != nil {
return xerrors.Errorf("marshal provision job: %w", err)
}
provisionerJob, err = db.InsertProvisionerJob(r.Context(), database.InsertProvisionerJobParams{
ID: uuid.New(),
ID: provisionerJobID,
CreatedAt: database.Now(),
UpdatedAt: database.Now(),
InitiatorID: user.ID,
@ -149,22 +164,6 @@ func (api *api) postWorkspaceHistoryByUser(rw http.ResponseWriter, r *http.Reque
return xerrors.Errorf("insert provisioner job: %w", err)
}
workspaceHistory, err = db.InsertWorkspaceHistory(r.Context(), database.InsertWorkspaceHistoryParams{
ID: workspaceHistoryID,
CreatedAt: database.Now(),
UpdatedAt: database.Now(),
WorkspaceID: workspace.ID,
ProjectVersionID: projectVersion.ID,
BeforeID: priorHistoryID,
Name: namesgenerator.GetRandomName(1),
Initiator: user.ID,
Transition: createBuild.Transition,
ProvisionJobID: provisionerJob.ID,
})
if err != nil {
return xerrors.Errorf("insert workspace history: %w", err)
}
if priorHistoryID.Valid {
// Update the prior history entries "after" column.
err = db.UpdateWorkspaceHistoryByID(r.Context(), database.UpdateWorkspaceHistoryByIDParams{