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
3ee42b46
Commit
3ee42b46
authored
Apr 09, 2015
by
David Oppenheimer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6561 from piosz/events_back
Added events back to Node Controller
parents
27c0828e
c1dd881f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
nodecontroller.go
pkg/cloudprovider/controller/nodecontroller.go
+36
-0
No files found.
pkg/cloudprovider/controller/nodecontroller.go
View file @
3ee42b46
...
...
@@ -26,8 +26,10 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
apierrors
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/golang/glog"
)
...
...
@@ -56,6 +58,7 @@ type NodeController struct {
nodes
[]
string
kubeClient
client
.
Interface
kubeletClient
client
.
KubeletClient
recorder
record
.
EventRecorder
registerRetryCount
int
podEvictionTimeout
time
.
Duration
deletingPodsRateLimiter
util
.
RateLimiter
...
...
@@ -104,6 +107,14 @@ func NewNodeController(
nodeMonitorGracePeriod
time
.
Duration
,
nodeStartupGracePeriod
time
.
Duration
,
nodeMonitorPeriod
time
.
Duration
)
*
NodeController
{
eventBroadcaster
:=
record
.
NewBroadcaster
()
recorder
:=
eventBroadcaster
.
NewRecorder
(
api
.
EventSource
{
Component
:
"controllermanager"
})
if
kubeClient
!=
nil
{
glog
.
Infof
(
"Sending events to api server."
)
eventBroadcaster
.
StartRecordingToSink
(
kubeClient
.
Events
(
""
))
}
else
{
glog
.
Infof
(
"No api server defined - no events will be sent to API server."
)
}
return
&
NodeController
{
cloud
:
cloud
,
matchRE
:
matchRE
,
...
...
@@ -111,6 +122,7 @@ func NewNodeController(
staticResources
:
staticResources
,
kubeClient
:
kubeClient
,
kubeletClient
:
kubeletClient
,
recorder
:
recorder
,
registerRetryCount
:
registerRetryCount
,
podEvictionTimeout
:
podEvictionTimeout
,
deletingPodsRateLimiter
:
deletingPodsRateLimiter
,
...
...
@@ -298,6 +310,19 @@ func (nc *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
return
nodes
,
nil
}
func
(
nc
*
NodeController
)
recordNodeEvent
(
node
*
api
.
Node
,
event
string
)
{
ref
:=
&
api
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
node
.
Name
,
UID
:
types
.
UID
(
node
.
Name
),
Namespace
:
""
,
}
glog
.
V
(
2
)
.
Infof
(
"Recording %s event message for node %s"
,
event
,
node
.
Name
)
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
nc
.
recorder
.
Eventf
(
ref
,
event
,
"Node %s is now %s"
,
node
.
Name
,
event
)
}
// For a given node checks its conditions and tries to update it. Returns grace period to which given node
// is entitled, state of current and last observed Ready Condition, and an error if it ocured.
func
(
nc
*
NodeController
)
tryUpdateNodeStatus
(
node
*
api
.
Node
)
(
time
.
Duration
,
api
.
NodeCondition
,
*
api
.
NodeCondition
,
error
)
{
...
...
@@ -481,6 +506,17 @@ func (nc *NodeController) MonitorNodeStatus() error {
nc
.
deletePods
(
node
.
Name
)
}
}
// Report node events.
if
readyCondition
.
Status
==
api
.
ConditionTrue
&&
lastReadyCondition
.
Status
!=
api
.
ConditionTrue
{
nc
.
recordNodeEvent
(
node
,
"ready"
)
}
if
readyCondition
.
Status
==
api
.
ConditionFalse
&&
lastReadyCondition
.
Status
!=
api
.
ConditionFalse
{
nc
.
recordNodeEvent
(
node
,
"not_ready"
)
}
if
readyCondition
.
Status
==
api
.
ConditionUnknown
&&
lastReadyCondition
.
Status
!=
api
.
ConditionUnknown
{
nc
.
recordNodeEvent
(
node
,
"unknown"
)
}
}
}
return
nil
...
...
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