Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: add startup script logs to the ui #6558

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

Merged
merged 34 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
99d510c
Add startup script logs to the database
code-asher Feb 23, 2023
66c8ec3
Add coderd endpoints for startup script logs
code-asher Feb 23, 2023
1cc3e9d
Push startup script logs from agent
code-asher Feb 23, 2023
45d250f
Pull startup script logs on frontend
code-asher Feb 23, 2023
7fed360
Merge branch 'main' into startuplogs
kylecarbs Mar 10, 2023
7ce73aa
Rename queries
kylecarbs Mar 10, 2023
b86c400
Add constraint
kylecarbs Mar 11, 2023
0c4d2c3
Start creating log sending loop
kylecarbs Mar 13, 2023
1bb700f
Add log sending to the agent
kylecarbs Mar 13, 2023
736705f
Add tests for streaming logs
kylecarbs Mar 13, 2023
f741523
Shorten notify channel name
kylecarbs Mar 14, 2023
54c30be
Add FE
kylecarbs Mar 14, 2023
adb06ea
Improve bulk log performance
kylecarbs Mar 15, 2023
4061b13
Finish UI display
kylecarbs Mar 15, 2023
4c5b630
Fix startup log visibility
kylecarbs Mar 15, 2023
05d536c
Add warning for overflow
kylecarbs Mar 16, 2023
34fde1a
Fix agent queue logs overflow
kylecarbs Mar 17, 2023
379f1f4
Display staartup logs in a virtual DOM for performance
kylecarbs Mar 19, 2023
decde5c
Fix agent queue with loads of logs
kylecarbs Mar 20, 2023
d74457c
Merge branch 'main' into startuplogs
kylecarbs Mar 20, 2023
ac55f48
Fix authorize test
kylecarbs Mar 20, 2023
8d75963
Remove faulty test
kylecarbs Mar 20, 2023
cc715cd
Fix startup and shutdown reporting error
kylecarbs Mar 20, 2023
e3a4b2c
Fix gen
kylecarbs Mar 20, 2023
399dad7
Merge branch 'main' into startuplogs
kylecarbs Mar 22, 2023
45c0aca
Fix comments
kylecarbs Mar 22, 2023
5a0b15d
Periodically purge old database entries
kylecarbs Mar 23, 2023
b1b3fcb
Add test fixture for migration
kylecarbs Mar 23, 2023
6e1032c
Add Storybook
kylecarbs Mar 23, 2023
3762e8d
Check if there are logs when displaying features
kylecarbs Mar 23, 2023
f6b9fce
Fix startup component overflow gap
kylecarbs Mar 23, 2023
c48658c
Fix startup log wrapping
kylecarbs Mar 23, 2023
4ec1a0e
Merge branch 'main' into startuplogs
kylecarbs Mar 23, 2023
b55b7a1
Merge branch 'main' into startuplogs
kylecarbs Mar 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into startuplogs
  • Loading branch information
kylecarbs committed Mar 10, 2023
commit 7fed360104fdb28e5d8c6885b0ee40b1b59b7e44
5 changes: 2 additions & 3 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,8 @@ func (a *agent) runScript(ctx context.Context, lifecycle, script string) error {
return nil
}

a.logger.Info(ctx, "running startup script", slog.F("script", script))

fileWriter, err := a.filesystem.OpenFile(filepath.Join(a.logDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600)
a.logger.Info(ctx, "running script", slog.F("lifecycle", lifecycle), slog.F("script", script))
fileWriter, err := a.filesystem.OpenFile(filepath.Join(a.logDir, fmt.Sprintf("coder-%s-script.log", lifecycle)), os.O_CREATE|os.O_RDWR, 0o600)
if err != nil {
return xerrors.Errorf("open %s script log file: %w", lifecycle, err)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ func TestAgent_StartupScript(t *testing.T) {
}
content := "output\n"
//nolint:dogsled
_, client, _, fs := setupAgent(t, agentsdk.Metadata{
_, client, _, fs, _ := setupAgent(t, agentsdk.Metadata{
StartupScript: "echo " + content,
}, 0)
var gotContent string
Expand Down
30 changes: 29 additions & 1 deletion coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 29 additions & 1 deletion coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions docs/api/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/{workspaceagent}/log
```json
[
{
"name": "string",
"agent_id": "string",
"job_id": "string",
"output": "string"
}
]
Expand All @@ -737,7 +738,8 @@ Status Code **200**
| Name | Type | Required | Restrictions | Description |
| -------------- | ------ | -------- | ------------ | ----------- |
| `[array item]` | array | false | | |
| `» name` | string | false | | |
| `» agent_id` | string | false | | |
| `» job_id` | string | false | | |
| `» output` | string | false | | |

To perform this operation, you must be authenticated. [Learn more](authentication.md).
Expand Down
36 changes: 19 additions & 17 deletions docs/api/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -3350,23 +3350,7 @@ Parameter represents a set value for the scope.
| `enabled` | boolean | false | | |
| `message` | string | false | | |

## codersdk.StartupScriptLog

```json
{
"name": "string",
"output": "string"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| -------- | ------ | -------- | ------------ | ----------- |
| `name` | string | false | | |
| `output` | string | false | | |

## codersdk.SwaggerConfig
## codersdk.SessionCountDeploymentStats

```json
{
Expand All @@ -3386,6 +3370,24 @@ Parameter represents a set value for the scope.
| `ssh` | integer | false | | |
| `vscode` | integer | false | | |

## codersdk.StartupScriptLog

```json
{
"agent_id": "string",
"job_id": "string",
"output": "string"
}
```

### Properties

| Name | Type | Required | Restrictions | Description |
| ---------- | ------ | -------- | ------------ | ----------- |
| `agent_id` | string | false | | |
| `job_id` | string | false | | |
| `output` | string | false | | |

## codersdk.SupportConfig

```json
Expand Down
11 changes: 8 additions & 3 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,14 @@ export const getStartupScriptLogs = async (
return response.data
}

export const getDeploymentConfig =
async (): Promise<TypesGen.DeploymentConfig> => {
const response = await axios.get(`/api/v2/config/deployment`)
export const getDeploymentValues = async (): Promise<DeploymentConfig> => {
const response = await axios.get(`/api/v2/deployment/config`)
return response.data
}

export const getDeploymentStats =
async (): Promise<TypesGen.DeploymentStats> => {
const response = await axios.get(`/api/v2/deployment/stats`)
return response.data
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.