-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable readiness reflector for Standalone NEG #927
Conversation
7e9871a
to
5ae14c2
Compare
pkg/neg/controller.go
Outdated
@@ -416,7 +416,7 @@ func (c *Controller) mergeStandaloneNEGsPortInfo(service *apiv1.Service, name ty | |||
return err | |||
} | |||
|
|||
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/*readinessGate*/true
pkg/neg/readiness/poller.go
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// syncPod syncs the NEG readiness gate of the given pod.
key => podKey
pkg/neg/readiness/poller.go
Outdated
} | ||
|
||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// processHealthStatus updates Pod readiness gates in response to a health status update.
//
// We update the pod (using the patcher) when:
// 1. ...
pkg/neg/readiness/poller.go
Outdated
// It returns true if retry is needed. | ||
func (p *poller) processHealthStatus(key negMeta, healthStatuses []*composite.NetworkEndpointWithHealthStatus) (bool, error) { | ||
var retry bool | ||
errList := []error{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var errList []error
pkg/neg/readiness/poller.go
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
)
pkg/neg/readiness/poller.go
Outdated
for _, hs := range healthStatus.Healths { | ||
if hs == nil { | ||
continue | ||
} | ||
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be an Error
|
||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue?
pkg/neg/readiness/poller.go
Outdated
|
||
// getHealthyBackendService returns one of the backend service key where the endpoint is considered healthy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ... returns the first healthy backend service key
pkg/neg/readiness/poller.go
Outdated
|
||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return healthStatus != nil && len(...)
8fb6d48
to
cd2dce2
Compare
Fixed the comments |
cd2dce2
to
5603304
Compare
/lgtm |
@@ -416,7 +416,7 @@ func (c *Controller) mergeStandaloneNEGsPortInfo(service *apiv1.Service, name ty | |||
return err | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Enable Pod Readiness Gate for Standalone NEG