Skip to content
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

Minor fixes to shim panic log & create task functions #1007

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions cmd/containerd-shim-runhcs-v1/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ The delete command will be executed in the container's bundle as its cwd.
return errors.New("bundle is required")
}

// hcsshim shim writes panic logs in the bundle directory in a file named "panic.log"
// log those messages (if any) on stderr so that it shows up in containerd's log.
// This should be done as the first thing so that we don't miss any panic logs even if
// something goes wrong during delete op.
logs, err := ioutil.ReadFile(filepath.Join(bundleFlag, "panic.log"))
if err == nil && len(logs) > 0 {
logrus.WithField("log", string(logs)).Error("found shim panic logs during delete")
}

// Attempt to find the hcssystem for this bundle and terminate it.
if sys, _ := hcs.OpenComputeSystem(ctx, idFlag); sys != nil {
defer sys.Close()
Expand Down Expand Up @@ -82,13 +91,6 @@ The delete command will be executed in the container's bundle as its cwd.
}
}

// hcsshim shim writes panic logs in the bundle directory in a file named "panic.log"
// log those messages (if any) on stderr so that it shows up in containerd's log.
logs, err := ioutil.ReadFile(filepath.Join(bundleFlag, "panic.log"))
if err == nil && len(logs) > 0 {
logrus.WithField("log", string(logs)).Error("found shim panic logs during delete")
}

// Remove the bundle on disk
if err := os.RemoveAll(bundleFlag); err != nil && !os.IsNotExist(err) {
return err
Expand Down
15 changes: 2 additions & 13 deletions cmd/containerd-shim-runhcs-v1/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ type pod struct {
// It MUST be treated as read only in the lifetime of the pod.
host *uvm.UtilityVM

// wcl is the workload create mutex. All calls to CreateTask must hold this
// lock while the ID reservation takes place. Once the ID is held it is safe
// to release the lock to allow concurrent creates.
wcl sync.Mutex
workloadTasks sync.Map
}

Expand All @@ -262,17 +258,10 @@ func (p *pod) CreateTask(ctx context.Context, req *task.CreateTaskRequest, s *sp
return nil, errors.Wrapf(errdefs.ErrFailedPrecondition, "task with id: '%s' cannot be created in pod: '%s' which is not running", req.ID, p.id)
}

p.wcl.Lock()
_, loaded := p.workloadTasks.LoadOrStore(req.ID, nil)
if loaded {
_, ok := p.workloadTasks.Load(req.ID)
if ok {
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "task with id: '%s' already exists id pod: '%s'", req.ID, p.id)
}
p.wcl.Unlock()
defer func() {
if err != nil {
p.workloadTasks.Delete(req.ID)
}
katiewasnothere marked this conversation as resolved.
Show resolved Hide resolved
}()

ct, sid, err := oci.GetSandboxTypeAndID(s.Annotations)
if err != nil {
Expand Down