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
10204f8b
Commit
10204f8b
authored
Mar 17, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #23167 from cjcullen/sshcheck
Auto commit by PR queue bot
parents
d4912eaf
5f3929f7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
master.go
pkg/master/master.go
+4
-0
tunneler.go
pkg/master/tunneler.go
+11
-0
tunneler_test.go
pkg/master/tunneler_test.go
+1
-0
No files found.
pkg/master/master.go
View file @
10204f8b
...
@@ -858,5 +858,9 @@ func (m *Master) IsTunnelSyncHealthy(req *http.Request) error {
...
@@ -858,5 +858,9 @@ func (m *Master) IsTunnelSyncHealthy(req *http.Request) error {
if
lag
>
600
{
if
lag
>
600
{
return
fmt
.
Errorf
(
"Tunnel sync is taking to long: %d"
,
lag
)
return
fmt
.
Errorf
(
"Tunnel sync is taking to long: %d"
,
lag
)
}
}
sshKeyLag
:=
m
.
tunneler
.
SecondsSinceSSHKeySync
()
if
sshKeyLag
>
600
{
return
fmt
.
Errorf
(
"SSHKey sync is taking to long: %d"
,
sshKeyLag
)
}
return
nil
return
nil
}
}
pkg/master/tunneler.go
View file @
10204f8b
...
@@ -41,6 +41,7 @@ type Tunneler interface {
...
@@ -41,6 +41,7 @@ type Tunneler interface {
Stop
()
Stop
()
Dial
(
net
,
addr
string
)
(
net
.
Conn
,
error
)
Dial
(
net
,
addr
string
)
(
net
.
Conn
,
error
)
SecondsSinceSync
()
int64
SecondsSinceSync
()
int64
SecondsSinceSSHKeySync
()
int64
}
}
type
SSHTunneler
struct
{
type
SSHTunneler
struct
{
...
@@ -51,6 +52,7 @@ type SSHTunneler struct {
...
@@ -51,6 +52,7 @@ type SSHTunneler struct {
tunnels
*
ssh
.
SSHTunnelList
tunnels
*
ssh
.
SSHTunnelList
lastSync
int64
// Seconds since Epoch
lastSync
int64
// Seconds since Epoch
lastSSHKeySync
int64
// Seconds since Epoch
lastSyncMetric
prometheus
.
GaugeFunc
lastSyncMetric
prometheus
.
GaugeFunc
clock
util
.
Clock
clock
util
.
Clock
...
@@ -101,6 +103,7 @@ func (c *SSHTunneler) Run(getAddresses AddressFunc) {
...
@@ -101,6 +103,7 @@ func (c *SSHTunneler) Run(getAddresses AddressFunc) {
c
.
tunnels
=
ssh
.
NewSSHTunnelList
(
c
.
SSHUser
,
c
.
SSHKeyfile
,
c
.
HealthCheckURL
,
c
.
stopChan
)
c
.
tunnels
=
ssh
.
NewSSHTunnelList
(
c
.
SSHUser
,
c
.
SSHKeyfile
,
c
.
HealthCheckURL
,
c
.
stopChan
)
// Sync loop to ensure that the SSH key has been installed.
// Sync loop to ensure that the SSH key has been installed.
c
.
lastSSHKeySync
=
c
.
clock
.
Now
()
.
Unix
()
c
.
installSSHKeySyncLoop
(
c
.
SSHUser
,
publicKeyFile
)
c
.
installSSHKeySyncLoop
(
c
.
SSHUser
,
publicKeyFile
)
// Sync tunnelList w/ nodes.
// Sync tunnelList w/ nodes.
c
.
lastSync
=
c
.
clock
.
Now
()
.
Unix
()
c
.
lastSync
=
c
.
clock
.
Now
()
.
Unix
()
...
@@ -125,6 +128,12 @@ func (c *SSHTunneler) SecondsSinceSync() int64 {
...
@@ -125,6 +128,12 @@ func (c *SSHTunneler) SecondsSinceSync() int64 {
return
now
-
then
return
now
-
then
}
}
func
(
c
*
SSHTunneler
)
SecondsSinceSSHKeySync
()
int64
{
now
:=
c
.
clock
.
Now
()
.
Unix
()
then
:=
atomic
.
LoadInt64
(
&
c
.
lastSSHKeySync
)
return
now
-
then
}
func
(
c
*
SSHTunneler
)
installSSHKeySyncLoop
(
user
,
publicKeyfile
string
)
{
func
(
c
*
SSHTunneler
)
installSSHKeySyncLoop
(
user
,
publicKeyfile
string
)
{
go
wait
.
Until
(
func
()
{
go
wait
.
Until
(
func
()
{
if
c
.
InstallSSHKey
==
nil
{
if
c
.
InstallSSHKey
==
nil
{
...
@@ -143,7 +152,9 @@ func (c *SSHTunneler) installSSHKeySyncLoop(user, publicKeyfile string) {
...
@@ -143,7 +152,9 @@ func (c *SSHTunneler) installSSHKeySyncLoop(user, publicKeyfile string) {
}
}
if
err
:=
c
.
InstallSSHKey
(
user
,
keyData
);
err
!=
nil
{
if
err
:=
c
.
InstallSSHKey
(
user
,
keyData
);
err
!=
nil
{
glog
.
Errorf
(
"Failed to install ssh key: %v"
,
err
)
glog
.
Errorf
(
"Failed to install ssh key: %v"
,
err
)
return
}
}
atomic
.
StoreInt64
(
&
c
.
lastSSHKeySync
,
c
.
clock
.
Now
()
.
Unix
())
},
5
*
time
.
Minute
,
c
.
stopChan
)
},
5
*
time
.
Minute
,
c
.
stopChan
)
}
}
...
...
pkg/master/tunneler_test.go
View file @
10204f8b
...
@@ -76,6 +76,7 @@ func TestIsTunnelSyncHealthy(t *testing.T) {
...
@@ -76,6 +76,7 @@ func TestIsTunnelSyncHealthy(t *testing.T) {
// Pass case: 540 second lag
// Pass case: 540 second lag
tunneler
.
lastSync
=
time
.
Date
(
2015
,
time
.
January
,
1
,
1
,
1
,
1
,
1
,
time
.
UTC
)
.
Unix
()
tunneler
.
lastSync
=
time
.
Date
(
2015
,
time
.
January
,
1
,
1
,
1
,
1
,
1
,
time
.
UTC
)
.
Unix
()
tunneler
.
lastSSHKeySync
=
time
.
Date
(
2015
,
time
.
January
,
1
,
1
,
1
,
1
,
1
,
time
.
UTC
)
.
Unix
()
tunneler
.
clock
=
util
.
NewFakeClock
(
time
.
Date
(
2015
,
time
.
January
,
1
,
1
,
9
,
1
,
1
,
time
.
UTC
))
tunneler
.
clock
=
util
.
NewFakeClock
(
time
.
Date
(
2015
,
time
.
January
,
1
,
1
,
9
,
1
,
1
,
time
.
UTC
))
err
:=
master
.
IsTunnelSyncHealthy
(
nil
)
err
:=
master
.
IsTunnelSyncHealthy
(
nil
)
assert
.
NoError
(
err
,
"IsTunnelSyncHealthy() should not have returned an error."
)
assert
.
NoError
(
err
,
"IsTunnelSyncHealthy() should not have returned an error."
)
...
...
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