Skip to content

Commit

Permalink
Merge pull request #384 from ligato/dev
Browse files Browse the repository at this point in the history
Release 2.0
  • Loading branch information
rastislavs authored Apr 2, 2019
2 parents 958d934 + e90bd2e commit 7728b02
Show file tree
Hide file tree
Showing 105 changed files with 18,130 additions and 918 deletions.
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
# Release v2.0 (2019-04-02)

## Breaking Changes
* The `ChangeEvent` interface was modified. Before, it returned single value of type `ProtoWatchResp`, now it contains a new method `GetChanges()` which return a list of values of that type.

## New Features
* [Datasync](datasync/README.md)
- The `ChangeEvent` interface provides a new method `GetContext` returning a context associated with the given event.
- The `ResyncEvent` interface also provides a new method called `GetContext` returning a context associated with the given resync event.
- Resync time duration is shown in milliseconds
* [IdxMap](idxmap/README.md)
- New method `ListFields(string)` in the `NamedMapping` interface providing a map of fields associated with the item identified by the named parameter known as secondary indexes
* [GRPC](rpc/grpc)
- Added authentication support for the GRPC plugin
* [Probe](health/probe)
- Support for non-fatal errors. The probe plugin keeps a lst of non-fatal plugins. Errors reported from the non-fatal plugin are effectively ignored in the vpp-agent overall status.
* [BoltDB](db/keyval/bolt)
- The config file now has an option to filter duplicated notifications.

## Improvements
* [Agent](agent)
- `DumpStackTraceOnTimeout` is now disabled by default with possibility to enable it via the environment variable `DUMP_STACK_ON_TIMEOUT`.
- The agent logs the last plugin in case it fails to start because of the timeout
- Signal received during startup closes the agent instance
* [FileDB](db/keyval/filedb)
- If the child process is not detached, the `PDeathSignal` is set preventing the child process to hang
- The process watcher is started on process start, rather than on process creation
- A new or an attached process can be created with custom I/O writer
- Support for environment variables for processes
* [Resync](datasync/resync)
- The resync timeout was split into two values, for ACK timeout set to 10 second (up from 5) and for ACCEPT timeout set to 1 second.

## Fixed Bugs
* The ETCD plugin watch is now properly closed using a context
* The plugin lookup works correctly with interface types where the inner type is slice or array of plugins
* `PropagateResync` now waits at the result of the resync event instead of returning immediately
* Used `jsonpb` to fix protobuf marshalling/unmarshalling
* Plugin config directory paths with ".." are now handled properly.
* If channel used by process manager is closed by the used (which should not be done), the plugin recovers

## Documentation
* Added "beginner" tutorials (hello world, plugin dependencies, REST handler, KV Store, plugin lookup) with examples.

# Release v1.7 (2018-12-12)

## Major Topics
Expand Down
27 changes: 20 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/signal"
"runtime"
"strings"
"sync"
"time"

"github.com/ligato/cn-infra/config"
Expand Down Expand Up @@ -99,6 +100,9 @@ type agent struct {
stopOnce once.ReturnError

tracer measure.Tracer

mu sync.Mutex
curPlugin infra.Plugin
}

// Options returns the Options the agent was created with
Expand Down Expand Up @@ -144,10 +148,16 @@ func (a *agent) starter() error {
if timeout := a.opts.StartTimeout; timeout > 0 {
go func() {
select {
case s := <-sig:
agentLogger.Infof("Signal %v received during agent start, stopping", s)
os.Exit(1)
case <-started:
// agent started
case <-time.After(timeout):
agentLogger.Errorf("Agent failed to start before timeout (%v)", timeout)
a.mu.Lock()
curPlugin := a.curPlugin
a.mu.Unlock()
agentLogger.Errorf("Agent failed to start before timeout (%v) last plugin: %s", timeout, curPlugin)
dumpStacktrace()
os.Exit(1)
}
Expand Down Expand Up @@ -196,12 +206,16 @@ func (a *agent) starter() error {
}

func (a *agent) start() error {
agentLogger.Infof("Starting agent with %d plugins", len(a.opts.Plugins))
agentLogger.Debugf("starting %d plugins", len(a.opts.Plugins))

// Init plugins
for _, plugin := range a.opts.Plugins {
t := time.Now()

a.mu.Lock()
a.curPlugin = plugin
a.mu.Unlock()

agentLogger.Debugf("-> Init(): %v", plugin)
if err := plugin.Init(); err != nil {
return err
Expand All @@ -214,6 +228,10 @@ func (a *agent) start() error {
for _, plugin := range a.opts.Plugins {
t := time.Now()

a.mu.Lock()
a.curPlugin = plugin
a.mu.Unlock()

if postPlugin, ok := plugin.(infra.PostInit); ok {
agentLogger.Debugf("-> AfterInit(): %v", plugin)
if err := postPlugin.AfterInit(); err != nil {
Expand All @@ -226,6 +244,10 @@ func (a *agent) start() error {
a.tracer.LogTime(fmt.Sprintf("%v.AfterInit", plugin), t)
}

a.mu.Lock()
a.curPlugin = nil
a.mu.Unlock()

if printPluginStartDurations && infraLogger.GetLevel() >= logging.DebugLevel {
var b strings.Builder
b.WriteString("plugin start durations:\n")
Expand Down
2 changes: 1 addition & 1 deletion agent/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
DefaultStopTimeout = time.Second * 5

// DumpStackTraceOnTimeout prints stack trace on timeout or agent start/stop
DumpStackTraceOnTimeout = true
DumpStackTraceOnTimeout = os.Getenv("DUMP_STACK_ON_TIMEOUT") != ""
)

// Options specifies option list for the Agent
Expand Down
5 changes: 1 addition & 4 deletions config/plugin_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ func Dir() (dir string, err error) {
if err != nil {
return cwd, err
}
if len(val) > 1 {
return filepath.Join(cwd, val[1:]), nil
}
return cwd, nil
return filepath.Join(cwd, val), nil
}
return val, nil
}
Expand Down
9 changes: 7 additions & 2 deletions datasync/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package datasync

import (
"github.com/gogo/protobuf/proto"
"github.com/ligato/cn-infra/logging"
"github.com/ligato/cn-infra/utils/safeclose"
)

Expand Down Expand Up @@ -76,7 +77,9 @@ func (ta KVProtoWriters) Put(key string, data proto.Message, opts ...PutOption)
// to add the key from that registration only
func (wa *AggregatedRegistration) Register(resyncName, keyPrefix string) error {
for _, registration := range wa.Registrations {
registration.Register(resyncName, keyPrefix)
if err := registration.Register(resyncName, keyPrefix); err != nil {
logging.DefaultLogger.Warnf("aggregated register failed: %v", err)
}
}

return nil
Expand All @@ -86,7 +89,9 @@ func (wa *AggregatedRegistration) Register(resyncName, keyPrefix string) error {
// Call Unregister(keyPrefix) on specific registration to remove the key from that registration only
func (wa *AggregatedRegistration) Unregister(keyPrefix string) error {
for _, registration := range wa.Registrations {
registration.Unregister(keyPrefix)
if err := registration.Unregister(keyPrefix); err != nil {
logging.DefaultLogger.Warnf("aggregated unregister failed: %v", err)
}
}

return nil
Expand Down
Loading

0 comments on commit 7728b02

Please sign in to comment.