New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lcow: fix debug in startServiceVMIfNotRunning() #37446
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,21 +219,21 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
// Use the global ID if in global mode | ||
id = d.getVMID(id) | ||
|
||
title := fmt.Sprintf("lcowdriver: startservicevmifnotrunning %s:", id) | ||
title := "lcowdriver: startServiceVMIfNotRunning " + id | ||
|
||
// Attempt to add ID to the service vm map | ||
logrus.Debugf("%s: Adding entry to service vm map", title) | ||
logrus.Debugf("%s: adding entry to service vm map", title) | ||
svm, exists, err := d.serviceVms.add(id) | ||
if err != nil && err == errVMisTerminating { | ||
// VM is in the process of terminating. Wait until it's done and and then try again | ||
logrus.Debugf("%s: VM with current ID still in the process of terminating: %s", title, id) | ||
logrus.Debugf("%s: VM with current ID still in the process of terminating", title) | ||
if err := svm.getStopError(); err != nil { | ||
logrus.Debugf("%s: VM %s did not stop successfully: %s", title, id, err) | ||
logrus.Debugf("%s: VM did not stop successfully: %s", title, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
return nil, err | ||
} | ||
return d.startServiceVMIfNotRunning(id, mvdToAdd, context) | ||
} else if err != nil { | ||
logrus.Debugf("%s: failed to add service vm to map: %s", err) | ||
logrus.Debugf("%s: failed to add service vm to map: %s", title, err) | ||
return nil, fmt.Errorf("%s: failed to add to service vm map: %s", title, err) | ||
} | ||
|
||
|
@@ -248,7 +248,7 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
} | ||
|
||
// We are the first service for this id, so we need to start it | ||
logrus.Debugf("%s: service vm doesn't exist. Now starting it up: %s", title, id) | ||
logrus.Debugf("%s: service vm doesn't exist. Now starting it up", title) | ||
|
||
defer func() { | ||
// Signal that start has finished, passing in the error if any. | ||
|
@@ -261,7 +261,7 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
|
||
// Generate a default configuration | ||
if err := svm.config.GenerateDefault(d.options); err != nil { | ||
return nil, fmt.Errorf("%s failed to generate default gogcs configuration for global svm (%s): %s", title, context, err) | ||
return nil, fmt.Errorf("%s: failed to generate default gogcs configuration for global svm (%s): %s", title, context, err) | ||
} | ||
|
||
// For the name, we deliberately suffix if safe-mode to ensure that it doesn't | ||
|
@@ -277,19 +277,19 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
// and not in the process of being created by another thread. | ||
scratchTargetFile := filepath.Join(d.dataRoot, scratchDirectory, fmt.Sprintf("%s.vhdx", id)) | ||
|
||
logrus.Debugf("%s locking cachedScratchMutex", title) | ||
logrus.Debugf("%s: locking cachedScratchMutex", title) | ||
d.cachedScratchMutex.Lock() | ||
if _, err := os.Stat(d.cachedScratchFile); err == nil { | ||
// Make a copy of cached scratch to the scratch directory | ||
logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) cloning cached scratch for mvd", context) | ||
logrus.Debugf("%s: (%s) cloning cached scratch for mvd", title, context) | ||
if err := client.CopyFile(d.cachedScratchFile, scratchTargetFile, true); err != nil { | ||
logrus.Debugf("%s releasing cachedScratchMutex on err: %s", title, err) | ||
logrus.Debugf("%s: releasing cachedScratchMutex on err: %s", title, err) | ||
d.cachedScratchMutex.Unlock() | ||
return nil, err | ||
} | ||
|
||
// Add the cached clone as a mapped virtual disk | ||
logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) adding cloned scratch as mvd", context) | ||
logrus.Debugf("%s: (%s) adding cloned scratch as mvd", title, context) | ||
mvd := hcsshim.MappedVirtualDisk{ | ||
HostPath: scratchTargetFile, | ||
ContainerPath: toolsScratchPath, | ||
|
@@ -299,7 +299,7 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
svm.scratchAttached = true | ||
} | ||
|
||
logrus.Debugf("%s releasing cachedScratchMutex", title) | ||
logrus.Debugf("%s: releasing cachedScratchMutex", title) | ||
d.cachedScratchMutex.Unlock() | ||
|
||
// If requested to start it with a mapped virtual disk, add it now. | ||
|
@@ -309,39 +309,39 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
} | ||
|
||
// Start it. | ||
logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) starting %s", context, svm.config.Name) | ||
logrus.Debugf("%s: (%s) starting %s", title, context, svm.config.Name) | ||
if err := svm.config.StartUtilityVM(); err != nil { | ||
return nil, fmt.Errorf("failed to start service utility VM (%s): %s", context, err) | ||
} | ||
|
||
// defer function to terminate the VM if the next steps fail | ||
defer func() { | ||
if err != nil { | ||
waitTerminate(svm, fmt.Sprintf("startServiceVmIfNotRunning: %s (%s)", id, context)) | ||
waitTerminate(svm, fmt.Sprintf("%s: (%s)", title, context)) | ||
} | ||
}() | ||
|
||
// Now we have a running service VM, we can create the cached scratch file if it doesn't exist. | ||
logrus.Debugf("%s locking cachedScratchMutex", title) | ||
logrus.Debugf("%s: locking cachedScratchMutex", title) | ||
d.cachedScratchMutex.Lock() | ||
if _, err := os.Stat(d.cachedScratchFile); err != nil { | ||
logrus.Debugf("%s (%s): creating an SVM scratch", title, context) | ||
logrus.Debugf("%s: (%s) creating an SVM scratch", title, context) | ||
|
||
// Don't use svm.CreateExt4Vhdx since that only works when the service vm is setup, | ||
// but we're still in that process right now. | ||
if err := svm.config.CreateExt4Vhdx(scratchTargetFile, client.DefaultVhdxSizeGB, d.cachedScratchFile); err != nil { | ||
logrus.Debugf("%s (%s): releasing cachedScratchMutex on error path", title, context) | ||
logrus.Debugf("%s: (%s) releasing cachedScratchMutex on error path", title, context) | ||
d.cachedScratchMutex.Unlock() | ||
logrus.Debugf("%s: failed to create vm scratch %s: %s", title, scratchTargetFile, err) | ||
return nil, fmt.Errorf("failed to create SVM scratch VHDX (%s): %s", context, err) | ||
} | ||
} | ||
logrus.Debugf("%s (%s): releasing cachedScratchMutex", title, context) | ||
logrus.Debugf("%s: (%s) releasing cachedScratchMutex", title, context) | ||
d.cachedScratchMutex.Unlock() | ||
|
||
// Hot-add the scratch-space if not already attached | ||
if !svm.scratchAttached { | ||
logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) hot-adding scratch %s", context, scratchTargetFile) | ||
logrus.Debugf("%s: (%s) hot-adding scratch %s", title, context, scratchTargetFile) | ||
if err := svm.hotAddVHDsAtStart(hcsshim.MappedVirtualDisk{ | ||
HostPath: scratchTargetFile, | ||
ContainerPath: toolsScratchPath, | ||
|
@@ -353,7 +353,7 @@ func (d *Driver) startServiceVMIfNotRunning(id string, mvdToAdd []hcsshim.Mapped | |
svm.scratchAttached = true | ||
} | ||
|
||
logrus.Debugf("lcowdriver: startServiceVmIfNotRunning: (%s) success", context) | ||
logrus.Debugf("%s: (%s) success", title, context) | ||
return svm, nil | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps for a follow up, but we should
logrus.WithFields
for this information (similar to what we do for other storage drivers)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concur (see the patch description).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...but I'd rather do it in a separate PR later as this fix is quite big already -- and initially it supposed to be a one-liner 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh!! Didn't read that far into your description 🤦♂️☺️ 😝