Repository navigation
enable readiness reflector for Standalone NEG - #927
Conversation
7e9871a to
5ae14c2
Compare
| } | ||
|
|
||
| if err := portInfoMap.Merge(negtypes.NewPortInfoMap(name.Namespace, name.Name, exposedNegSvcPort, c.namer, false)); err != nil { | ||
| if err := portInfoMap.Merge(negtypes.NewPortInfoMap(name.Namespace, name.Name, exposedNegSvcPort, c.namer, true)); err != nil { |
| syncPod(key, negName string) error | ||
| // neg is the key of the NEG resource | ||
| // backendService is the key of the BackendService resource. | ||
| syncPod(key string, neg, backendService *meta.Key) error |
There was a problem hiding this comment.
// syncPod syncs the NEG readiness gate of the given pod.
key => podKey
| } | ||
|
|
||
| // processHealthStatus processes the health status response from NEG API. | ||
| // It processed health status for each endpoint and signal patcher correspondingly in the following conditions: |
There was a problem hiding this comment.
// processHealthStatus updates Pod readiness gates in response to a health status update.
//
// We update the pod (using the patcher) when:
// 1. ...
| // It returns true if retry is needed. | ||
| func (p *poller) processHealthStatus(key negMeta, healthStatuses []*composite.NetworkEndpointWithHealthStatus) (bool, error) { | ||
| var retry bool | ||
| errList := []error{} |
| // 2. if the NEG is not associated with any health checks | ||
| // It returns true if retry is needed. | ||
| func (p *poller) processHealthStatus(key negMeta, healthStatuses []*composite.NetworkEndpointWithHealthStatus) (bool, error) { | ||
| var retry bool |
There was a problem hiding this comment.
these var decls are kind of random, prefer putting locking at the top and grouping everything
p.lock.Lock()
defer p.lock.Unlock()
var (
retry bool
errList []error
patchCount int
unhealthyPods []types.NamespacedName
// healthChecked indicates ...
healthChecked bool
)
| } | ||
| if hs.BackendService == nil { | ||
| klog.Warningf("Backend service is nil in health status of network endpoint %v: %v", ne, hs) | ||
| klog.Warningf("Backend service is nil in health status of network endpoint %v", healthStatus) |
| // getHealthyBackendService returns one of the backend service key where the endpoint is considered healthy. | ||
| func getHealthyBackendService(healthStatus *composite.NetworkEndpointWithHealthStatus) *meta.Key { | ||
| for _, hs := range healthStatus.Healths { | ||
| if hs == nil { |
There was a problem hiding this comment.
this should be an Error log.
Also, kind of strange to have to check for nils everywhere
| if hs.HealthState == healthyState { | ||
| id, err := cloud.ParseResourceURL(hs.BackendService.BackendService) | ||
| if err != nil { | ||
| klog.Errorf("Failed to parse backend service reference from a Network Endpoint health status %v: %v", healthStatus, err) |
| return retry, utilerrors.NewAggregate(errList) | ||
| } | ||
|
|
||
| // getHealthyBackendService returns one of the backend service key where the endpoint is considered healthy. |
There was a problem hiding this comment.
// ... returns the first healthy backend service key
|
|
||
| // hasHealthStatus returns true if there is at least 1 health status associated with the endpoint. | ||
| func hasHealthStatus(healthStatus *composite.NetworkEndpointWithHealthStatus) bool { | ||
| if healthStatus != nil && len(healthStatus.Healths) > 0 { |
There was a problem hiding this comment.
return healthStatus != nil && len(...)
8fb6d48 to
cd2dce2
Compare
|
Fixed the comments |
cd2dce2 to
5603304
Compare
|
/lgtm |
| } | ||
|
|
||
| if err := portInfoMap.Merge(negtypes.NewPortInfoMap(name.Namespace, name.Name, exposedNegSvcPort, c.namer, false)); err != nil { | ||
| if err := portInfoMap.Merge(negtypes.NewPortInfoMap(name.Namespace, name.Name, exposedNegSvcPort, c.namer /*readinessGate*/, true)); err != nil { |
There was a problem hiding this comment.
you have this on the wrong parameter.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, freehan The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Enable Pod Readiness Gate for Standalone NEG