MCPcopy
hub / github.com/google/seesaw / handleConfigUpdate

Method handleConfigUpdate

engine/vserver.go:554–622  ·  view source on GitHub ↗

handleConfigUpdate updates the internal structures of a vserver using the new configuration.

(config *config.Vserver)

Source from the content-addressed store, hash-verified

552// handleConfigUpdate updates the internal structures of a vserver using the
553// new configuration.
554func (v *vserver) handleConfigUpdate(config *config.Vserver) {
555 if config == nil {
556 return
557 }
558 switch {
559 case v.config == nil:
560 v.configInit(config)
561 return
562
563 case v.enabled && !vserverEnabled(config, v.vserverOverride.State()):
564 log.Infof("%v: disabling vserver", v)
565 v.downAll()
566 v.unconfigureVIPs()
567 v.configInit(config)
568 return
569
570 case !v.enabled && !vserverEnabled(config, v.vserverOverride.State()):
571 v.configInit(config)
572 return
573
574 case !v.enabled && vserverEnabled(config, v.vserverOverride.State()):
575 log.Infof("%v: enabling vserver", v)
576 v.configInit(config)
577 return
578
579 default:
580 // Some updates require changes to the iptables rules. Since we currently
581 // can't make fine-grained changes to the iptables rules, we must
582 // re-initialise the entire vserver. This is necessary in the following
583 // scenarios:
584 // - A port or protocol is added, removed or changed
585 // - A vserver is changed from FWM to non-FWM or vice versa
586 // - A vserverEntry is changed from DSR to NAT or vice versa
587 //
588 // (Changing a VIP address also requires updating iptables, but
589 // v.configUpdate() handles this case)
590 //
591 // TODO(angusc): Add support for finer-grained updates to ncc so we can
592 // avoid re-initialising the vserver in these cases.
593 reInit := false
594 switch {
595 case config.UseFWM != v.config.UseFWM:
596 reInit = true
597 case len(config.Entries) != len(v.config.Entries):
598 reInit = true
599 default:
600 for k, entry := range config.Entries {
601 if v.config.Entries[k] == nil {
602 reInit = true
603 break
604 }
605 if v.config.Entries[k].Mode != entry.Mode {
606 reInit = true
607 break
608 }
609 }
610 }
611 if reInit {

Callers 2

runMethod · 0.95
handleOverrideMethod · 0.95

Calls 6

configInitMethod · 0.95
downAllMethod · 0.95
unconfigureVIPsMethod · 0.95
configUpdateMethod · 0.95
vserverEnabledFunction · 0.85
StateMethod · 0.65

Tested by

no test coverage detected