Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Remove terminating pods from endpoints #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/endpoints/controller/endpoints_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"strconv"
"sync"

"github.com/deislabs/osiris/pkg/kubernetes"
Expand All @@ -18,6 +19,14 @@ import (
endpointsv1 "k8s.io/kubernetes/pkg/api/v1/endpoints"
)

const (

// tolerateAnnoration backport annotation
// TolerateUnreadyEndpointsAnnotation definition from
// k8s.io/kubernetes/pkg/controller/endpoint
tolerateAnnoration = "service.alpha.kubernetes.io/tolerate-unready-endpoints"
)

// endpointsManager is a controller responsible for the on-going management of
// the endpoints resource corresponding to a single Osiris-enabled service
type endpointsManager struct {
Expand Down Expand Up @@ -127,6 +136,27 @@ func (e *endpointsManager) syncAppPod(obj interface{}) {
break
}
}

// If the user specified the older (deprecated) annotation,
// we have to respect it.
tolerateUnreadyEndpoints := e.service.Spec.PublishNotReadyAddresses
v, ok := e.service.Annotations[tolerateAnnoration]
if ok {
b, err := strconv.ParseBool(v)
if err == nil {
tolerateUnreadyEndpoints = b
} else {
glog.Errorf(
"Failed to parse annotation %v: %v",
tolerateAnnoration,
err,
)
}
}

if !tolerateUnreadyEndpoints && pod.DeletionTimestamp != nil {
ready = false
}
glog.Infof(
"Informed about pod %s for service %s in namespace %s; its IP is %s and "+
"its ready condition is %t",
Expand Down