-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a status condition to ic for instrumentation details (#2408)
This adds a condition that describes why the workload is instrumented (which kind of source), along with it's name for better troubleshooting and traceability. Examples:  The function in k8sutils now returns more info about the decision, which can later be used for odigos describe and possibly be also persisted with ic delete if we ever need finalizers for it.
- Loading branch information
Showing
13 changed files
with
288 additions
and
51 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
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
30 changes: 30 additions & 0 deletions
30
instrumentor/controllers/startlangdetection/conditionutils.go
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 startlangdetection | ||
|
||
import ( | ||
"slices" | ||
|
||
odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// Checks if the conditions array in the status is currently sorted by logical order | ||
// this can be used to check if sorting is needed. | ||
func areConditionsLogicallySorted(conditions []metav1.Condition) bool { | ||
var lastTypeLogicalOrder int = 0 | ||
for _, condition := range conditions { | ||
currentLogicalOrder := odigosv1.StatusConditionTypeLogicalOrder(condition.Type) | ||
if currentLogicalOrder <= lastTypeLogicalOrder { | ||
return false | ||
} | ||
lastTypeLogicalOrder = currentLogicalOrder | ||
} | ||
return true | ||
} | ||
|
||
// giving the input conditions array, this function will return a new array with the conditions sorted by logical order | ||
func sortIcConditionsByLogicalOrder(conditions []metav1.Condition) []metav1.Condition { | ||
slices.SortFunc(conditions, func(i, j metav1.Condition) int { | ||
return odigosv1.StatusConditionTypeLogicalOrder(i.Type) - odigosv1.StatusConditionTypeLogicalOrder(j.Type) | ||
}) | ||
return conditions | ||
} |
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
Oops, something went wrong.