Description
I believe an agent script timing should only be reported once per build since the script only runs once per build. Considering this, the response from the /api/v2/workspacebuilds/build-id/timings
endpoint becomes confusing when it returns multiple agent script timings for the same script in the same build.
For instance, here's an example of the response:
Response
{
"provisioner_timings": [
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:09.36658Z",
"ended_at": "2024-12-18T16:07:12.056761Z",
"stage": "init",
"source": "terraform",
"action": "initializing terraform",
"resource": "state file"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.248206Z",
"ended_at": "2024-12-18T16:07:13.25545Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.git_email"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.248394Z",
"ended_at": "2024-12-18T16:07:13.255321Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.gpu"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.249603Z",
"ended_at": "2024-12-18T16:07:13.255382Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.git_user_name"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.252024Z",
"ended_at": "2024-12-18T16:07:13.256101Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.splunk_version"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.25204Z",
"ended_at": "2024-12-18T16:07:13.256586Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.home_disk_size"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.252068Z",
"ended_at": "2024-12-18T16:07:13.255598Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_workspace.me"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.253162Z",
"ended_at": "2024-12-18T16:07:13.257632Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.memory"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.253177Z",
"ended_at": "2024-12-18T16:07:13.258667Z",
"stage": "plan",
"source": "coder",
"action": "read",
"resource": "data.coder_parameter.cpu"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.262178Z",
"ended_at": "2024-12-18T16:07:13.266056Z",
"stage": "plan",
"source": "coder",
"action": "state refresh",
"resource": "coder_agent.main"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.277698Z",
"ended_at": "2024-12-18T16:07:13.281774Z",
"stage": "plan",
"source": "coder",
"action": "state refresh",
"resource": "coder_script.splunk_ansible"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.277881Z",
"ended_at": "2024-12-18T16:07:13.281838Z",
"stage": "plan",
"source": "coder",
"action": "state refresh",
"resource": "coder_app.code-server"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.281617Z",
"ended_at": "2024-12-18T16:07:13.283034Z",
"stage": "plan",
"source": "coder",
"action": "state refresh",
"resource": "coder_app.splunk"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.290473Z",
"ended_at": "2024-12-18T16:07:13.309158Z",
"stage": "plan",
"source": "kubernetes",
"action": "state refresh",
"resource": "kubernetes_persistent_volume_claim.home"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:13.406039Z",
"ended_at": "2024-12-18T16:07:14.77887Z",
"stage": "graph",
"source": "terraform",
"action": "building terraform dependency graph",
"resource": "state file"
},
{
"job_id": "70dc09b7-199b-4853-9e03-5d3b8b6c007d",
"started_at": "2024-12-18T16:07:15.726965Z",
"ended_at": "2024-12-18T16:07:15.810591Z",
"stage": "apply",
"source": "kubernetes",
"action": "create",
"resource": "kubernetes_deployment.main[0]"
}
],
"agent_script_timings": [
{
"started_at": "2024-12-18T16:07:49.769585Z",
"ended_at": "2024-12-18T16:07:51.118721Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "Startup Script",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2024-12-19T06:48:24.52297Z",
"ended_at": "2024-12-19T06:48:30.545644Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "Startup Script",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2024-12-19T09:18:35.94846Z",
"ended_at": "2024-12-19T09:18:37.509152Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "Startup Script",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2025-01-04T17:38:34.907521Z",
"ended_at": "2025-01-04T17:38:41.363145Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "Startup Script",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2025-01-04T17:52:38.905293Z",
"ended_at": "2025-01-04T17:52:40.977108Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "Startup Script",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2024-12-18T16:07:49.769517Z",
"ended_at": "2024-12-18T16:09:15.998633Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "splunk_ansible",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2024-12-19T06:48:24.523009Z",
"ended_at": "2024-12-19T06:49:51.191554Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "splunk_ansible",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2024-12-19T09:18:35.948436Z",
"ended_at": "2024-12-19T09:20:04.274409Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "splunk_ansible",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
},
{
"started_at": "2025-01-04T17:52:38.949353Z",
"ended_at": "2025-01-04T17:56:30.692371Z",
"exit_code": 0,
"stage": "start",
"status": "ok",
"display_name": "splunk_ansible",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
}
],
"agent_connection_timings": [
{
"started_at": "2024-12-18T16:07:17.575081Z",
"ended_at": "2024-12-18T16:07:49.708293Z",
"stage": "connect",
"workspace_agent_id": "137a736b-a619-437d-b653-6a117f85069d",
"workspace_agent_name": "main"
}
]
}
Multiple timings for the "Startup Script" are reported, spanning different dates within the same build, which doesn’t align with expected behavior.
Possible Causes:
- Incorrect Build ID Insertion: Agent script timings may be incorrectly associated with the wrong build ID.
- Query Error: The API query for fetching agent script timings might be flawed.
Additional Context:
- This issue is related to #15921.
- A workaround for a similar problem was implemented in this PR.
- Fixes for agent script timings in this PR might have introduced this bug again.