Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: add constraint and runtime check for provisioner logs size limit#18893

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

bcpeinhardt
Copy link
Contributor

@bcpeinhardtbcpeinhardt commentedJul 15, 2025
edited
Loading

This PR sets a constraint of 1MB on the provisioner job logs written to the database. This is consistent with the constraint we place on workspace agent logs:

CONSTRAINT max_logs_lengthCHECK ((logs_length<=1048576)),

It also adds a message printed to the front end about the provisioner log overflow, and updates the message printed to the front end when workspace startup logs exceed the max, as it was causing some customers to think their startup script had failed to run.

Closes#17992

@bcpeinhardtbcpeinhardt changed the titlebcpeinhardt/17992 fix startup logs size limit bugfix: 17992 startup logs size limit bugJul 15, 2025
@bcpeinhardtbcpeinhardt changed the titlefix: 17992 startup logs size limit bugfix: add constraint and runtime check for provisioner logs size limitJul 15, 2025
Comment on lines 941 to 960
err=s.Database.UpdateProvisionerJobLogsLength(ctx, database.UpdateProvisionerJobLogsLengthParams{
ID:parsedID,
LogsLength:int32(newLogSize),// #nosec G115 - Log output length is limited to 1MB (2^20) which fits in an int32.
})
iferr!=nil {
ifdatabase.IsProvisionerJobLogsLimitError(err) {
err=s.Database.UpdateProvisionerJobLogsOverflowed(ctx, database.UpdateProvisionerJobLogsOverflowedParams{
ID:parsedID,
LogsOverflowed:true,
})
iferr!=nil {
s.Logger.Error(ctx,"failed to set logs overflowed flag",slog.F("job_id",parsedID),slog.Error(err))
}
return&proto.UpdateJobResponse{
Canceled:job.CanceledAt.Valid,
},nil
}
s.Logger.Error(ctx,"failed to update logs length",slog.F("job_id",parsedID),slog.Error(err))
returnnil,xerrors.Errorf("update logs length: %w",err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it might be a good idea to store the current logs length and overflow state as variables in this Go code. With that change we would update the length var when anInsert call is successful, and we can determine prior to insertion whether the log we want to insert will cause the overflow. That way we can avoid the extras.Database.UpdateProvisionerJobLogsLength call on every log line after an overflow has occurred.

@coderabbitaicoderabbitai
Copy link

coderabbitaibot commentedJul 21, 2025
edited
Loading

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the.coderabbit.yaml file in this repository. To trigger a single review, invoke the@coderabbitai review command.

You can disable this status message by setting thereviews.review_status tofalse in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branchbcpeinhardt/17992-fix-startup-logs-size-limit-bug

🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

@bcpeinhardtbcpeinhardt marked this pull request as ready for reviewJuly 21, 2025 16:13
id> @created_after
)ORDER BY idASC;

-- name: GetProvisionerJobLogSize :one
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I can remove this query now I think.

level:"error",
output:"Startup logs exceeded the max size of 1MB!",
output:
"Startup logs exceeded the max size of 1MB, and will not continue to be written to the database! Logs will continue to be written to the /tmp/coder-startup-script.log file in the workspace.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should the other places for the logging also contain the more descriptive message, inWorkspaceBuildLogs.tsx andWorkspaceBuildPageView.tsx?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I think so :)

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJul 29, 2025
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelJul 30, 2025
Copy link
Contributor

@cstyancstyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Approving, just one bit I'm unsure about in the rbac stuff.

}

func (q*querier)UpdateProvisionerJobLogsLength(ctx context.Context,arg database.UpdateProvisionerJobLogsLengthParams)error {
// Not sure what the rbac should be here, going with this for now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is the only bit I'm unsure of, maybe include the same comment as the other provisioner related functions have?

// TODO: Remove this once we have a proper rbac check for provisioner jobs.// Details in https://github.com/coder/coder/issues/16160

or ask@mafredri since he opened that issue?

Copy link
ContributorAuthor

@bcpeinhardtbcpeinhardtJul 30, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Our manual testing was actually from the admin account, we should look at this again before merging I think.
Edit: I tested with a member account and everything works fine. I could be way off here but I think the action.Update on the ResourceProvisionerJob is coming from the template admin?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There are several other queries which perform the same rbac check we do to update fields on the ProvisionerJobs table, so I feel comfortable merging this and revisiting the provisioner jobs rbac in the future.

@bcpeinhardtbcpeinhardt merged commite4dc2d9 intomainJul 31, 2025
31 checks passed
@bcpeinhardtbcpeinhardt deleted the bcpeinhardt/17992-fix-startup-logs-size-limit-bug branchJuly 31, 2025 00:09
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 31, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@cstyancstyancstyan approved these changes

@aslilacaslilacAwaiting requested review from aslilacaslilac is a code owner

Assignees

@bcpeinhardtbcpeinhardt

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Clarify language in startup script warning to be less confusing
2 participants
@bcpeinhardt@cstyan

[8]ページ先頭

©2009-2025 Movatter.jp