Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
099404a0
Commit
099404a0
authored
Oct 11, 2017
by
Robert Rati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the lease endpoint reconciler creation of kubernetes endpoint and lease file ttl
parent
78ada62c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
master.go
pkg/master/master.go
+2
-4
lease.go
pkg/master/reconcilers/lease.go
+5
-2
No files found.
pkg/master/master.go
View file @
099404a0
...
@@ -93,8 +93,6 @@ const (
...
@@ -93,8 +93,6 @@ const (
DefaultEndpointReconcilerInterval
=
10
*
time
.
Second
DefaultEndpointReconcilerInterval
=
10
*
time
.
Second
// DefaultEndpointReconcilerTTL is the default TTL timeout for the storage layer
// DefaultEndpointReconcilerTTL is the default TTL timeout for the storage layer
DefaultEndpointReconcilerTTL
=
15
*
time
.
Second
DefaultEndpointReconcilerTTL
=
15
*
time
.
Second
// DefaultStorageEndpoint is the default storage endpoint for the lease controller
DefaultStorageEndpoint
=
"kube-apiserver-endpoint"
)
)
type
ExtraConfig
struct
{
type
ExtraConfig
struct
{
...
@@ -206,7 +204,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
...
@@ -206,7 +204,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Fatalf
(
"Error creating storage factory: %v"
,
err
)
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
{
if
err
!=
nil
{
glog
.
Fatalf
(
"Error getting storage config: %v"
,
err
)
glog
.
Fatalf
(
"Error getting storage config: %v"
,
err
)
}
}
...
@@ -214,7 +212,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
...
@@ -214,7 +212,7 @@ func (c *Config) createLeaseReconciler() reconcilers.EndpointReconciler {
StorageConfig
:
endpointConfig
,
StorageConfig
:
endpointConfig
,
Decorator
:
generic
.
UndecoratedStorage
,
Decorator
:
generic
.
UndecoratedStorage
,
DeleteCollectionWorkers
:
0
,
DeleteCollectionWorkers
:
0
,
ResourcePrefix
:
c
.
ExtraConfig
.
StorageFactory
.
ResourcePrefix
(
kapi
.
Resource
(
DefaultStorageEndpoint
)),
ResourcePrefix
:
c
.
ExtraConfig
.
StorageFactory
.
ResourcePrefix
(
kapi
.
Resource
(
"endpoints"
)),
})
})
endpointRegistry
:=
endpoint
.
NewRegistry
(
endpointsStorage
)
endpointRegistry
:=
endpoint
.
NewRegistry
(
endpointsStorage
)
masterLeases
:=
reconcilers
.
NewLeases
(
leaseStorage
,
"/masterleases/"
,
ttl
)
masterLeases
:=
reconcilers
.
NewLeases
(
leaseStorage
,
"/masterleases/"
,
ttl
)
...
...
pkg/master/reconcilers/lease.go
View file @
099404a0
...
@@ -24,6 +24,7 @@ https://github.com/openshift/origin/blob/bb340c5dd5ff72718be86fb194dedc0faed7f4c
...
@@ -24,6 +24,7 @@ https://github.com/openshift/origin/blob/bb340c5dd5ff72718be86fb194dedc0faed7f4c
import
(
import
(
"fmt"
"fmt"
"net"
"net"
"path"
"sync"
"sync"
"time"
"time"
...
@@ -77,7 +78,8 @@ func (s *storageLeases) ListLeases() ([]string, error) {
...
@@ -77,7 +78,8 @@ func (s *storageLeases) ListLeases() ([]string, error) {
// UpdateLease resets the TTL on a master IP in storage
// UpdateLease resets the TTL on a master IP in storage
func
(
s
*
storageLeases
)
UpdateLease
(
ip
string
)
error
{
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
// just make sure we've got the right IP set, and then refresh the TTL
existing
:=
input
.
(
*
api
.
Endpoints
)
existing
:=
input
.
(
*
api
.
Endpoints
)
existing
.
Subsets
=
[]
api
.
EndpointSubset
{
existing
.
Subsets
=
[]
api
.
EndpointSubset
{
...
@@ -86,7 +88,8 @@ func (s *storageLeases) UpdateLease(ip string) error {
...
@@ -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
// NB: GuaranteedUpdate does not perform the store operation unless
// something changed between load and store (not including resource
// something changed between load and store (not including resource
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment