Enable GCP serial console for debug mode (#162)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2022-09-19 15:21:33 +02:00 committed by GitHub
parent d0ba2eb6b7
commit 9c00f4efc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 14 deletions

View File

@ -138,13 +138,14 @@ func (c *Creator) createGCP(ctx context.Context, cl gcpclient, config *config.Co
} }
createInput := gcpcl.CreateInstancesInput{ createInput := gcpcl.CreateInstancesInput{
CountControlPlanes: controlPlaneCount, EnableSerialConsole: config.IsDebugCluster(),
CountWorkers: workerCount, CountControlPlanes: controlPlaneCount,
ImageID: config.Provider.GCP.Image, CountWorkers: workerCount,
InstanceType: insType, ImageID: config.Provider.GCP.Image,
StateDiskSizeGB: config.StateDiskSizeGB, InstanceType: insType,
StateDiskType: config.Provider.GCP.StateDiskType, StateDiskSizeGB: config.StateDiskSizeGB,
KubeEnv: gcp.KubeEnv, StateDiskType: config.Provider.GCP.StateDiskType,
KubeEnv: gcp.KubeEnv,
} }
if err := cl.CreateInstances(ctx, createInput); err != nil { if err := cl.CreateInstances(ctx, createInput); err != nil {
return state.ConstellationState{}, err return state.ConstellationState{}, err

View File

@ -10,6 +10,7 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"strconv"
"strings" "strings"
"time" "time"
@ -32,11 +33,14 @@ func (c *Client) CreateInstances(ctx context.Context, input CreateInstancesInput
} }
ops := []Operation{} ops := []Operation{}
enableSerialConsole := strconv.FormatBool(input.EnableSerialConsole)
workerTemplateInput := insertInstanceTemplateInput{ workerTemplateInput := insertInstanceTemplateInput{
Name: c.buildResourceName("worker"), Name: c.buildResourceName("worker"),
Network: c.network, Network: c.network,
SecondarySubnetworkRangeName: c.secondarySubnetworkRange, SecondarySubnetworkRangeName: c.secondarySubnetworkRange,
Subnetwork: c.subnetwork, Subnetwork: c.subnetwork,
EnableSerialConsole: enableSerialConsole,
ImageID: input.ImageID, ImageID: input.ImageID,
InstanceType: input.InstanceType, InstanceType: input.InstanceType,
StateDiskSizeGB: int64(input.StateDiskSizeGB), StateDiskSizeGB: int64(input.StateDiskSizeGB),
@ -60,6 +64,7 @@ func (c *Client) CreateInstances(ctx context.Context, input CreateInstancesInput
Network: c.network, Network: c.network,
Subnetwork: c.subnetwork, Subnetwork: c.subnetwork,
SecondarySubnetworkRangeName: c.secondarySubnetworkRange, SecondarySubnetworkRangeName: c.secondarySubnetworkRange,
EnableSerialConsole: enableSerialConsole,
ImageID: input.ImageID, ImageID: input.ImageID,
InstanceType: input.InstanceType, InstanceType: input.InstanceType,
StateDiskSizeGB: int64(input.StateDiskSizeGB), StateDiskSizeGB: int64(input.StateDiskSizeGB),
@ -317,13 +322,14 @@ func (i *instanceGroupManagerInput) InsertInstanceGroupManagerRequest() computep
// CreateInstancesInput is the input for a CreatInstances operation. // CreateInstancesInput is the input for a CreatInstances operation.
type CreateInstancesInput struct { type CreateInstancesInput struct {
CountWorkers int EnableSerialConsole bool
CountControlPlanes int CountWorkers int
ImageID string CountControlPlanes int
InstanceType string ImageID string
StateDiskSizeGB int InstanceType string
StateDiskType string StateDiskSizeGB int
KubeEnv string StateDiskType string
KubeEnv string
} }
type insertInstanceTemplateInput struct { type insertInstanceTemplateInput struct {
@ -331,6 +337,7 @@ type insertInstanceTemplateInput struct {
Network string Network string
Subnetwork string Subnetwork string
SecondarySubnetworkRangeName string SecondarySubnetworkRangeName string
EnableSerialConsole string
ImageID string ImageID string
InstanceType string InstanceType string
StateDiskSizeGB int64 StateDiskSizeGB int64
@ -389,6 +396,10 @@ func (i insertInstanceTemplateInput) insertInstanceTemplateRequest() *computepb.
Key: proto.String("constellation-role"), Key: proto.String("constellation-role"),
Value: proto.String(i.Role), Value: proto.String(i.Role),
}, },
{
Key: proto.String("serial-port-enable"),
Value: proto.String(i.EnableSerialConsole),
},
}, },
}, },
NetworkInterfaces: []*computepb.NetworkInterface{ NetworkInterfaces: []*computepb.NetworkInterface{