mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 03:46:45 +00:00
probe: update capture node and add cordon toggle
This commit is contained in:
@@ -22,6 +22,7 @@ const (
|
||||
ScaleUp = report.KubernetesScaleUp
|
||||
ScaleDown = report.KubernetesScaleDown
|
||||
CordonNode = report.KubernetesCordonNode
|
||||
UncordonNode = report.KubernetesUncordonNode
|
||||
)
|
||||
|
||||
// GroupName and version used by CRDs
|
||||
@@ -475,10 +476,14 @@ func (r *Reporter) CaptureJob(f func(xfer.Request, string, string) xfer.Response
|
||||
}
|
||||
}
|
||||
|
||||
// CaptureCordonNode is exported for testing
|
||||
func (r *Reporter) CaptureCordonNode(f func(xfer.Request, string) xfer.Response) func(xfer.Request) xfer.Response {
|
||||
// CaptureNode is exported for testing
|
||||
func (r *Reporter) CaptureNode(f func(xfer.Request, string) xfer.Response) func(xfer.Request) xfer.Response {
|
||||
return func(req xfer.Request) xfer.Response {
|
||||
return f(req, r.nodeName)
|
||||
nodeID, ok := report.ParseHostNodeID(req.NodeID)
|
||||
if !ok {
|
||||
return xfer.ResponseErrorf("Invalid ID: %s", req.NodeID)
|
||||
}
|
||||
return f(req, nodeID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,7 +512,8 @@ func (r *Reporter) registerControls() {
|
||||
DeleteVolumeSnapshot: r.CaptureVolumeSnapshot(r.deleteVolumeSnapshot),
|
||||
ScaleUp: r.CaptureDeployment(r.ScaleUp),
|
||||
ScaleDown: r.CaptureDeployment(r.ScaleDown),
|
||||
CordonNode: r.CaptureCordonNode(r.CordonNode),
|
||||
CordonNode: r.CaptureNode(r.CordonNode),
|
||||
UncordonNode: r.CaptureNode(r.CordonNode),
|
||||
}
|
||||
r.handlerRegistry.Batch(nil, controls)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
/*
|
||||
Copied from
|
||||
|
||||
https://github.com/kubernetes/kubectl/blob/master/pkg/drain/cordon.go
|
||||
|
||||
at commit f9460c53339c4bb60b20031e3c6125e8bac679e2 to add node cordon feature.
|
||||
*/
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
|
||||
@@ -181,6 +181,21 @@ var (
|
||||
Icon: "fa fa-file-text",
|
||||
Rank: 2,
|
||||
}
|
||||
|
||||
CordonControl = []report.Control{
|
||||
{
|
||||
ID: CordonNode,
|
||||
Human: "Cordon",
|
||||
Icon: "fa fa-toggle-off",
|
||||
Rank: 1,
|
||||
},
|
||||
{
|
||||
ID: UncordonNode,
|
||||
Human: "Uncordon",
|
||||
Icon: "fa fa-toggle-on",
|
||||
Rank: 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Reporter generate Reports containing Container and ContainerImage topologies
|
||||
@@ -287,6 +302,10 @@ func (r *Tagger) Tag(rpt report.Report) (report.Report, error) {
|
||||
|
||||
rpt.Container.Nodes[id] = n.WithParent(report.Pod, report.MakePodNodeID(uid))
|
||||
}
|
||||
for id, n := range rpt.Host.Nodes {
|
||||
controls := append(n.ActiveControls(), CordonNode, UncordonNode)
|
||||
rpt.Host.Nodes[id] = n.WithLatestActiveControls(controls...)
|
||||
}
|
||||
return rpt, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ const (
|
||||
KubernetesDeleteVolumeSnapshot = "kubernetes_delete_volume_snapshot"
|
||||
KubernetesDescribe = "kubernetes_describe"
|
||||
KubernetesCordonNode = "kubernetes_cordon_node"
|
||||
KubernetesUncordonNode = "kubernetes_uncordon_node"
|
||||
// probe/awsecs
|
||||
ECSCluster = "ecs_cluster"
|
||||
ECSCreatedAt = "ecs_created_at"
|
||||
|
||||
Reference in New Issue
Block a user