Skip to content

coder_agent.metadata includes stderr #208

Open
@NiklasRosenstein

Description

@NiklasRosenstein

This is more of an unfortunate circumstance, but one where I don't think there is a workaround.

Terraform Version

Terraform v1.7.5
+ provider registry.terraform.io/coder/coder v0.20.1

Affected Resource(s)

  • coder_agent

Terraform Configuration Files

resource "coder_agent" "this" {
  os   = "linux"
  arch = "amd64"
  dir  = "/home/coder"

  metadata {
    display_name = "CPU Usage"
    key          = "cpu_usage"
    script       = "coder stat cpu"
    interval     = 10
    timeout      = 1
    order        = 1
  }

  metadata {
    display_name = "RAM Usage"
    key          = "ram_usage"
    script       = "coder stat mem"
    interval     = 10
    timeout      = 1
    order        = 2
  }

  metadata {
    display_name = "Disk Usage"
    key          = "disk_usage"
    script       = "coder stat disk"
    interval     = 10
    timeout      = 1
    order        = 3
  }

  metadata {
    display_name = "Uptime"
    key          = "uptime"
    script       = "uptime -p"
    interval     = 10
    timeout      = 1
    order        = 4
  }

  order = 1
}

Expected Behavior

The metadata contains the expected output.

Actual Behavior

If the ~/.bashrc prints a message, for example an error message to stderr, that message is included in the metadata. This is unexpected because it isn't strictly expected IMO that ~/.bashrc is even sourced for the script invokation.

As far as I can tell there's no workaround other than to fix the ~/.bashrc, which is unfortunate for administrators of the Coder template who have no control over the user's rc-file.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions