Remove journal for now

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-12-07 14:24:40 -08:00
parent c1d1c67444
commit acc8d9e97c
2 changed files with 1 additions and 70 deletions

View File

@ -1,61 +0,0 @@
package containerd
import (
"encoding/json"
"os"
"path/filepath"
"sync"
"github.com/Sirupsen/logrus"
)
type entry struct {
Event *Event `json:"event"`
}
func newJournal(path string) (*journal, error) {
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
return nil, err
}
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0755)
if err != nil {
return nil, err
}
j := &journal{
f: f,
enc: json.NewEncoder(f),
wc: make(chan *Event, 2048),
}
j.wg.Add(1)
go j.start()
return j, nil
}
type journal struct {
f *os.File
enc *json.Encoder
wc chan *Event
wg sync.WaitGroup
}
func (j *journal) start() {
defer j.wg.Done()
for e := range j.wc {
et := &entry{
Event: e,
}
if err := j.enc.Encode(et); err != nil {
logrus.WithField("error", err).Error("write event to journal")
}
}
}
func (j *journal) write(e *Event) {
j.wc <- e
}
func (j *journal) Close() error {
close(j.wc)
j.wg.Wait()
return j.f.Close()
}

View File

@ -3,7 +3,6 @@ package containerd
import (
"os"
"os/signal"
"path/filepath"
goruntime "runtime"
"sync"
"syscall"
@ -23,10 +22,6 @@ func NewSupervisor(stateDir string, tasks chan *StartTask) (*Supervisor, error)
if err != nil {
return nil, err
}
j, err := newJournal(filepath.Join(stateDir, "journal.json"))
if err != nil {
return nil, err
}
machine, err := CollectMachineInformation()
if err != nil {
return nil, err
@ -36,7 +31,6 @@ func NewSupervisor(stateDir string, tasks chan *StartTask) (*Supervisor, error)
containers: make(map[string]runtime.Container),
processes: make(map[int]runtime.Container),
runtime: r,
journal: j,
tasks: tasks,
events: make(chan *Event, 2048),
machine: machine,
@ -65,7 +59,6 @@ type Supervisor struct {
processes map[int]runtime.Container
handlers map[EventType]Handler
runtime runtime.Runtime
journal *journal
events chan *Event
tasks chan *StartTask
subscribers map[subscriber]bool
@ -112,7 +105,7 @@ func (s *Supervisor) Stop(sig chan os.Signal) {
// Close closes any open files in the supervisor but expects that Stop has been
// callsed so that no more containers are started.
func (s *Supervisor) Close() error {
return s.journal.Close()
return nil
}
func (s *Supervisor) Events() subscriber {
@ -140,7 +133,6 @@ func (s *Supervisor) Start() error {
goruntime.LockOSThread()
for e := range s.events {
EventsCounter.Inc(1)
s.journal.write(e)
h, ok := s.handlers[e.Type]
if !ok {
e.Err <- ErrUnknownEvent