feat: Add UI for awaiting agent connections (#578)

* feat: Add stage to build logs

This adds a stage property to logs, and refactors the job logs
cliui.

It also adds tests to the cliui for build logs!

* feat: Add stage to build logs

This adds a stage property to logs, and refactors the job logs
cliui.

It also adds tests to the cliui for build logs!

* feat: Add config-ssh and tests for resiliency

* Rename "Echo" test to "ImmediateExit"

* Fix Terraform resource agent association

* Fix logs post-cancel

* Fix select on Windows

* Remove terraform init logs

* Move timer into it's own loop

* Fix race condition in provisioner jobs

* Fix requested changes
This commit is contained in:
Kyle Carberry
2022-03-28 18:19:28 -06:00
committed by GitHub
parent 620c889842
commit 82dfd6c72f
26 changed files with 539 additions and 231 deletions

View File

@ -1,33 +1,48 @@
terraform {
required_providers {
coder = {
source = "coder/coder"
source = "coder/coder"
version = "0.2.1"
}
}
}
variable "gcp_credentials" {
sensitive = true
variable "service_account" {
description = <<EOF
Coder requires a Google Cloud Service Account to provision workspaces.
1. Create a service account:
https://console.cloud.google.com/projectselector/iam-admin/serviceaccounts/create
2. Add the roles:
- Compute Admin
- Service Account User
3. Click on the created key, and navigate to the "Keys" tab.
4. Click "Add key", then "Create new key".
5. Generate a JSON private key, and paste the contents in \'\' quotes below.
EOF
sensitive = true
}
variable "gcp_project" {
description = "The Google Cloud project to manage resources in."
}
variable "gcp_region" {
default = "us-central1"
variable "zone" {
description = "What region should your workspace live in?"
default = "us-central1-a"
validation {
condition = contains(["northamerica-northeast1-a", "us-central1-a", "us-west2-c", "europe-west4-b", "southamerica-east1-a"], var.zone)
error_message = "Invalid zone!"
}
}
provider "google" {
project = var.gcp_project
region = var.gcp_region
credentials = var.gcp_credentials
zone = var.zone
credentials = var.service_account
project = jsondecode(var.service_account).project_id
}
data "coder_workspace" "me" {
}
data "coder_agent_script" "dev" {
auth = "google-instance-identity"
arch = "amd64"
os = "windows"
}
@ -36,15 +51,24 @@ data "google_compute_default_service_account" "default" {
}
resource "random_string" "random" {
count = data.coder_workspace.me.transition == "start" ? 1 : 0
length = 8
special = false
}
resource "google_compute_disk" "root" {
name = "coder-${lower(random_string.random.result)}"
type = "pd-ssd"
zone = var.zone
image = "projects/windows-cloud/global/images/windows-server-2022-dc-core-v20220215"
lifecycle {
ignore_changes = [image]
}
}
resource "google_compute_instance" "dev" {
zone = "us-central1-a"
zone = var.zone
count = data.coder_workspace.me.transition == "start" ? 1 : 0
name = "coder-${lower(random_string.random[0].result)}"
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
machine_type = "e2-medium"
network_interface {
network = "default"
@ -53,15 +77,14 @@ resource "google_compute_instance" "dev" {
}
}
boot_disk {
initialize_params {
image = "projects/windows-cloud/global/images/windows-server-2022-dc-core-v20220215"
}
auto_delete = false
source = google_compute_disk.root.name
}
service_account {
email = data.google_compute_default_service_account.default.email
scopes = ["cloud-platform"]
}
metadata = {
metadata = {
windows-startup-script-ps1 = data.coder_agent_script.dev.value
serial-port-enable = "TRUE"
}
@ -69,8 +92,5 @@ resource "google_compute_instance" "dev" {
resource "coder_agent" "dev" {
count = length(google_compute_instance.dev)
auth {
type = "google-instance-identity"
instance_id = google_compute_instance.dev[0].instance_id
}
instance_id = google_compute_instance.dev[0].instance_id
}