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