mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #53809 from rrati/lease-reconciler-fixes
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fixed the lease endpoint reconciler creation of kubernetes endpoint and lease file ttl. #53803 Fixed the prefix used to create the kubernetes endpoint and the ttl value used for lease files. Fixes: #53803
This commit is contained in:
commit
c7a1a061c3
@ -93,8 +93,6 @@ const (
|
||||
DefaultEndpointReconcilerInterval = 10 * time.Second
|
||||
// DefaultEndpointReconcilerTTL is the default TTL timeout for the storage layer
|
||||
DefaultEndpointReconcilerTTL = 15 * time.Second
|
||||
// DefaultStorageEndpoint is the default storage endpoint for the lease controller
|
||||
DefaultStorageEndpoint = "kube-apiserver-endpoint"
|
||||
)
|
||||
|
||||
type ExtraConfig struct {
|
||||
@ -206,7 +204,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
|
||||
if err != nil {
|
||||
glog.Fatalf("Error creating storage factory: %v", err)
|
||||
}
|
||||
endpointConfig, err := c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource(DefaultStorageEndpoint))
|
||||
endpointConfig, err := c.ExtraConfig.StorageFactory.NewConfig(kapi.Resource("endpoints"))
|
||||
if err != nil {
|
||||
glog.Fatalf("Error getting storage config: %v", err)
|
||||
}
|
||||
@ -214,7 +212,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
|
||||
StorageConfig: endpointConfig,
|
||||
Decorator: generic.UndecoratedStorage,
|
||||
DeleteCollectionWorkers: 0,
|
||||
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource(DefaultStorageEndpoint)),
|
||||
ResourcePrefix: c.ExtraConfig.StorageFactory.ResourcePrefix(kapi.Resource("endpoints")),
|
||||
})
|
||||
endpointRegistry := endpoint.NewRegistry(endpointsStorage)
|
||||
masterLeases := reconcilers.NewLeases(leaseStorage, "/masterleases/", ttl)
|
||||
|
@ -24,6 +24,7 @@ https://github.com/openshift/origin/blob/bb340c5dd5ff72718be86fb194dedc0faed7f4c
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"path"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -77,7 +78,8 @@ func (s *storageLeases) ListLeases() ([]string, error) {
|
||||
|
||||
// UpdateLease resets the TTL on a master IP in storage
|
||||
func (s *storageLeases) UpdateLease(ip string) error {
|
||||
return s.storage.GuaranteedUpdate(apirequest.NewDefaultContext(), s.baseKey+"/"+ip, &api.Endpoints{}, true, nil, func(input kruntime.Object, respMeta storage.ResponseMeta) (kruntime.Object, *uint64, error) {
|
||||
key := path.Join(s.baseKey, ip)
|
||||
return s.storage.GuaranteedUpdate(apirequest.NewDefaultContext(), key, &api.Endpoints{}, true, nil, func(input kruntime.Object, respMeta storage.ResponseMeta) (kruntime.Object, *uint64, error) {
|
||||
// just make sure we've got the right IP set, and then refresh the TTL
|
||||
existing := input.(*api.Endpoints)
|
||||
existing.Subsets = []api.EndpointSubset{
|
||||
@ -86,7 +88,8 @@ func (s *storageLeases) UpdateLease(ip string) error {
|
||||
},
|
||||
}
|
||||
|
||||
leaseTime := uint64(s.leaseTime)
|
||||
// leaseTime needs to be in seconds
|
||||
leaseTime := uint64(s.leaseTime / time.Second)
|
||||
|
||||
// NB: GuaranteedUpdate does not perform the store operation unless
|
||||
// something changed between load and store (not including resource
|
||||
|
Loading…
Reference in New Issue
Block a user