Change:
<!-- This form is for bug reports and feature requests ONLY! If you're looking for help check and the . --Is this a BUG REPORT or FEATURE REQUEST?: /kind bug What happened: IPVS proxier update service too slow, it waits until a sync period. What you expected to happen: Any k8s service update should trigger IPVS virtual service update. How to reproduce it (as minimally and precisely as possible): a k8s service its session affinity type see if ipvs virtual service has changed - NO! Anything else we need to know?: Environment: Kubernetes version (use ): Cloud provider or hardware configuration: OS (e.g. from /etc/os-release): Kernel (e.g. ): Install tools: Others: /sig network /area ipvs

Discussion:
// IPVS service was changed, update the existing one // During updates, service VIP will not go down glog.V(3).Infof("IPVS service %s was changed", svcName) <del> if err := proxier.ipvs.UpdateVirtualServer(appliedVirtualServer); err != nil { </del> <ins> if err := proxier.ipvs.UpdateVirtualServer(vs); err != nil { </ins> glog.Errorf("Failed to update IPVS service, err:%v", err) return err }

} } } <ins> func Test_syncService(t *testing.T) { testCases := []struct { oldVirtualServer *utilipvs.VirtualServer svcName          string newVirtualServer *utilipvs.VirtualServer bindAddr         bool }{ { // case 0, old virtual server is same as new virtual server oldVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      80, Scheduler: "rr", Flags:     utilipvs.FlagHashed, }, svcName: "foo", newVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      80, Scheduler: "rr", Flags:     utilipvs.FlagHashed, }, bindAddr: false, }, { // case 1, old virtual server is different from new virtual server oldVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      8080, Scheduler: "rr", Flags:     utilipvs.FlagHashed, }, svcName: "bar", newVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      8080, Scheduler: "rr", Flags:     utilipvs.FlagPersistent, }, bindAddr: false, }, { // case 2, old virtual server is different from new virtual server oldVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      8080, Scheduler: "rr", Flags:     utilipvs.FlagHashed, }, svcName: "bar", newVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolTCP), Port:      8080, Scheduler: "wlc", Flags:     utilipvs.FlagHashed, }, bindAddr: false, }, { // case 3, old virtual server is nil, and create new virtual server oldVirtualServer: nil, svcName:          "baz", newVirtualServer: &utilipvs.VirtualServer{ Address:   net.ParseIP("1.2.3.4"), Protocol:  string(api.ProtocolUDP), Port:      53, Scheduler: "rr", Flags:     utilipvs.FlagHashed, }, bindAddr: true, }, } for i := range testCases { ipt := iptablestest.NewFake() ipvs := ipvstest.NewFake() ipset := ipsettest.NewFake(testIPSetVersion) proxier := NewFakeProxier(ipt, ipvs, ipset, nil) if testCases[i].oldVirtualServer != nil { if err := proxier.ipvs.AddVirtualServer(testCases[i].oldVirtualServer); err != nil { t.Errorf("Case [%d], unexpected add IPVS virtual server error: %v", i, err) } } if err := proxier.syncService(testCases[i].svcName, testCases[i].newVirtualServer, testCases[i].bindAddr); err != nil { t.Errorf("Case [%d], unexpected sync IPVS virutal server error: %v", i, err) } // check list, err := proxier.ipvs.GetVirtualServers() if err != nil { t.Errorf("Case [%d], unexpected list IPVS virtual server error: %v", i, err) } if len(list) != 1 { t.Errorf("Case [%d], expect %d virtual servers, got %d", i, 1, len(list)) continue } if !list[0].Equal(testCases[i].newVirtualServer) { t.Errorf("Case [%d], unexpected mismatch, expect: %#v, got: %#v", i, testCases[i].newVirtualServer, list[0]) } } } </ins>