Skip to content

Commit

Permalink
fix: replace log.Default.Debug with log.Default.Info
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Jan 4, 2025
1 parent 4c425ac commit e7ba455
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pkg/hetzner/hetzner.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (h *Hetzner) BuildServerOptions(ctx context.Context, opts *options.Options)
}

func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, diskSize int, publicKey string, privateKeyFile []byte) error {
log.Default.Debug("Creating DevPod instance")
log.Default.Info("Creating DevPod instance")

volume, err := h.volumeByName(ctx, req.Name)
if err != nil {
Expand All @@ -133,7 +133,7 @@ func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, disk

if volume == nil {
// Create the volume as it doesn't exist
log.Default.Debug("Creating a new volume")
log.Default.Info("Creating a new volume")

v, _, err := h.client.Volume.Create(ctx, hcloud.VolumeCreateOpts{
Location: req.Location,
Expand All @@ -149,7 +149,7 @@ func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, disk
return err
}

log.Default.Debug("Volume successfully created")
log.Default.Info("Volume successfully created")

volume = v.Volume
}
Expand All @@ -170,23 +170,23 @@ func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, disk
}

// Create the server
log.Default.Debug("Creating a new server")
log.Default.Info("Creating a new server")
server, _, err := h.client.Server.Create(ctx, *req)
if err != nil {
return err
}

log.Default.Debug("Server created - waiting until provisioned")
log.Default.Info("Server created - waiting until provisioned")

for {
time.Sleep(time.Second)

log.Default.Debug("Checking server provision status")
log.Default.Info("Checking server provision status")

// Check the server is provisioned - this runs "ssh user@path cloud-init status"
sshClient, err := ssh.NewSSHClient("devpod", fmt.Sprintf("%s:22", server.Server.PublicNet.IPv4.IP), privateKeyFile)
if err != nil {
log.Default.Debug("Unable to connect to server")
log.Default.Info("Unable to connect to server")
continue
}
defer func() {
Expand All @@ -195,13 +195,13 @@ func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, disk

buf := new(bytes.Buffer)
if err := ssh.Run(ctx, sshClient, "cloud-init status", &bytes.Buffer{}, buf, &bytes.Buffer{}); err != nil {
log.Default.Debug("Error retrieving cloud-init status")
log.Default.Info("Error retrieving cloud-init status")
continue
}

var status cloudInit
if err := yaml.Unmarshal(buf.Bytes(), &status); err != nil {
log.Default.Debug("Unable to parse cloud-init YAML")
log.Default.Errorf("Unable to parse cloud-init YAML: %v", err)
continue
}

Expand All @@ -210,10 +210,10 @@ func (h *Hetzner) Create(ctx context.Context, req *hcloud.ServerCreateOpts, disk
break
}

log.Default.Debug("Server not yet provisioned")
log.Default.Info("Server not yet provisioned")
}

log.Default.Debug("Server provisioned")
log.Default.Info("Server provisioned")

return nil
}
Expand Down

0 comments on commit e7ba455

Please sign in to comment.