Skip to content

enable readiness reflector for Standalone NEG - #927

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
freehan:standalone-neg-ga
Nov 14, 2019
Merged

k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
freehan:standalone-neg-ga

Conversation

@freehan

@freehan freehan commented Nov 4, 2019

Copy link
Copy Markdown
Contributor

Enable Pod Readiness Gate for Standalone NEG

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 4, 2019
Comment thread pkg/neg/controller.go Outdated
}

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/*readinessGate*/true

Comment thread 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

Copy link
Copy Markdown
Member

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

Comment thread 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:

Copy link
Copy Markdown
Member

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. ...

Comment thread 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{}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var errList []error

Comment thread 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

Copy link
Copy Markdown
Member

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
)

Comment thread pkg/neg/readiness/poller.go Outdated
}
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)

Copy link
Copy Markdown
Member

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 {

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue?

Comment thread pkg/neg/readiness/poller.go Outdated
return retry, utilerrors.NewAggregate(errList)
}

// getHealthyBackendService returns one of the backend service key where the endpoint is considered healthy.

Copy link
Copy Markdown
Member

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

Comment thread 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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return healthStatus != nil && len(...)

@freehan
freehan force-pushed the standalone-neg-ga branch 3 times, most recently from 8fb6d48 to cd2dce2 Compare November 12, 2019 22:28
@freehan

freehan commented Nov 13, 2019

Copy link
Copy Markdown
Contributor Author

Fixed the comments

@bowei

bowei commented Nov 14, 2019

Copy link
Copy Markdown
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 14, 2019
Comment thread pkg/neg/controller.go
}

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 {

Copy link
Copy Markdown
Member

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.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
k8s-ci-robot merged commit 7a92145 into kubernetes:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants