Rename to contol plane/workers

AB#1954
This commit is contained in:
katexochen 2022-04-27 14:21:36 +02:00 committed by Paul Meyer
parent f8f5d20f5b
commit 469b2ff46c
6 changed files with 27 additions and 27 deletions

View File

@ -20,10 +20,10 @@ import (
func newCreateCmd() *cobra.Command { func newCreateCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create {aws|gcp|azure} C_COUNT N_COUNT TYPE", Use: "create {aws|gcp|azure} C_COUNT W_COUNT TYPE",
Short: "Create instances on a cloud platform for your Constellation.", Short: "Create instances on a cloud platform for your Constellation.",
Long: `Create instances on a cloud platform for your Constellation. Long: `Create instances on a cloud platform for your Constellation.
A Constellation with C_COUNT Coordinators and N_COUNT Nodes is created. A Constellation with C_COUNT control-plane nodes and W_COUNT workers is created.
TYPE is the instance type used for all instances.`, TYPE is the instance type used for all instances.`,
Args: cobra.MatchAll( Args: cobra.MatchAll(
cobra.ExactArgs(4), cobra.ExactArgs(4),
@ -72,8 +72,8 @@ func create(cmd *cobra.Command, creator cloudCreator, fileHandler file.Handler,
if !flags.yes { if !flags.yes {
// Ask user to confirm action. // Ask user to confirm action.
cmd.Printf("The following Constellation will be created:\n") cmd.Printf("The following Constellation will be created:\n")
cmd.Printf("%d coordinators of type %s will be created.\n", countCoord, insType) cmd.Printf("%d control-planes nodes of type %s will be created.\n", countCoord, insType)
cmd.Printf("%d nodes of type %s will be created.\n", countNode, insType) cmd.Printf("%d worker nodes of type %s will be created.\n", countNode, insType)
ok, err := askToConfirm(cmd, "Do you want to create this Constellation?") ok, err := askToConfirm(cmd, "Do you want to create this Constellation?")
if err != nil { if err != nil {
return err return err
@ -105,7 +105,7 @@ func parseCreateFlags(cmd *cobra.Command) (createFlags, error) {
} }
if len(name) > constellationNameLength { if len(name) > constellationNameLength {
return createFlags{}, fmt.Errorf( return createFlags{}, fmt.Errorf(
"name for constellation too long, maximum length is %d, got %d: %s", "name for Constellation too long, maximum length is %d, got %d: %s",
constellationNameLength, len(name), name, constellationNameLength, len(name), name,
) )
} }

View File

@ -28,8 +28,8 @@ func TestCreateArgumentValidation(t *testing.T) {
"gcp valid create 3": {[]string{"gcp", "1", "2", "n2d-standard-96"}, false}, "gcp valid create 3": {[]string{"gcp", "1", "2", "n2d-standard-96"}, false},
"gcp invalid too many arguments": {[]string{"gcp", "3", "2", "n2d-standard-2", "n2d-standard-2"}, true}, "gcp invalid too many arguments": {[]string{"gcp", "3", "2", "n2d-standard-2", "n2d-standard-2"}, true},
"gcp invalid too many arguments 2": {[]string{"gcp", "3", "2", "n2d-standard-2", "2"}, true}, "gcp invalid too many arguments 2": {[]string{"gcp", "3", "2", "n2d-standard-2", "2"}, true},
"gcp invalid no coordinators": {[]string{"gcp", "0", "1", "n2d-standard-2"}, true}, "gcp invalid no control planes": {[]string{"gcp", "0", "1", "n2d-standard-2"}, true},
"gcp invalid no nodes": {[]string{"gcp", "1", "0", "n2d-standard-2"}, true}, "gcp invalid no workers": {[]string{"gcp", "1", "0", "n2d-standard-2"}, true},
"gcp invalid first is no int": {[]string{"gcp", "n2d-standard-2", "1", "n2d-standard-2"}, true}, "gcp invalid first is no int": {[]string{"gcp", "n2d-standard-2", "1", "n2d-standard-2"}, true},
"gcp invalid second is no int": {[]string{"gcp", "3", "n2d-standard-2", "n2d-standard-2"}, true}, "gcp invalid second is no int": {[]string{"gcp", "3", "n2d-standard-2", "n2d-standard-2"}, true},
"gcp invalid third is no size": {[]string{"gcp", "2", "2", "2"}, true}, "gcp invalid third is no size": {[]string{"gcp", "2", "2", "2"}, true},
@ -39,8 +39,8 @@ func TestCreateArgumentValidation(t *testing.T) {
"azure valid create 3": {[]string{"azure", "1", "2", "Standard_DC8as_v5"}, false}, "azure valid create 3": {[]string{"azure", "1", "2", "Standard_DC8as_v5"}, false},
"azure invalid to many arguments": {[]string{"azure", "3", "2", "Standard_DC2as_v5", "Standard_DC2as_v5"}, true}, "azure invalid to many arguments": {[]string{"azure", "3", "2", "Standard_DC2as_v5", "Standard_DC2as_v5"}, true},
"azure invalid to many arguments 2": {[]string{"azure", "3", "2", "Standard_DC2as_v5", "2"}, true}, "azure invalid to many arguments 2": {[]string{"azure", "3", "2", "Standard_DC2as_v5", "2"}, true},
"azure invalid no coordinators": {[]string{"azure", "0", "1", "Standard_DC2as_v5"}, true}, "azure invalid no control planes": {[]string{"azure", "0", "1", "Standard_DC2as_v5"}, true},
"azure invalid no nodes": {[]string{"azure", "1", "0", "Standard_DC2as_v5"}, true}, "azure invalid no workers": {[]string{"azure", "1", "0", "Standard_DC2as_v5"}, true},
"azure invalid first is no int": {[]string{"azure", "Standard_DC2as_v5", "1", "Standard_DC2as_v5"}, true}, "azure invalid first is no int": {[]string{"azure", "Standard_DC2as_v5", "1", "Standard_DC2as_v5"}, true},
"azure invalid second is no int": {[]string{"azure", "1", "Standard_DC2as_v5", "Standard_DC2as_v5"}, true}, "azure invalid second is no int": {[]string{"azure", "1", "Standard_DC2as_v5", "Standard_DC2as_v5"}, true},
"azure invalid third is no size": {[]string{"azure", "2", "2", "2"}, true}, "azure invalid third is no size": {[]string{"azure", "2", "2", "2"}, true},

View File

@ -61,8 +61,8 @@ func runInitialize(cmd *cobra.Command, args []string) error {
return initialize(cmd.Context(), cmd, protoClient, serviceAccountCreator, fileHandler, waiter, vpnHandler) return initialize(cmd.Context(), cmd, protoClient, serviceAccountCreator, fileHandler, waiter, vpnHandler)
} }
// initialize initializes a Constellation. Coordinator instances are activated as Coordinators and will // initialize initializes a Constellation. Coordinator instances are activated as contole-plane nodes and will
// themself activate the other peers as nodes. // themself activate the other peers as workers.
func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, serviceAccCreator serviceAccountCreator, func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, serviceAccCreator serviceAccountCreator,
fileHandler file.Handler, waiter statusWaiter, vpnHandler vpnHandler, fileHandler file.Handler, waiter statusWaiter, vpnHandler vpnHandler,
) error { ) error {
@ -106,7 +106,7 @@ func initialize(ctx context.Context, cmd *cobra.Command, protCl protoClient, ser
endpoints := ipsToEndpoints(append(coordinators.PublicIPs(), nodes.PublicIPs()...), *config.CoordinatorPort) endpoints := ipsToEndpoints(append(coordinators.PublicIPs(), nodes.PublicIPs()...), *config.CoordinatorPort)
cmd.Println("Waiting for cloud provider to finish resource creation ...") cmd.Println("Waiting for cloud provider resource creation and boot ...")
if err := waiter.InitializeValidators(validators.V()); err != nil { if err := waiter.InitializeValidators(validators.V()); err != nil {
return err return err
} }
@ -235,12 +235,12 @@ func writeWGQuickFile(fileHandler file.Handler, vpnHandler vpnHandler, vpnConfig
} }
func (r activationResult) writeOutput(wr io.Writer, fileHandler file.Handler) error { func (r activationResult) writeOutput(wr io.Writer, fileHandler file.Handler) error {
fmt.Fprint(wr, "Your Constellation was successfully initialized.\n\n") fmt.Fprint(wr, "Your Constellation cluster was successfully initialized.\n\n")
tw := tabwriter.NewWriter(wr, 0, 0, 2, ' ', 0) tw := tabwriter.NewWriter(wr, 0, 0, 2, ' ', 0)
writeRow(tw, "Your WireGuard IP", r.clientVpnIP) writeRow(tw, "Your WireGuard IP", r.clientVpnIP)
writeRow(tw, "Coordinator's public IP", r.coordinatorPubIP) writeRow(tw, "Control plane's public IP", r.coordinatorPubIP)
writeRow(tw, "Coordinator's public key", r.coordinatorPubKey) writeRow(tw, "Control plane's public key", r.coordinatorPubKey)
writeRow(tw, "Constellation's owner identifier", r.ownerID) writeRow(tw, "Constellation's owner identifier", r.ownerID)
writeRow(tw, "Constellation's unique identifier", r.clusterID) writeRow(tw, "Constellation's unique identifier", r.clusterID)
writeRow(tw, "WireGuard configuration file", constants.WGQuickConfigFilename) writeRow(tw, "WireGuard configuration file", constants.WGQuickConfigFilename)
@ -252,7 +252,7 @@ func (r activationResult) writeOutput(wr io.Writer, fileHandler file.Handler) er
return fmt.Errorf("write kubeconfig: %w", err) return fmt.Errorf("write kubeconfig: %w", err)
} }
fmt.Fprintln(wr, "You can now connect to your Constellation by executing:") fmt.Fprintln(wr, "You can now connect to your Constellation cluster by executing:")
fmt.Fprintf(wr, "\twg-quick up ./%s\n", constants.WGQuickConfigFilename) fmt.Fprintf(wr, "\twg-quick up ./%s\n", constants.WGQuickConfigFilename)
fmt.Fprintf(wr, "\texport KUBECONFIG=\"$PWD/%s\"\n", constants.AdminConfFilename) fmt.Fprintf(wr, "\texport KUBECONFIG=\"$PWD/%s\"\n", constants.AdminConfFilename)
return nil return nil
@ -387,7 +387,7 @@ func getScalingGroupsFromConfig(stat state.ConstellationState, config *config.Co
case len(stat.QEMUCoordinators) != 0: case len(stat.QEMUCoordinators) != 0:
return getQEMUInstances(stat, config) return getQEMUInstances(stat, config)
default: default:
return ScalingGroup{}, ScalingGroup{}, errors.New("no instances to init") return ScalingGroup{}, ScalingGroup{}, errors.New("no instances to initialize")
} }
} }
@ -409,7 +409,7 @@ func getAWSInstances(stat state.ConstellationState) (coordinators, nodes Scaling
nodeMap := stat.EC2Instances.GetOthers(coordinatorID) nodeMap := stat.EC2Instances.GetOthers(coordinatorID)
if len(nodeMap) == 0 { if len(nodeMap) == 0 {
return ScalingGroup{}, ScalingGroup{}, errors.New("no nodes available, can't create Constellation with one instance") return ScalingGroup{}, ScalingGroup{}, errors.New("no worker nodes available, can't create Constellation cluster with one instance")
} }
var nodeInstances Instances var nodeInstances Instances
@ -418,7 +418,7 @@ func getAWSInstances(stat state.ConstellationState) (coordinators, nodes Scaling
} }
// TODO: make min / max configurable and abstract autoscaling for different cloud providers // TODO: make min / max configurable and abstract autoscaling for different cloud providers
// TODO: GroupID of nodes is empty, since they currently do not scale. // TODO: GroupID of workers is empty, since they currently do not scale.
nodes = ScalingGroup{Instances: nodeInstances, GroupID: ""} nodes = ScalingGroup{Instances: nodeInstances, GroupID: ""}
return return
@ -427,7 +427,7 @@ func getAWSInstances(stat state.ConstellationState) (coordinators, nodes Scaling
func getGCPInstances(stat state.ConstellationState, config *config.Config) (coordinators, nodes ScalingGroup, err error) { func getGCPInstances(stat state.ConstellationState, config *config.Config) (coordinators, nodes ScalingGroup, err error) {
coordinatorMap := stat.GCPCoordinators coordinatorMap := stat.GCPCoordinators
if len(coordinatorMap) == 0 { if len(coordinatorMap) == 0 {
return ScalingGroup{}, ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance") return ScalingGroup{}, ScalingGroup{}, errors.New("no control-plane nodes available, can't create Constellation without any instance")
} }
var coordinatorInstances Instances var coordinatorInstances Instances
for _, node := range coordinatorMap { for _, node := range coordinatorMap {
@ -441,7 +441,7 @@ func getGCPInstances(stat state.ConstellationState, config *config.Config) (coor
nodeMap := stat.GCPNodes nodeMap := stat.GCPNodes
if len(nodeMap) == 0 { if len(nodeMap) == 0 {
return ScalingGroup{}, ScalingGroup{}, errors.New("no nodes available, can't create Constellation with one instance") return ScalingGroup{}, ScalingGroup{}, errors.New("no worker nodes available, can't create Constellation with one instance")
} }
var nodeInstances Instances var nodeInstances Instances
@ -461,7 +461,7 @@ func getGCPInstances(stat state.ConstellationState, config *config.Config) (coor
func getAzureInstances(stat state.ConstellationState, config *config.Config) (coordinators, nodes ScalingGroup, err error) { func getAzureInstances(stat state.ConstellationState, config *config.Config) (coordinators, nodes ScalingGroup, err error) {
coordinatorMap := stat.AzureCoordinators coordinatorMap := stat.AzureCoordinators
if len(coordinatorMap) == 0 { if len(coordinatorMap) == 0 {
return ScalingGroup{}, ScalingGroup{}, errors.New("no coordinators available, can't create Constellation without any instance") return ScalingGroup{}, ScalingGroup{}, errors.New("no control-plane nodes available, can't create Constellation without any instance")
} }
var coordinatorInstances Instances var coordinatorInstances Instances
for _, node := range coordinatorMap { for _, node := range coordinatorMap {
@ -474,7 +474,7 @@ func getAzureInstances(stat state.ConstellationState, config *config.Config) (co
} }
nodeMap := stat.AzureNodes nodeMap := stat.AzureNodes
if len(nodeMap) == 0 { if len(nodeMap) == 0 {
return ScalingGroup{}, ScalingGroup{}, errors.New("no nodes available, can't create Constellation with one instance") return ScalingGroup{}, ScalingGroup{}, errors.New("no worker nodes available, can't create Constellation cluster with one instance")
} }
var nodeInstances Instances var nodeInstances Instances

View File

@ -186,7 +186,7 @@ func (c *fakeActivationRespClient) GetKubeconfig() (string, error) {
func (c *fakeActivationRespClient) GetCoordinatorVpnKey() (string, error) { func (c *fakeActivationRespClient) GetCoordinatorVpnKey() (string, error) {
if c.coordinatorVpnKey == "" { if c.coordinatorVpnKey == "" {
return "", errors.New("coordinator public VPN key is empty") return "", errors.New("control-plane public VPN key is empty")
} }
return c.coordinatorVpnKey, nil return c.coordinatorVpnKey, nil
} }

View File

@ -42,7 +42,7 @@ func (a *API) ActivateAsCoordinator(in *pubproto.ActivateAsCoordinatorRequest, s
}) })
}) })
logToCLI("Initializing first Coordinator ...") logToCLI("Initializing first control-plane node ...")
// If any of the following actions fail, we cannot revert // If any of the following actions fail, we cannot revert
// Thus, mark this peer as failed. // Thus, mark this peer as failed.
@ -226,7 +226,7 @@ func (a *API) activateNodes(logToCLI logFunc, nodePublicIPs []string) error {
// Activate all nodes. // Activate all nodes.
for num, nodePublicIP := range nodePublicIPs { for num, nodePublicIP := range nodePublicIPs {
logToCLI("activating node %3d out of %3d nodes ...", num+1, len(nodePublicIPs)) logToCLI("Activating worker node %3d out of %3d ...", num+1, len(nodePublicIPs))
nodeVPNIP, err := a.core.GetNextNodeIP() nodeVPNIP, err := a.core.GetNextNodeIP()
if err != nil { if err != nil {
a.logger.Error("generation of vpn ips failed", zap.Error(err)) a.logger.Error("generation of vpn ips failed", zap.Error(err))

View File

@ -156,7 +156,7 @@ func (a *API) ActivateAdditionalCoordinator(ctx context.Context, in *pubproto.Ac
func (a *API) activateCoordinators(logToCLI logFunc, coordinatorPublicIPs []string) error { func (a *API) activateCoordinators(logToCLI logFunc, coordinatorPublicIPs []string) error {
// Activate all coordinators. // Activate all coordinators.
for num, coordinatorPublicIP := range coordinatorPublicIPs { for num, coordinatorPublicIP := range coordinatorPublicIPs {
logToCLI("activating coordinator %3d out of %3d coordinators ...", num+2, len(coordinatorPublicIPs)+1) logToCLI("Activating control-plane node %3d out of %3d ...", num+2, len(coordinatorPublicIPs)+1)
if err := a.activateCoordinator(context.TODO(), coordinatorPublicIP); err != nil { if err := a.activateCoordinator(context.TODO(), coordinatorPublicIP); err != nil {
return err return err
} }