-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
List pods to find those relevant for runtime detection instead of cac…
…hing the workload objects (#2325) This PR refactors the runtime detection controllers to avoid `Get` or `List` operation on workload objects (Deployments, StatefulSets and DaemonSets). As a result: * The Odiglet permissions are narrowed. * The cache won't contain workload objects which results in a significant memory consumption improvement (especially in large clusters). This is done by modifying the `insttrumentationconfig` reconciler to list the Pods associated to the reconciled instrumentationConfig. The Odiglet cache is already configured to only include Pods whithin the same node, hence this list operation will only return pods in the same node and in the same ns of the instrumentationConfig. --------- Co-authored-by: Amir Blum <[email protected]>
- Loading branch information
Showing
6 changed files
with
51 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package runtime_details | ||
|
||
import ( | ||
"github.com/odigos-io/odigos/k8sutils/pkg/workload" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func getPodWorkloadObject(pod *corev1.Pod) (*workload.PodWorkload, error) { | ||
for _, owner := range pod.OwnerReferences { | ||
workloadName, workloadKind, err := workload.GetWorkloadFromOwnerReference(owner) | ||
if err != nil { | ||
return nil, workload.IgnoreErrorKindNotSupported(err) | ||
} | ||
|
||
return &workload.PodWorkload{ | ||
Name: workloadName, | ||
Kind: workloadKind, | ||
Namespace: pod.Namespace, | ||
}, nil | ||
} | ||
|
||
// Pod does not necessarily have to be managed by a controller | ||
return nil, nil | ||
} |
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