Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Lenco committed Jul 29, 2019
2 parents 48b277b + 75214a0 commit 0d44e82
Show file tree
Hide file tree
Showing 61 changed files with 2,901 additions and 804 deletions.
5 changes: 2 additions & 3 deletions Gopkg.lock

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

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ clean-examples:
cd examples/localclient_vpp/nat && go clean
cd examples/localclient_vpp/plugins && go clean

debug-remote:
cd ./cmd/vpp-agent && dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient

# -------------------------------
# Testing
# -------------------------------
Expand Down
26 changes: 15 additions & 11 deletions plugins/govppmux/adapter_puregoclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,33 @@
package govppmux

import (
"fmt"
"os"

"git.fd.io/govpp.git/adapter"
"git.fd.io/govpp.git/adapter/socketclient"
"git.fd.io/govpp.git/adapter/statsclient"
"github.com/ligato/cn-infra/logging"
)

const noShmWarning = `Using shared memory for VPP binary API is not currently supported in pure Go client!
To use socket client for VPP binary API (recommended):
- unset GOVPPMUX_NOSOCK environment variable
- remove these settings from govpp.conf config: shm-prefix, connect-via-shm
If you still want to use shared memory for VPP binary API:
- compile your agent with this build tag: vppapiclient
- vppapiclient requires CGo and needs VPP to be installed
`

// NewVppAdapter returns VPP binary API adapter, implemented as pure Go client.
func NewVppAdapter(addr string, useShm bool) adapter.VppAPI {
if useShm {
logging.Warnf(`Using shared memory for VPP binary API is not currently supported in pure Go client!
To use socket client for VPP binary API:
- unset GOVPPMUX_NOSOCK environment variable
- remove these settings from govpp.conf config: shm-prefix, connect-via-shm
If you still want to use shared memory for VPP binary API (not recommended):
- compile your agent with this build tag: vppapiclient
`)
fmt.Fprintf(os.Stderr, noShmWarning)
panic("No implementation for shared memory in pure Go client!")
}
// addr is used as socket path
return socketclient.NewVppClient(addr)

}

// NewStatsAdapter returns VPP stats API adapter, implemented as pure Go client.
Expand Down
2 changes: 1 addition & 1 deletion plugins/govppmux/vppcalls/vpp1901/vpe_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
msgs = append(msgs, vpe.AllMessages()...)
msgs = append(msgs, memclnt.AllMessages()...)

