type Leases … type storageLeases … var _ … // ListLeases retrieves a list of the current master IPs from storage func (s *storageLeases) ListLeases() ([]string, error) { … } // UpdateLease resets the TTL on a master IP in storage // UpdateLease will create a new key if it doesn't exist. func (s *storageLeases) UpdateLease(ip string) error { … } // RemoveLease removes the lease on a master IP in storage func (s *storageLeases) RemoveLease(ip string) error { … } func (s *storageLeases) Destroy() { … } // NewLeases creates a new etcd-based Leases implementation. func NewLeases(config *storagebackend.ConfigForResource, baseKey string, leaseTime time.Duration) (Leases, error) { … } type leaseEndpointReconciler … // NewLeaseEndpointReconciler creates a new LeaseEndpoint reconciler func NewLeaseEndpointReconciler(epAdapter EndpointsAdapter, masterLeases Leases) EndpointReconciler { … } // ReconcileEndpoints lists keys in a special etcd directory. // Each key is expected to have a TTL of R+n, where R is the refresh interval // at which this function is called, and n is some small value. If an // apiserver goes down, it will fail to refresh its key's TTL and the key will // expire. ReconcileEndpoints will notice that the endpoints object is // different from the directory listing, and update the endpoints object // accordingly. func (r *leaseEndpointReconciler) ReconcileEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error { … } // doReconcile can be called from ReconcileEndpoints() or RemoveEndpoints(). // it is NOT SAFE to call it from multiple goroutines. func (r *leaseEndpointReconciler) doReconcile(serviceName string, endpointPorts []corev1.EndpointPort, reconcilePorts bool) error { … } // checkEndpointSubsetFormatWithLease determines if the endpoint is in the // format ReconcileEndpoints expects when the controller is using leases. // // Return values: // - formatCorrect is true if exactly one subset is found. // - ipsCorrect when the addresses in the endpoints match the expected addresses list // - portsCorrect is true when endpoint ports exactly match provided ports. // portsCorrect is only evaluated when reconcilePorts is set to true. func checkEndpointSubsetFormatWithLease(e *corev1.Endpoints, expectedIPs []string, ports []corev1.EndpointPort, reconcilePorts bool) (formatCorrect bool, ipsCorrect bool, portsCorrect bool) { … } func (r *leaseEndpointReconciler) RemoveEndpoints(serviceName string, ip net.IP, endpointPorts []corev1.EndpointPort) error { … } func (r *leaseEndpointReconciler) StopReconciling() { … } func (r *leaseEndpointReconciler) Destroy() { … }