-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clusteragent/clusterchecks] Add isolate check command to datadog clu…
…ster agent (#21049) * Add isolate check command to dca * Clean up isolate command return object * Separate isolate logic into new file * Add changelog * Remove unused log param * fixup! Remove unused log param * Update release note * Add container integrations as codeowner for cli/subcommands/clusterchecks * Simplify for loop logic return early * Remove error return from IsolateCheck call * Rename IsolateResponse.Result to IsIsolated for consistency * Remove reference to checkID in command use text * Add tests for isolation error states * Add more documentation for IsolateCheck logic * fixup! Add more documentation for IsolateCheck logic * fixup! Add container integrations as codeowner for cli/subcommands/clusterchecks * Trigger gitlab sync
- Loading branch information
Showing
12 changed files
with
422 additions
and
5 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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,62 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
//go:build clusterchecks | ||
|
||
package clusterchecks | ||
|
||
import "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types" | ||
|
||
func (d *dispatcher) isolateCheck(isolateCheckID string) types.IsolateResponse { | ||
// Update stats prior to starting isolate to ensure all checks are accounted for | ||
d.updateRunnersStats() | ||
currentDistribution := d.currentDistribution() | ||
|
||
// If there is only one runner, we cannot isolate the check | ||
if len(currentDistribution.runnerWorkers()) == 1 { | ||
return types.IsolateResponse{ | ||
CheckID: isolateCheckID, | ||
CheckNode: "", | ||
IsIsolated: false, | ||
Reason: "No other runners available", | ||
} | ||
} | ||
|
||
isolateNode := currentDistribution.runnerForCheck(isolateCheckID) | ||
if isolateNode == "" { | ||
return types.IsolateResponse{ | ||
CheckID: isolateCheckID, | ||
CheckNode: "", | ||
IsIsolated: false, | ||
Reason: "Unable to find check", | ||
} | ||
} | ||
|
||
proposedDistribution := newChecksDistribution(currentDistribution.runnerWorkers()) | ||
|
||
for _, checkID := range currentDistribution.checksSortedByWorkersNeeded() { | ||
if checkID == isolateCheckID { | ||
// Keep the check to be isolated on its current runner | ||
continue | ||
} | ||
|
||
workersNeededForCheck := currentDistribution.workersNeededForCheck(checkID) | ||
runnerForCheck := currentDistribution.runnerForCheck(checkID) | ||
|
||
proposedDistribution.addToLeastBusy( | ||
checkID, | ||
workersNeededForCheck, | ||
runnerForCheck, | ||
isolateNode, | ||
) | ||
} | ||
|
||
d.applyDistribution(proposedDistribution, currentDistribution) | ||
return types.IsolateResponse{ | ||
CheckID: isolateCheckID, | ||
CheckNode: isolateNode, | ||
IsIsolated: true, | ||
} | ||
} |
Oops, something went wrong.