Skip to content

Commit

Permalink
Addressing merge issues for the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoodmsft committed Dec 5, 2017
1 parent 26c1cbe commit 69c7eb5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 30 deletions.
6 changes: 6 additions & 0 deletions dataplane/windows/policysets/policysets.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func (s *PolicySets) protoRuleToHnsRules(policyId string, pRule *proto.Rule, isI
return nil, SkipRule
}

// Skip rules with name port ipsets
if len(pRule.SrcNamedPortIpSetIds) > 0 || len(pRule.DstNamedPortIpSetIds) > 0 {
log.WithField("rule", pRule).Info("Skipping rule because it contains named port ipsets (currently unsupported).")
return nil, SkipRule
}

// Filter the Src and Dst CIDRs to only the IP version that we're rendering
var filteredAll bool
ruleCopy := *pRule
Expand Down
84 changes: 60 additions & 24 deletions felix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"os"
"os/exec"
"os/signal"
"reflect"
"runtime"
"runtime/debug"
"syscall"
Expand Down Expand Up @@ -54,6 +53,7 @@ import (
"github.com/projectcalico/libcalico-go/lib/backend/watchersyncer"
errors2 "github.com/projectcalico/libcalico-go/lib/errors"
"github.com/projectcalico/libcalico-go/lib/health"
"github.com/projectcalico/libcalico-go/lib/set"
"github.com/projectcalico/typha/pkg/syncclient"
)

Expand Down Expand Up @@ -252,7 +252,13 @@ configRetry:
// Initialise the glue logic that connects the calculation graph to/from the dataplane driver.
log.Info("Connect to the dataplane driver.")
failureReportChan := make(chan string)
dpConnector := newConnector(configParams, backendClient, dpDriver, failureReportChan)
var connToUsageRepUpdChan chan map[string]string
if configParams.UsageReportingEnabled {
// Make a channel for the connector to use to send updates to the usage reporter.
// (Otherwise, we pass in a nil channel, which disables such updates.)
connToUsageRepUpdChan = make(chan map[string]string, 1)
}
dpConnector := newConnector(configParams, connToUsageRepUpdChan, backendClient, dpDriver, failureReportChan)

// Now create the calculation graph, which receives updates from the
// datastore and outputs dataplane updates for the dataplane driver.
Expand Down Expand Up @@ -332,13 +338,13 @@ configRetry:
}
}()

