fix proxy change not work bugs

This commit is contained in:
凡羊羊 2019-10-15 23:46:08 +08:00
parent c58f4ae60a
commit c53dbb42cc
3 changed files with 11 additions and 4 deletions

View File

@ -154,6 +154,10 @@ func (gwc *GWController) syncGateway(key interface{}) error {
L7VS: l7sv,
L4VS: l4sv,
}
logrus.Debugf("gwc.rcfig : %+v", gwc.rcfg)
logrus.Debugf("currentConfig: %+v", currentConfig)
if gwc.rcfg.Equals(currentConfig) {
logrus.Info("No need to update running configuration.")
// refresh http pools dynamically

View File

@ -109,9 +109,6 @@ func (n *NginxConfigFileTemplete) NewNginxTemplate(data *model.Nginx) error {
//WriteServer write server config
func (n *NginxConfigFileTemplete) WriteServer(c option.Config, configtype, tenant string, servers ...*model.Server) error {
if servers == nil || len(servers) < 1 {
return nil
}
if tenant == "" {
tenant = "default"
}
@ -125,6 +122,10 @@ func (n *NginxConfigFileTemplete) WriteServer(c option.Config, configtype, tenan
defer n.writeLocks[tenant].Unlock()
serverConfigFile := path.Join(n.configFileDirPath, configtype, tenant, "servers.conf")
first := true
if servers == nil || len(servers) < 1 {
logrus.Warnf("%s proxy is empty, nginx server[%s] will clean up", tenant, serverConfigFile)
return n.writeFile(first, []byte{}, serverConfigFile)
}
for i, server := range servers {
body, err := n.serverTmpl.Write(&NginxServerContext{
Server: servers[i],

View File

@ -18,6 +18,8 @@
package v1
import "github.com/Sirupsen/logrus"
//LoadBalancingType Load Balancing type
type LoadBalancingType string
@ -125,7 +127,7 @@ func (cfg *Config) Equals(c *Config) bool {
return false
}
}
logrus.Debugf("len if cnf.L4VS = %d, l4vs = %d", len(cfg.L4VS), len(c.L4VS))
if len(cfg.L4VS) != len(c.L4VS) {
return false
}