Skip to content

Commit

Permalink
logging for creating instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ryota-sakamoto committed Jun 16, 2024
1 parent 832f845 commit 89e8631
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/provisioner/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ type Config struct {
}

func CreateMaster(clusterName string, config Config) error {
slog.Debug("create master", slog.String("clusterName", clusterName), slog.Any("config", config))

instanceName := fmt.Sprintf("%s-%s", clusterName, "master")
instance, err := multipass.GetInstance(instanceName)
if err != nil {
return fmt.Errorf("failed to get instance: %w", err)
}

slog.Debug("get instance", slog.String("instanceName", instanceName), slog.Any("instance", instance))
if instance != nil {
return nil
}
Expand All @@ -51,16 +55,21 @@ func CreateMaster(clusterName string, config Config) error {
}

func CreateWorker(clusterName string, config Config) error {
slog.Debug("create worker", slog.String("clusterName", clusterName), slog.Any("config", config))

name := config.Name
if name == "" {
name = GetRandomName()
}

instanceName := fmt.Sprintf("%s-%s", clusterName, name)

instance, err := multipass.GetInstance(instanceName)
if err != nil {
return fmt.Errorf("failed to get instance: %w", err)
}

slog.Debug("get instance", slog.String("instanceName", instanceName), slog.Any("instance", instance))
if instance != nil {
return nil
}
Expand Down

0 comments on commit 89e8631

Please sign in to comment.