Skip to content

Commit af2bfb1

Browse files
committed
Return validation error when ondemand and m3 are run together #14
1 parent 75b9dd8 commit af2bfb1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/agent/agent.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
var ErrNothingCanBeDone = errors.New("nothing can be done")
18+
var ErrConflictingMode = errors.New("conflicting mode")
1819

1920
func Run() error {
2021
startupLogs()
@@ -30,6 +31,14 @@ func Run() error {
3031
return ErrNothingCanBeDone
3132
}
3233

34+
// Validation: if ondemand and m3 are both enabled, abort here
35+
// Because it causes an issue with capture dir in ondemand.go
36+
if onDemandMode && m3Mode {
37+
logger.Error().Msg("OnDemand and M3 mode can not run together.")
38+
39+
return ErrConflictingMode
40+
}
41+
3342
// TODO: This is for backward compatibility: API mode can run along with on demand and M3.
3443
// Nobody of us knows whether there's any customer using this (on demand + API mode)
3544
// I think we should clean it up eventually.

internal/cli/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Run() {
4444

4545
err = runToCompletionOrSigterm(agent.Run)
4646
if err != nil {
47-
logger.Log("Error: %s", err.Error())
47+
logger.Err(err).Msg("Error encountered")
4848
}
4949

5050
logger.Log("yc-360 script is shutting down...")

0 commit comments

Comments
 (0)