Skip to content

Commit

Permalink
v2.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Greer committed Feb 24, 2022
1 parent c023d1b commit f7fd311
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TAG=v2.5.6-rc1
TAG=v2.5.6

# rc6: hub.comcast.net/k8s-eng/ravel:v2.5.0-proto45
# rc7: hub.comcast.net/k8s-eng/ravel:v2.5.0-proto66
Expand Down
17 changes: 11 additions & 6 deletions pkg/system/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (i *ipManager) add(ctx context.Context, addr string, isIP6 bool) error {
device := i.generateDeviceLabel(addr, isIP6)
// create the device
args := []string{"link", "add", device, "type", "dummy"}
// log.Debugln("ipManager: using command: ip", args)
log.Debugln("ipManager: adding ip using command: ip", args)

cmdCtx, cmdContextCancel := context.WithTimeout(ctx, time.Second*20)
defer cmdContextCancel()
Expand All @@ -294,12 +294,12 @@ func (i *ipManager) add(ctx context.Context, addr string, isIP6 bool) error {
// if it exists, we know we have already added the iface for it, and
// the relevant address. Exit success from this method
if err != nil && strings.Contains(string(out), "File exists") {
// log.Debugln("ipManager: attempted to add interface, but it already exists")
log.Debugln("ipManager: attempted to add interface, but it already exists")
return nil
}

// if the error _does not_ indicate the file exists, we have a real error
if err != nil && !strings.Contains(string(out), "File exists") {
if err != nil {
return fmt.Errorf("ipManager: failed to create device %s for addr %s: %v. Saw output: %s", device, addr, err, string(out))
}

Expand All @@ -323,11 +323,10 @@ func (i *ipManager) add(ctx context.Context, addr string, isIP6 bool) error {
cmd = exec.CommandContext(cmdCtx, "ip", args...)
out, err = cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("ipManager: unable to add address='%s' on device='%s' with args='%v'. %v. Saw output: %s", addr, device, args, err, string(out))
return fmt.Errorf("ipManager: unable to add ip on second try address='%s' on device='%s' with args='%v'. %v. Saw output: %s", addr, device, args, err, string(out))
}

log.Debugln("ipManager: successfully added loopback adapter and address", addr)

log.Debugln("ipManager: successfully added dummy loopback adapter with address", addr)
return nil
}

Expand Down Expand Up @@ -456,6 +455,12 @@ func (i *ipManager) retrieveDummyIFaces() ([]string, error) {
// run the commands piped together
output, err := runPipeCommands(ctx, commandA, commandB)
if err != nil {
// if the error is `error waiting for command 2: exit status 1`, then that means there are no adapters,
// because grep exits 1 when it does not find results. We should gracefully handle this circumstance.
if strings.Contains(err.Error(), "error waiting for command 2: exit status 1") {
log.Debugln("ipManager: ip link show | grep -B 2 dummy did not find any adapters")
return []string{}, nil
}
return []string{}, fmt.Errorf("ipManager: error running ip link show command: %w", err)
}

Expand Down
26 changes: 19 additions & 7 deletions pkg/system/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,12 @@ func (w *watcher) watches() {
for {
select {
case <-w.ctx.Done():
log.Debugln("watcher: context is done. calling w.Stop")
log.Debugln("watcher: context is done. calling w.stopWatch")
w.stopWatch()
return

case evt, ok := <-w.services.ResultChan():
log.Debugln("watcher: services chan got an event:", evt)
if !ok || evt.Object == nil {
err := w.resetWatch()
if err != nil {
Expand All @@ -257,10 +258,11 @@ func (w *watcher) watches() {
w.processService(evt.Type, svc.DeepCopy())

case evt, ok := <-w.endpoints.ResultChan():
log.Debugln("watcher: endpoints chan got an event:", evt)
if !ok || evt.Object == nil {
err := w.resetWatch()
if err != nil {
w.logger.Errorf("endpoints evt arrived, resetWatch() failed: %v", err)
w.logger.Errorf("watcher: endpoints evt arrived, resetWatch() failed: %v", err)
}
continue
}
Expand All @@ -272,6 +274,7 @@ func (w *watcher) watches() {
w.processEndpoint(evt.Type, ep.DeepCopy())

case evt, ok := <-w.configmaps.ResultChan():
log.Debugln("watcher: configmaps chan got an event:", evt)
if !ok || evt.Object == nil {
err := w.resetWatch()
if err != nil {
Expand All @@ -288,6 +291,7 @@ func (w *watcher) watches() {
w.processConfigMap(evt.Type, cm.DeepCopy())

case evt, ok := <-w.nodeWatch.ResultChan():
log.Debugln("watcher: nodeWatch chan got an event:", evt)
if !ok || evt.Object == nil {
err := w.resetWatch()
if err != nil {
Expand Down Expand Up @@ -319,6 +323,7 @@ func (w *watcher) watches() {
}
// increment total only if the watchers didn't expire
totalUpdates++
log.Debugln("watcher: update count is now:", totalUpdates)

if w.configMap == nil {
w.logger.Warnf("configmap is nil. skipping publication")
Expand All @@ -328,23 +333,24 @@ func (w *watcher) watches() {
// Build a new cluster config and publish it, maybe
if modified, cc, err := w.buildClusterConfig(); err != nil {
w.metrics.WatchClusterConfig("error")
w.logger.Errorf("error building cluster config. %v", err)
w.logger.Errorf("watcher: error building cluster config. %v", err)
} else if modified {
w.metrics.WatchClusterConfig("publish")
// w.logger.Debug("publishing new cluster config")
w.logger.Debug("watcher: publishing new cluster config")
w.publishChan <- cc
} else {
w.metrics.WatchClusterConfig("noop")
// w.logger.Debug("cluster config not modified")
w.logger.Debug("watcher: cluster config not modified")
}

// Here, do the nodes workflow and publish it definitely
// Compute a new set of nodes and node endpoints. Compare that set of info to the
// set of info that was last transmitted. If it changed, publish it.
if nodes, err := w.buildNodeConfig(); err != nil {
w.logger.Infof("building node config: %v", err)
w.logger.Infof("watcher: error building node config: %v", err)
// should it return here?
} else {
w.logger.Infof("watcher: publishing node config")
w.publishNodes(nodes)
}
}
Expand Down Expand Up @@ -462,6 +468,7 @@ func (w *watcher) watchPublish() {
select {
case cc := <-w.publishChan:
// w.logger.Debugf("watchPublish loop iteration - resv on publishChan - timeout=%v", timeout)
log.Debugln("watcher: publish signal recieved. Waiting for 2 second timeout")
lastCC = cc
if countdownActive && timeout >= maxTimeout {
continue
Expand All @@ -475,6 +482,7 @@ func (w *watcher) watchPublish() {

case <-countdown.C:
// w.logger.Debugf("watchPublish loop iteration - countdown timer expired - timeout=%v", timeout)
log.Debugln("watcher: publishing cluster config:", lastCC)
countdownActive = false
w.publish(lastCC)
timeout = baseTimeout
Expand Down Expand Up @@ -583,6 +591,7 @@ func (w *watcher) buildClusterConfig() (bool, *types.ClusterConfig, error) {
return false, nil, nil
}

log.Println("watcher: cluster config was changed")
return true, rawConfig, nil
}

Expand Down Expand Up @@ -771,6 +780,9 @@ func (w *watcher) extractConfigKey(configmap *v1.ConfigMap) (*types.ClusterConfi
// addListenersToConfig mutates the input types.ClusterConfig to add the autoSvc and autoPort
// from the watcher primary configuration, if that value is set.
func (w *watcher) addListenersToConfig(inCC *types.ClusterConfig) error {

log.Debugln("unicorns: addListenersToConfig")

// bail out if there's nothing to do.
if w.autoSvc == "" {
log.Debugln("unicorns: not adding unicorns listner because the autoSvc is blank")
Expand All @@ -782,7 +794,7 @@ func (w *watcher) addListenersToConfig(inCC *types.ClusterConfig) error {
// If not, create.
autoSvc, err := types.NewServiceDef(w.autoSvc)
if err != nil {
return fmt.Errorf("unable to add listener to config. %v", err)
return fmt.Errorf("unicorns: unable to add listener to config. %v", err)
}
autoSvc.IPVSOptions.RawForwardingMethod = "i"
for _, vip := range inCC.VIPPool {
Expand Down

0 comments on commit f7fd311

Please sign in to comment.