Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into config-ignored-default
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir committed Jan 10, 2025
2 parents 9bef15d + 04e3894 commit f279bcd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
5 changes: 2 additions & 3 deletions instrumentor/controllers/instrumentationdevice/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/odigos-io/odigos/k8sutils/pkg/conditions"
odigosk8sconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
k8sprofiles "github.com/odigos-io/odigos/k8sutils/pkg/profiles"
k8sutils "github.com/odigos-io/odigos/k8sutils/pkg/utils"
"github.com/odigos-io/odigos/k8sutils/pkg/workload"
appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -126,8 +125,8 @@ func addInstrumentationDeviceToWorkload(ctx context.Context, kubeClient client.C
return err
}

// User input <odigosConfiguration.AllowConcurrentAgents> prefered over the profile configuration
agentsCanRunConcurrently := k8sprofiles.AgentsCanRunConcurrently(odigosConfiguration.Profiles)
// allowConcurrentAgents is false by default unless explicitly set to true in the OdigosConfiguration
agentsCanRunConcurrently := false
if odigosConfiguration.AllowConcurrentAgents != nil {
agentsCanRunConcurrently = *odigosConfiguration.AllowConcurrentAgents
}
Expand Down
11 changes: 9 additions & 2 deletions k8sutils/pkg/profiles/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
type Profile struct {
ProfileName common.ProfileName
ShortDescription string
KubeObject Object // used to read it from the embedded YAML file
Dependencies []common.ProfileName // other profiles that are applied by the current profile
KubeObject Object // used to read it from the embedded YAML file
Dependencies []common.ProfileName // other profiles that are applied by the current profile
ModifyConfigFunc func(*common.OdigosConfiguration) // function to update the configuration based on the profile
}

type Object interface {
Expand All @@ -36,6 +37,12 @@ var (
AllowConcurrentAgents = Profile{
ProfileName: common.ProfileName("allow_concurrent_agents"),
ShortDescription: "This profile allows Odigos to run concurrently with other agents",
ModifyConfigFunc: func(c *common.OdigosConfiguration) {
if c.AllowConcurrentAgents == nil {
allowConcurrentAgents := true
c.AllowConcurrentAgents = &allowConcurrentAgents
}
},
}
FullPayloadCollectionProfile = Profile{
ProfileName: common.ProfileName("full-payload-collection"),
Expand Down
16 changes: 0 additions & 16 deletions k8sutils/pkg/profiles/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@ package profiles

import "github.com/odigos-io/odigos/common"

func AgentsCanRunConcurrently(profiles []common.ProfileName) bool {
for _, profile := range profiles {
if profile == AllowConcurrentAgents.ProfileName {
return true
}

profileDependencies := ProfilesMap[profile].Dependencies
for _, dependencyProfile := range profileDependencies {
if dependencyProfile == AllowConcurrentAgents.ProfileName {
return true
}
}
}
return false
}

func FilterSizeProfiles(profiles []common.ProfileName) common.ProfileName {
// In case multiple size profiles are provided, the first one will be used.
for _, profile := range profiles {
Expand Down
24 changes: 24 additions & 0 deletions scheduler/controllers/odigosconfig/odigosconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/odigos-io/odigos/common/consts"
k8sconsts "github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
"github.com/odigos-io/odigos/k8sutils/pkg/profiles"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -35,6 +36,8 @@ func (r *odigosConfigController) Reconcile(ctx context.Context, _ ctrl.Request)
// make sure the default ignored containers are always present
odigosConfig.IgnoredContainers = mergeIgnoredItemLists(odigosConfig.IgnoredContainers, k8sconsts.DefaultIgnoredContainers)

applyProfilesToOdigosConfig(odigosConfig)

err = r.persistEffectiveConfig(ctx, odigosConfig)
if err != nil {
return ctrl.Result{}, err
Expand Down Expand Up @@ -102,3 +105,24 @@ func (r *odigosConfigController) persistEffectiveConfig(ctx context.Context, eff

return nil
}

func applySingleProfile(profile common.ProfileName, odigosConfig *common.OdigosConfiguration) {
profileConfig, found := profiles.ProfilesMap[profile]
if !found {
return
}

if profileConfig.ModifyConfigFunc != nil {
profileConfig.ModifyConfigFunc(odigosConfig)
}

for _, dependency := range profileConfig.Dependencies {
applySingleProfile(dependency, odigosConfig)
}
}

func applyProfilesToOdigosConfig(odigosConfig *common.OdigosConfiguration) {
for _, profile := range odigosConfig.Profiles {
applySingleProfile(profile, odigosConfig)
}
}

0 comments on commit f279bcd

Please sign in to comment.