8000 Merge branch 'main' of github.com:/coder/coder into dk/logreplacements · coder/coder@5df2cb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5df2cb3

Browse files
committed
Merge branch 'main' of github.com:/coder/coder into dk/logreplacements
2 parents 6b7a8b7 + 67e4024 commit 5df2cb3

File tree

122 files changed

+5322
-826
lines changed
  • coderd
  • codersdk/drpcsdk
  • docs
  • enterprise
  • provisionerd
  • provisionersdk
  • provisioner/terraform
  • scripts
  • site
  • tailnet
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    122 files changed

    +5322
    -826
    lines changed

    .gitignore

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -50,6 +50,7 @@ site/stats/
    5050
    *.tfplan
    5151
    *.lock.hcl
    5252
    .terraform/
    53+
    !coderd/testdata/parameters/modules/.terraform/
    5354
    !provisioner/terraform/testdata/modules-source-caching/.terraform/
    5455

    5556
    **/.coderv2/*

    agent/agent.go

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -89,6 +89,7 @@ type Options struct {
    8989
    ServiceBannerRefreshInterval time.Duration
    9090
    BlockFileTransfer bool
    9191
    Execer agentexec.Execer
    92+
    SubAgent bool
    9293

    9394
    ExperimentalDevcontainersEnabled bool
    9495
    ContainerAPIOptions []agentcontainers.Option // Enable ExperimentalDevcontainersEnabled for these to be effective.
    @@ -190,6 +191,8 @@ func New(options Options) Agent {
    190191
    metrics: newAgentMetrics(prometheusRegistry),
    191192
    execer: options.Execer,
    192193

    194+
    subAgent: options.SubAgent,
    195+
    193196
    experimentalDevcontainersEnabled: options.ExperimentalDevcontainersEnabled,
    194197
    containerAPIOptions: options.ContainerAPIOptions,
    195198
    }
    @@ -272,6 +275,8 @@ type agent struct {
    272275
    metrics *agentMetrics
    273276
    execer agentexec.Execer
    274277

    278+
    subAgent bool
    279+
    275280
    experimentalDevcontainersEnabled bool
    276281
    containerAPIOptions []agentcontainers.Option
    277282
    containerAPI atomic.Pointer[agentcontainers.API] // Set by apiHandler.

    agent/agenttest/client.go

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -60,6 +60,7 @@ func NewClient(t testing.TB,
    6060
    err = agentproto.DRPCRegisterAgent(mux, fakeAAPI)
    6161
    require.NoError(t, err)
    6262
    server := drpcserver.NewWithOptions(mux, drpcserver.Options{
    63+
    Manager: drpcsdk.DefaultDRPCOptions(nil),
    6364
    Log: func(err error) {
    6465
    if xerrors.Is(err, io.EOF) {
    6566
    return

    cli/agent.go

    Lines changed: 13 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -53,6 +53,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
    5353
    blockFileTransfer bool
    5454
    agentHeaderCommand string
    5555
    agentHeader []string
    56+
    subAgent bool
    5657

    5758
    experimentalDevcontainersEnabled bool
    5859
    )
    @@ -350,6 +351,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
    350351
    PrometheusRegistry: prometheusRegistry,
    351352
    BlockFileTransfer: blockFileTransfer,
    352353
    Execer: execer,
    354+
    SubAgent: subAgent,
    353355

    354356
    ExperimentalDevcontainersEnabled: experimentalDevcontainersEnabled,
    355357
    })
    @@ -481,6 +483,17 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
    481483
    Description: "Allow the agent to automatically detect running devcontainers.",
    482484
    Value: serpent.BoolOf(&experimentalDevcontainersEnabled),
    483485
    },
    486+
    {
    487+
    Flag: "is-sub-agent",
    488+
    Default: "false",
    489+
    Env: "CODER_AGENT_IS_SUB_AGENT",
    490+
    Description: "Specify whether this is a sub agent or not.",
    491+
    Value: serpent.BoolOf(&subAgent),
    492+
    // As `coderd` handles the creation of sub-agents, it does not make
    493+
    // sense for this to be exposed. We do not want people setting an
    494+
    // agent as a sub-agent if it is not.
    495+
    Hidden: true,
    496+
    },
    484497
    }
    485498

    486499
    return cmd

    cli/testdata/coder_users_--help.golden

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -10,10 +10,10 @@ USAGE:
    1010
    SUBCOMMANDS:
    1111
    activate Update a user's status to 'active'. Active users can fully
    1212
    interact with the platform
    13-
    create
    13+
    create Create a new user.
    1414
    delete Delete a user by username or user_id.
    1515
    edit-roles Edit a user's roles by username or id
    16-
    list
    16+
    list Prints the list of users.
    1717
    show Show a single user. Use 'me' to indicate the currently
    1818
    authenticated user.
    1919
    suspend Update a user's status to 'suspended'. A suspended user cannot

    cli/testdata/coder_users_create_--help.golden

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,6 +3,8 @@ coder v0.0.0-devel
    33
    USAGE:
    44
    coder users create [flags]
    55

    6+
    Create a new user.
    7+
    68
    OPTIONS:
    79
    -O, --org string, $CODER_ORGANIZATION
    810
    Select which organization (uuid or name) to use.

    cli/testdata/coder_users_list_--help.golden

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,6 +3,8 @@ coder v0.0.0-devel
    33
    USAGE:
    44
    coder users list [flags]
    55

    6+
    Prints the list of users.
    7+
    68
    Aliases: ls
    79

    810
    OPTIONS:

    cli/usercreate.go

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -28,7 +28,8 @@ func (r *RootCmd) userCreate() *serpent.Command {
    2828
    )
    2929
    client := new(codersdk.Client)
    3030
    cmd := &serpent.Command{
    31-
    Use: "create",
    31+
    Use: "create",
    32+
    Short: "Create a new user.",
    3233
    Middleware: serpent.Chain(
    3334
    serpent.RequireNArgs(0),
    3435
    r.InitClient(client),

    cli/userlist.go

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -23,6 +23,7 @@ func (r *RootCmd) userList() *serpent.Command {
    2323

    2424
    cmd := &serpent.Command{
    2525
    Use: "list",
    26+
    Short: "Prints the list of users.",
    2627
    Aliases: []string{"ls"},
    2728
    Middleware: serpent.Chain(
    2829
    serpent.RequireNArgs(0),

    coderd/agentapi/api.go

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -30,6 +30,7 @@ import (
    3030
    "github.com/coder/coder/v2/coderd/wspubsub"
    3131
    "github.com/coder/coder/v2/codersdk"
    3232
    "github.com/coder/coder/v2/codersdk/agentsdk"
    33+
    "github.com/coder/coder/v2/codersdk/drpcsdk"
    3334
    "github.com/coder/coder/v2/tailnet"
    3435
    tailnetproto "github.com/coder/coder/v2/tailnet/proto"
    3536
    "github.com/coder/quartz"
    @@ -209,6 +210,7 @@ func (a *API) Server(ctx context.Context) (*drpcserver.Server, error) {
    209210

    210211
    return drpcserver.NewWithOptions(&tracing.DRPCHandler{Handler: mux},
    211212
    drpcserver.Options{
    213+
    Manager: drpcsdk.DefaultDRPCOptions(nil),
    212214
    Log: func(err error) {
    213215
    if xerrors.Is(err, io.EOF) {
    214216
    return

    coderd/apidoc/docs.go

    Lines changed: 2 additions & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    coderd/apidoc/swagger.json

    Lines changed: 2 additions & 0 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    coderd/coderd.go

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -38,6 +38,7 @@ import (
    3838
    "tailscale.com/util/singleflight"
    3939

    4040
    "cdr.dev/slog"
    41+
    "github.com/coder/coder/v2/codersdk/drpcsdk"
    4142
    "github.com/coder/quartz"
    4243
    "github.com/coder/serpent"
    4344

    @@ -84,7 +85,6 @@ import (
    8485
    "github.com/coder/coder/v2/coderd/workspaceapps"
    8586
    "github.com/coder/coder/v2/coderd/workspacestats"
    8687
    "github.com/coder/coder/v2/codersdk"
    87-
    "github.com/coder/coder/v2/codersdk/drpcsdk"
    8888
    "github.com/coder/coder/v2/codersdk/healthsdk"
    8989
    "github.com/coder/coder/v2/provisionerd/proto"
    9090
    "github.com/coder/coder/v2/provisionersdk"
    @@ -1804,6 +1804,7 @@ func (api *API) CreateInMemoryTaggedProvisionerDaemon(dialCtx context.Context, n
    18041804
    }
    18051805
    server := drpcserver.NewWithOptions(&tracing.DRPCHandler{Handler: mux},
    18061806
    drpcserver.Options{
    1807+
    Manager: drpcsdk.DefaultDRPCOptions(nil),
    18071808
    Log: func(err error) {
    18081809
    if xerrors.Is(err, io.EOF) {
    18091810
    return

    coderd/database/dbmem/dbmem.go

    Lines changed: 17 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1380,6 +1380,12 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedGlobalQueue(
    13801380
    return jobs, nil
    13811381
    }
    13821382

    1383+
    // isDeprecated returns true if the template is deprecated.
    1384+
    // A template is considered deprecated when it has a deprecation message.
    1385+
    func isDeprecated(template database.Template) bool {
    1386+
    return template.Deprecated != ""
    1387+
    }
    1388+
    13831389
    func (*FakeQuerier) AcquireLock(_ context.Context, _ int64) error {
    13841390
    return xerrors.New("AcquireLock must only be called within a transaction")
    13851391
    }
    @@ -13023,7 +13029,17 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
    1302313029
    if arg.ExactName != "" && !strings.EqualFold(template.Name, arg.ExactName) {
    1302413030
    continue
    1302513031
    }
    13026-
    if arg.Deprecated.Valid && arg.Deprecated.Bool == (template.Deprecated != "") {
    13032+
    // Filters templates based on the search query filter 'Deprecated' status
    13033+
    // Matching SQL logic:
    13034+
    // -- Filter by deprecated
    13035+
    // AND CASE
    13036+
    // WHEN :deprecated IS NOT NULL THEN
    13037+
    // CASE
    13038+
    // WHEN :deprecated THEN deprecated != ''
    13039+
    // ELSE deprecated = ''
    13040+
    // END
    13041+
    // ELSE true
    13042+
    if arg.Deprecated.Valid && arg.Deprecated.Bool != isDeprecated(template) {
    1302713043
    continue
    1302813044
    }
    1302913045
    if arg.FuzzyName != "" {

    coderd/database/dump.sql

    Lines changed: 45 additions & 32 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,3 @@
    1+
    UPDATE notification_templates
    2+
    SET name = 'Test Notification'
    3+
    WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';
    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,3 @@
    1+
    UPDATE notification_templates
    2+
    SET name = 'Troubleshooting Notification'
    3+
    WHERE id = 'c425f63e-716a-4bf4-ae24-78348f706c3f';
    Lines changed: 58 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,58 @@
    1+
    DROP VIEW workspace_prebuilds;
    2+
    DROP VIEW workspace_latest_builds;
    3+
    4+
    -- Revert to previous version from 000314_prebuilds.up.sql
    5+
    CREATE VIEW workspace_latest_builds AS
    6+
    SELECT DISTINCT ON (workspace_id)
    7+
    wb.id,
    8+
    wb.workspace_id,
    9+
    wb.template_version_id,
    10+
    wb.job_id,
    11+
    wb.template_version_preset_id,
    12+
    wb.transition,
    13+
    wb.created_at,
    14+
    pj.job_status
    15+
    FROM workspace_builds wb
    16+
    INNER JOIN provisioner_jobs pj ON wb.job_id = pj.id
    17+
    ORDER BY wb.workspace_id, wb.build_number DESC;
    18+
    19+
    -- Recreate the dependent views
    20+
    CREATE VIEW workspace_prebuilds AS
    21+
    WITH all_prebuilds AS (
    22+
    SELECT w.id,
    23+
    w.name,
    24+
    w.template_id,
    25+
    w.created_at
    26+
    FROM workspaces w
    27+
    WHERE (w.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'::uuid)
    28+
    ), workspaces_with_latest_presets AS (
    29+
    SELECT DISTINCT ON (workspace_builds.workspace_id) workspace_builds.workspace_id,
    30+
    workspace_builds.template_version_preset_id
    31+
    FROM workspace_builds
    32+
    WHERE (workspace_builds.template_version_preset_id IS NOT NULL)
    33+
    ORDER BY workspace_builds.workspace_id, workspace_builds.build_number DESC
    34+
    ), workspaces_with_agents_status AS (
    35+
    SELECT w.id AS workspace_id,
    36+
    bool_and((wa.lifecycle_state = 'ready'::workspace_agent_lifecycle_state)) AS ready
    37+
    FROM (((workspaces w
    38+
    JOIN workspace_latest_builds wlb ON ((wlb.workspace_id = w.id)))
    39+
    JOIN workspace_resources wr ON ((wr.job_id = wlb.job_id)))
    40+
    JOIN workspace_agents wa ON ((wa.resource_id = wr.id)))
    41+
    WHERE (w.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'::uuid)
    42+
    GROUP BY w.id
    43+
    ), current_presets AS (
    44+
    SELECT w.id AS prebuild_id,
    45+
    wlp.template_version_preset_id
    46+
    FROM (workspaces w
    47+
    JOIN workspaces_with_latest_presets wlp ON ((wlp.workspace_id = w.id)))
    48+
    WHERE (w.owner_id = 'c42fdf75-3097-471c-8c33-fb52454d81c0'::uuid)
    49+
    )
    50+
    SELECT p.id,
    51+
    p.name,
    52+
    p.template_id,
    53+
    p.created_at,
    54+
    COALESCE(a.ready, false) AS ready,
    55+
    cp.template_version_preset_id AS current_preset_id
    56+
    FROM ((all_prebuilds p
    57+
    LEFT JOIN workspaces_with_agents_status a ON ((a.workspace_id = p.id)))
    58+
    JOIN current_presets cp ON ((cp.prebuild_id = p.id)));

    0 commit comments

    Comments
     (0)
    0