vppcalls.Versions["vpp1901"] = vppcalls.HandlerVersion{
vppcalls.Versions["19.01"] = vppcalls.HandlerVersion{
Msgs: msgs,
New: func(ch govppapi.Channel) vppcalls.VpeVppAPI {
return NewVpeHandler(ch)
Expand Down
2 changes: 1 addition & 1 deletion plugins/govppmux/vppcalls/vpp1904/vpe_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
msgs = append(msgs, vpe.AllMessages()...)
msgs = append(msgs, memclnt.AllMessages()...)

vppcalls.Versions["vpp1904"] = vppcalls.HandlerVersion{
vppcalls.Versions["19.04"] = vppcalls.HandlerVersion{
Msgs: msgs,
New: func(ch govppapi.Channel) vppcalls.VpeVppAPI {
return NewVpeHandler(ch)
Expand Down
2 changes: 1 addition & 1 deletion plugins/govppmux/vppcalls/vpp1908/vpe_vppcalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {
msgs = append(msgs, vpe.AllMessages()...)
msgs = append(msgs, memclnt.AllMessages()...)

vppcalls.Versions["vpp1908"] = vppcalls.HandlerVersion{
vppcalls.Versions["19.08"] = vppcalls.HandlerVersion{
Msgs: msgs,
New: func(ch govppapi.Channel) vppcalls.VpeVppAPI {
return NewVpeHandler(ch)
Expand Down
8 changes: 8 additions & 0 deletions plugins/govppmux/vppcalls/vppcalls_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ type VersionInfo struct {
BuildDirectory string
}

// Release returns version in shortened format YY.MM that describes release.
func (v VersionInfo) Release() string {
if len(v.Version) < 5 {
return ""
}
return v.Version[:5]
}

// VpeInfo contains information about VPP connection and process.
type VpeInfo struct {
PID uint32
Expand Down
2 changes: 1 addition & 1 deletion plugins/kvscheduler/api/txn_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@ func WithSimulation(ctx context.Context) context.Context {
func IsWithSimulation(ctx context.Context) bool {
_, withSimulation := ctx.Value(txnSimulationCtxKey).(*txnSimulationOpt)
return withSimulation
}
}
6 changes: 3 additions & 3 deletions plugins/kvscheduler/api/txn_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func (t TxnType) String() string {
case NBTransaction:
return "NB Transaction"
case RetryFailedOps:
return "RETRY"
return "Retry Transaction"
}
return "UNKNOWN"
return "UndefinedTxnType"
}

// RecordedTxn is used to record executed transaction.
Expand Down Expand Up @@ -128,7 +128,7 @@ func (txn *RecordedTxn) StringWithOpts(resultOnly, verbose bool, indent int) str
if !resultOnly {
// transaction arguments
str += indent1 + "* transaction arguments:\n"
str += indent2 + fmt.Sprintf("- seq-num: %d\n", txn.SeqNum)
str += indent2 + fmt.Sprintf("- seqNum: %d\n", txn.SeqNum)
if txn.TxnType == NBTransaction && txn.ResyncType != NotResync {
ResyncType := "Full Resync"
if txn.ResyncType == DownstreamResync {
Expand Down
2 changes: 1 addition & 1 deletion plugins/kvscheduler/plugin_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (s *Scheduler) TransactionBarrier() {

// PushSBNotification notifies about a spontaneous value change(s) in the SB
// plane (i.e. not triggered by NB transaction).
func (s *Scheduler) PushSBNotification(notif... kvs.KVWithMetadata) error {
func (s *Scheduler) PushSBNotification(notif ...kvs.KVWithMetadata) error {
txn := &transaction{
txnType: kvs.SBNotification,
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/kvscheduler/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,4 +571,4 @@ func (s *Scheduler) validRetrievedDerivedKV(node graph.Node, descriptor *kvs.KVD
// return true -> let's overwrite invalidly retrieved derived value
}
return true
}
}
8 changes: 4 additions & 4 deletions plugins/kvscheduler/txn_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (s *Scheduler) preProcessNBTransaction(txn *transaction) (skip bool) {
}

// for resync refresh the graph + collect deletes
graphW := s.graph.Write(true,false)
graphW := s.graph.Write(true, false)
defer graphW.Release()
s.resyncCount++

Expand Down Expand Up @@ -344,7 +344,7 @@ func (s *Scheduler) postProcessTransaction(txn *transaction, executed kvs.Record
if toRefresh.Length() > 0 {
// changes brought by refresh triggered solely for the verification are
// not saved into the graph
graphW := s.graph.Write(afterErrRefresh,false)
graphW := s.graph.Write(afterErrRefresh, false)
s.refreshGraph(graphW, toRefresh, nil, afterErrRefresh)
s.scheduleRetries(txn, graphW, toRetry)

Expand Down Expand Up @@ -420,7 +420,7 @@ func (s *Scheduler) postProcessTransaction(txn *transaction, executed kvs.Record

// delete removed values from the graph after the notifications have been sent
if removed.Length() > 0 {
graphW := s.graph.Write(true,true)
graphW := s.graph.Write(true, true)
for _, key := range removed.Iterate() {
graphW.DeleteNode(key)
}
Expand All @@ -429,7 +429,7 @@ func (s *Scheduler) postProcessTransaction(txn *transaction, executed kvs.Record
}

// scheduleRetries schedules a series of re-try transactions for failed values
func (s *Scheduler) scheduleRetries(txn *transaction, graphR graph.ReadAccess, toRetry utils.KeySet,) {
func (s *Scheduler) scheduleRetries(txn *transaction, graphR graph.ReadAccess, toRetry utils.KeySet) {
// split values based on the retry metadata
retryTxns := make(map[retryTxnMeta]*retryTxn)
for _, retryKey := range toRetry.Iterate() {
Expand Down
24 changes: 11 additions & 13 deletions plugins/kvscheduler/txn_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,16 @@ func (s *Scheduler) preRecordTransaction(txn *transaction, planned kvs.RecordedT
// if enabled, print txn summary
if s.config.PrintTxnSummary {
// build header for the log
txnInfo := txn.txnType.String()
txnInfo := ""
if txn.txnType == kvs.NBTransaction && txn.nb.resyncType != kvs.NotResync {
resyncType := "Full Resync"
if txn.nb.resyncType == kvs.DownstreamResync {
resyncType = "SB Sync"
}
if txn.nb.resyncType == kvs.UpstreamResync {
resyncType = "NB Sync"
}
txnInfo = fmt.Sprintf("%s (%s)", txn.txnType.String(), resyncType)
txnInfo = fmt.Sprintf("%s", txn.nb.resyncType.String())
} else if txn.txnType == kvs.RetryFailedOps && txn.retry != nil {
txnInfo = fmt.Sprintf("retrying TX #%d (attempt %d)", txn.retry.txnSeqNum, txn.retry.attempt)
}
msg := fmt.Sprintf("#%d - %s", record.SeqNum, txn.txnType.String())
n := 115 - len(msg)
var buf strings.Builder
buf.WriteString("+======================================================================================================================+\n")
msg := fmt.Sprintf("Transaction #%d", record.SeqNum)
n := 115 - len(msg)
buf.WriteString(fmt.Sprintf("| %s %"+strconv.Itoa(n)+"s |\n", msg, txnInfo))
buf.WriteString("+======================================================================================================================+\n")
buf.WriteString(record.StringWithOpts(false, false, 2))
Expand All @@ -172,12 +167,15 @@ func (s *Scheduler) recordTransaction(txn *transaction, txnRecord *kvs.RecordedT
txnRecord.Executed = executed

if s.config.PrintTxnSummary {
txnType := txn.txnType.String()
msg := fmt.Sprintf("#%d - %s", txnRecord.SeqNum, txnType)
elapsed := stop.Sub(start)
msg2 := fmt.Sprintf("took %v", elapsed.Round(time.Microsecond*100))

var buf strings.Builder
buf.WriteString("o----------------------------------------------------------------------------------------------------------------------o\n")
buf.WriteString(txnRecord.StringWithOpts(true, false, 2))
buf.WriteString("x----------------------------------------------------------------------------------------------------------------------x\n")
msg := fmt.Sprintf("#%d", txnRecord.SeqNum)
msg2 := fmt.Sprintf("took %v", stop.Sub(start).Round(time.Microsecond*100))
buf.WriteString(fmt.Sprintf("| %s %"+fmt.Sprint(115-len(msg))+"s |\n", msg, msg2))
buf.WriteString("x----------------------------------------------------------------------------------------------------------------------x\n")
fmt.Println(buf.String())
Expand Down
Loading

0 comments on commit 0d44e82

Please sign in to comment.