mirror of
https://github.com/kubereboot/kured.git
synced 2026-08-23 21:36:33 +00:00
@@ -173,6 +173,13 @@ func release(lock *daemonsetlock.DaemonSetLock) {
|
||||
|
||||
func drain(nodeID string) {
|
||||
log.Infof("Draining node %s", nodeID)
|
||||
|
||||
if slackHookURL != "" {
|
||||
if err := slack.NotifyDrain(slackHookURL, slackUsername, nodeID); err != nil {
|
||||
log.Warnf("Error notifying slack: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
drainCmd := newCommand("/usr/bin/kubectl", "drain",
|
||||
"--ignore-daemonsets", "--delete-local-data", "--force", nodeID)
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ type body struct {
|
||||
Username string `json:"username,omitempty"`
|
||||
}
|
||||
|
||||
func NotifyReboot(hookURL, username, nodeID string) error {
|
||||
func notify(hookURL, username, message string) error {
|
||||
msg := body{
|
||||
Text: fmt.Sprintf("Rebooting node %s", nodeID),
|
||||
Text: message,
|
||||
Username: username,
|
||||
}
|
||||
|
||||
@@ -40,3 +40,11 @@ func NotifyReboot(hookURL, username, nodeID string) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NotifyDrain(hookURL, username, nodeID string) error {
|
||||
return notify(hookURL, username, fmt.Sprintf("Draining node %s", nodeID))
|
||||
}
|
||||
|
||||
func NotifyReboot(hookURL, username, nodeID string) error {
|
||||
return notify(hookURL, username, fmt.Sprintf("Rebooting node %s", nodeID))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user