-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unmount-volume check. Add agent log file. Fix command.
- Loading branch information
Showing
7 changed files
with
133 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package unmountvolume | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/adyatlov/bun" | ||
) | ||
|
||
func init() { | ||
builder := bun.CheckBuilder{ | ||
Name: "unmount-volume", | ||
Description: "Checks if Mesos agents had problems unmounting local persistent volumes", | ||
ForEachAgent: check, | ||
ForEachPublicAgent: check, | ||
} | ||
builder.BuildAndRegister() | ||
} | ||
|
||
func check(host bun.Host) (ok bool, details interface{}, err error) { | ||
line, n, err := host.FindFirstLine("mesos-agent-log", "Failed to destroy nested containers") | ||
if err != nil { | ||
return | ||
} | ||
if n != 0 { | ||
details = fmt.Sprintf("%v: %v", n, line) | ||
return | ||
} | ||
ok = true | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package agentlog | ||
|
||
import "github.com/adyatlov/bun" | ||
|
||
func init() { | ||
f := bun.FileType{ | ||
Name: "mesos-agent-log", | ||
ContentType: bun.Journal, | ||
Paths: []string{ | ||
"dcos-mesos-slave.service", | ||
"dcos-mesos-slave-public.service", | ||
}, | ||
Description: "Mesos agent jounrald log", | ||
HostTypes: map[bun.HostType]struct{}{bun.Agent: {}, bun.PublicAgent: {}}, | ||
} | ||
bun.RegisterFileType(f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package bun | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
const str = `“Would you tell me, please, which way I ought to go from here?” | ||
“That depends a good deal on where you want to get to,” said the Cat. | ||
“I don’t much care where-–” said Alice. | ||
“Then it doesn’t matter which way you go,” said the Cat. | ||
“-–so long as I get SOMEWHERE,” Alice added as an explanation. | ||
“Oh, you’re sure to do that,” said the Cat, “if you only walk long enough.”` | ||
|
||
func TestFindFirstLine(t *testing.T) { | ||
r := strings.NewReader(str) | ||
line, n, err := findFirstLine(r, "SOMEWHERE") | ||
const expected = `“-–so long as I get SOMEWHERE,” Alice added as an explanation.` | ||
if line != expected { | ||
t.Errorf("Epected line = \"%v\", observed \"%v\"", expected, line) | ||
} | ||
if n != 5 { | ||
t.Errorf("Expected n = 5, observed n = %v", n) | ||
} | ||
if err != nil { | ||
t.Errorf("Expected err = nil, observed err = %v", err) | ||
} | ||
} |