Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit deb58e9

Browse files
author
Mark Ryan
committed
Add debug connection information
With the addition of multiple instance support it became difficult to debug buggy cloud-init files. The reason is that if cloud-init fails to complete, the creation command will also not complete. As ccloudvm serialises the commands it sends to a given instance, no other commands, e.g., connect, can be issued on that instance until create has completed, making it difficult to connect to instances with buggy cloud-init files to debug them. This commit works around the issue by providing the user with ssh connection details for the instance being created if they pass the --debug option to create. Connect's still not going to work but at least the user will have a way to connect to their VM to debug it. Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
1 parent 7f4b2b9 commit deb58e9

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

ccvm/ccvm.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,34 @@ func createImages(ctx context.Context, wkld *workload, ws *workspace, args *type
186186
return nil
187187
}
188188

189+
func outputBootingMessage(args *types.CreateArgs, wkld *workload, ws *workspace,
190+
resultCh chan interface{}) {
191+
spec := &wkld.spec.VM
192+
193+
resultCh <- types.CreateResult{
194+
Line: fmt.Sprintf("Booting VM with %d MiB RAM and %d cpus\n", spec.MemMiB, spec.CPUs),
195+
}
196+
197+
if !args.Debug {
198+
return
199+
}
200+
201+
sshPort, err := spec.SSHPort()
202+
if err != nil {
203+
return
204+
}
205+
206+
resultCh <- types.CreateResult{
207+
Line: "To connect to the instance during its creation type\n\n",
208+
}
209+
210+
fstr := "\tssh -q -F /dev/null -o UserKnownHostsFile=/dev/null " +
211+
"-o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i %s %s -p %d\n"
212+
resultCh <- types.CreateResult{
213+
Line: fmt.Sprintf(fstr, ws.keyPath, spec.HostIP, sshPort),
214+
}
215+
}
216+
189217
func (c ccvmBackend) createInstance(ctx context.Context, resultCh chan interface{},
190218
downloadCh chan<- downloadRequest, args *types.CreateArgs) error {
191219
var err error
@@ -243,12 +271,9 @@ func (c ccvmBackend) createInstance(ctx context.Context, resultCh chan interface
243271
return err
244272
}
245273

246-
spec := wkld.spec.VM
247-
resultCh <- types.CreateResult{
248-
Line: fmt.Sprintf("Booting VM with %d MiB RAM and %d cpus\n", spec.MemMiB, spec.CPUs),
249-
}
274+
outputBootingMessage(args, wkld, ws, resultCh)
250275

251-
err = bootVM(ctx, ws, args.Name, &spec)
276+
err = bootVM(ctx, ws, args.Name, &wkld.spec.VM)
252277
if err != nil {
253278
return err
254279
}

0 commit comments

Comments
 (0)