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{
CountControlPlanes: controlPlaneCount,
CountWorkers: workerCount,
ImageID: config.Provider.GCP.Image,
InstanceType: insType,
StateDiskSizeGB: config.StateDiskSizeGB,
StateDiskType: config.Provider.GCP.StateDiskType,
KubeEnv: gcp.KubeEnv,
EnableSerialConsole: config.IsDebugCluster(),
CountControlPlanes: controlPlaneCount,
CountWorkers: workerCount,
ImageID: config.Provider.GCP.Image,
InstanceType: insType,
StateDiskSizeGB: config.StateDiskSizeGB,
StateDiskType: config.Provider.GCP.StateDiskType,
KubeEnv: gcp.KubeEnv,
}
if err := cl.CreateInstances(ctx, createInput); err != nil {
return state.ConstellationState{}, err

View File

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