go usagerep.PeriodicallyReportUsage(
24*time.Hour,
configParams.ClusterGUID,
configParams.ClusterType,
configParams.CalicoVersion,
usageRep := usagerep.New(
configParams.UsageReportingInitialDelaySecs,
configParams.UsageReportingIntervalSecs,
statsChanOut,
connToUsageRepUpdChan,
)
go usageRep.PeriodicallyReportUsage(context.Background())
} else {
// Usage reporting disabled, but we still want a stats collector for the
// felix_cluster_* metrics. Register a no-op function as the callback.
Expand Down Expand Up @@ -673,6 +679,7 @@ func getAndMergeConfig(

type DataplaneConnector struct {
config *config.Config
configUpdChan chan<- map[string]string
ToDataplane chan interface{}
StatusUpdatesFromDataplane chan interface{}
InSync chan bool
Expand All @@ -691,11 +698,14 @@ type Startable interface {
}

func newConnector(configParams *config.Config,
configUpdChan chan<- map[string]string,
datastore bapi.Client,
dataplane dp.DataplaneDriver,
failureReportChan chan<- string) *DataplaneConnector {
failureReportChan chan<- string,
) *DataplaneConnector {
felixConn := &DataplaneConnector{
config: configParams,
configUpdChan: configUpdChan,
datastore: datastore,
ToDataplane: make(chan interface{}),
StatusUpdatesFromDataplane: make(chan interface{}),
Expand Down Expand Up @@ -772,6 +782,8 @@ func (fc *DataplaneConnector) handleProcessStatusUpdate(msg *proto.ProcessStatus
}
}

var handledConfigChanges = set.From("CalicoVersion", "ClusterGUID", "ClusterType")

func (fc *DataplaneConnector) sendMessagesToDataplaneDriver() {
defer func() {
fc.shutDownProcess("Failed to send messages to dataplane")
Expand All @@ -789,32 +801,56 @@ func (fc *DataplaneConnector) sendMessagesToDataplaneDriver() {
fc.InSync <- true
}
case *proto.ConfigUpdate:
log.WithFields(log.Fields{
"old": config,
"new": msg.Config,
}).Info("Possible config update")
if config != nil && !reflect.DeepEqual(msg.Config, config) {
log.Warn("Felix configuration changed. Need to restart.")
if config != nil {
log.WithFields(log.Fields{
"old": config,
"new": msg.Config,
}).Info("Config updated, checking whether we need to restart")
restartNeeded := false
for kNew, vNew := range msg.Config {
logCxt := log.WithFields(log.Fields{"key": kNew, "new": vNew})
if vOld, prs := config[kNew]; !prs {
log.WithFields(log.Fields{"key": kNew, "value": vNew}).Warn("Felix configuration changed: Key added")
logCxt = logCxt.WithField("updateType", "add")
} else if vNew != vOld {
log.WithFields(log.Fields{"key": kNew, "old": vOld, "new": vNew}).Warn("Felix configuration changed: Key changed")
logCxt = logCxt.WithFields(log.Fields{"old": vOld, "updateType": "update"})
} else {
continue
}
if handledConfigChanges.Contains(kNew) {
logCxt.Info("Config change can be handled without restart")
continue
}
logCxt.Warning("Config change requires restart")
restartNeeded = true
}
for kOld, vOld := range config {
if _, prs := config[kOld]; !prs {
log.WithFields(log.Fields{"key": kOld, "value": vOld}).Warn("Felix configuration changed: Key deleted")
logCxt := log.WithFields(log.Fields{"key": kOld, "old": vOld, "updateType": "delete"})
if _, prs := config[kOld]; prs {
continue
}
if handledConfigChanges.Contains(kOld) {
logCxt.Info("Config change can be handled without restart")
continue
}
logCxt.Warning("Config change requires restart")
restartNeeded = true
}
fc.shutDownProcess(reasonConfigChanged)
} else if config == nil {
log.Info("Config resolved.")
config = make(map[string]string)
for k, v := range msg.Config {
config[k] = v

if restartNeeded {
fc.shutDownProcess("config changed")
}
}

// Take a copy of the config to compare against next time.
config = make(map[string]string)
for k, v := range msg.Config {
config[k] = v
}

if fc.configUpdChan != nil {
// Send the config over to the usage reporter.
fc.configUpdChan <- config
}
case *calc.DatastoreNotReady:
log.Warn("Datastore became unready, need to restart.")
fc.shutDownProcess("datastore became unready")
Expand Down
8 changes: 4 additions & 4 deletions glide.lock

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

4 changes: 2 additions & 2 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import:
- package: github.com/go-ini/ini
version: ^1.21.0
- package: github.com/projectcalico/libcalico-go
version: master
version: c07bf34a9a362e92e5e51853fd5fe03c27ecf333
subpackages:
- lib
- package: github.com/sirupsen/logrus
Expand All @@ -43,7 +43,7 @@ import:
- package: k8s.io/client-go
version: 82aa063804cf055e16e8911250f888bc216e8b61
- package: github.com/projectcalico/typha
version: 596ddb78e6d487f8899bc33f0d9b54c4f0fb9354
version: a3bbbde042b0a4fa8d75ec155c5910e491e0dcca
subpackages:
- pkg/syncclient
- package: github.com/emicklei/go-restful
Expand Down

0 comments on commit 69c7eb5

Please sign in to comment.