kube-proxyy: update winkernel proxier to read 'ready', 'serving' and 'terminating' conditions

Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
Andrew Sy Kim 2020-11-09 12:11:09 -05:00
parent a7333e1a3e
commit 1acdfb4e7c
2 changed files with 46 additions and 1 deletions

View File

@ -65,6 +65,11 @@ func (hns hnsV1) getEndpointByID(id string) (*endpointsInfo, error) {
macAddress: hnsendpoint.MacAddress,
hnsID: hnsendpoint.Id,
hns: hns,
// only ready and not terminating endpoints were added to HNS
ready: true,
serving: true,
terminating: false,
}, nil
}
func (hns hnsV1) getEndpointByIpAddress(ip string, networkName string) (*endpointsInfo, error) {
@ -90,6 +95,11 @@ func (hns hnsV1) getEndpointByIpAddress(ip string, networkName string) (*endpoin
macAddress: endpoint.MacAddress,
hnsID: endpoint.Id,
hns: hns,
// only ready and not terminating endpoints were added to HNS
ready: true,
serving: true,
terminating: false,
}, nil
}
}
@ -137,6 +147,10 @@ func (hns hnsV1) createEndpoint(ep *endpointsInfo, networkName string) (*endpoin
hnsID: createdEndpoint.Id,
providerAddress: ep.providerAddress, //TODO get from createdEndpoint
hns: hns,
ready: ep.ready,
serving: ep.serving,
terminating: ep.terminating,
}, nil
}
func (hns hnsV1) deleteEndpoint(hnsID string) error {

View File

@ -162,6 +162,11 @@ type endpointsInfo struct {
refCount *uint16
providerAddress string
hns HostNetworkService
// conditions
ready bool
serving bool
terminating bool
}
// String is part of proxy.Endpoint interface.
@ -174,6 +179,21 @@ func (info *endpointsInfo) GetIsLocal() bool {
return info.isLocal
}
// IsReady returns true if an endpoint is ready and not terminating.
func (info *endpointsInfo) IsReady() bool {
return info.ready
}
// IsServing returns true if an endpoint is ready, regardless of it's terminating state.
func (info *endpointsInfo) IsServing() bool {
return info.serving
}
// IsTerminating returns true if an endpoint is terminating.
func (info *endpointsInfo) IsTerminating() bool {
return info.terminating
}
// GetTopology returns the topology information of the endpoint.
func (info *endpointsInfo) GetTopology() map[string]string {
return nil
@ -300,6 +320,10 @@ func (proxier *Proxier) newEndpointInfo(baseInfo *proxy.BaseEndpointInfo) proxy.
refCount: new(uint16),
hnsID: "",
hns: proxier.hns,
ready: baseInfo.Ready,
serving: baseInfo.Serving,
terminating: baseInfo.Terminating,
}
return info
@ -311,6 +335,10 @@ func newSourceVIP(hns HostNetworkService, network string, ip string, mac string,
isLocal: true,
macAddress: mac,
providerAddress: providerAddress,
ready: true,
serving: true,
terminating: false,
}
ep, err := hns.createEndpoint(hnsEndpoint, network)
return ep, err
@ -1010,13 +1038,16 @@ func (proxier *Proxier) syncProxyRules() {
containsNodeIP := false
for _, epInfo := range proxier.endpointsMap[svcName] {
ep, ok := epInfo.(*endpointsInfo)
if !ok {
klog.Errorf("Failed to cast endpointsInfo %q", svcName.String())
continue
}
if !ep.IsReady() {
continue
}
var newHnsEndpoint *endpointsInfo
hnsNetworkName := proxier.network.name
var err error