-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allows disable pod events enrichment with deployment name #28521
Changes from 4 commits
ef84c87
859f9aa
fb2e693
b8f5d63
9556f83
3a1a5ac
9c023bb
357bb69
821f06f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,11 +29,12 @@ import ( | |
) | ||
|
||
type pod struct { | ||
store cache.Store | ||
client k8s.Interface | ||
node MetaGen | ||
namespace MetaGen | ||
resource *Resource | ||
store cache.Store | ||
client k8s.Interface | ||
node MetaGen | ||
namespace MetaGen | ||
resource *Resource | ||
addDeployment bool | ||
} | ||
|
||
// NewPodMetadataGenerator creates a metagen for pod resources | ||
|
@@ -42,13 +43,19 @@ func NewPodMetadataGenerator( | |
pods cache.Store, | ||
client k8s.Interface, | ||
node MetaGen, | ||
namespace MetaGen) MetaGen { | ||
namespace MetaGen, | ||
metaCfg *AddResourceMetadataConfig) MetaGen { | ||
addDeploymentMeta := true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In combination with the previous suggestion you might can move this one layer up to |
||
if metaCfg != nil { | ||
addDeploymentMeta = metaCfg.Deployment | ||
} | ||
return &pod{ | ||
resource: NewResourceMetadataGenerator(cfg, client), | ||
store: pods, | ||
node: node, | ||
namespace: namespace, | ||
client: client, | ||
resource: NewResourceMetadataGenerator(cfg, client), | ||
store: pods, | ||
node: node, | ||
namespace: namespace, | ||
client: client, | ||
addDeployment: addDeploymentMeta, | ||
} | ||
} | ||
|
||
|
@@ -84,11 +91,13 @@ func (p *pod) GenerateK8s(obj kubernetes.Resource, opts ...FieldOptions) common. | |
out := p.resource.GenerateK8s("pod", obj, opts...) | ||
|
||
// check if Pod is handled by a ReplicaSet which is controlled by a Deployment | ||
rsName, _ := out.GetValue("replicaset.name") | ||
if rsName, ok := rsName.(string); ok { | ||
dep := p.getRSDeployment(rsName, po.GetNamespace()) | ||
if dep != "" { | ||
out.Put("deployment.name", dep) | ||
if p.addDeployment { | ||
rsName, _ := out.GetValue("replicaset.name") | ||
if rsName, ok := rsName.(string); ok { | ||
dep := p.getRSDeployment(rsName, po.GetNamespace()) | ||
if dep != "" { | ||
out.Put("deployment.name", dep) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -107,7 +116,7 @@ func (p *pod) GenerateK8s(obj kubernetes.Resource, opts ...FieldOptions) common. | |
meta := p.namespace.GenerateFromName(po.GetNamespace()) | ||
if meta != nil { | ||
// Use this in 8.0 | ||
//out.Put("namespace", meta["namespace"]) | ||
// out.Put("namespace", meta["namespace"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MichaelKatsoulis this line looks like a leftover from other PR, shall we open a fixup PR to remove it? |
||
out.DeepUpdate(meta) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ func NewResourceMetadataEnricher( | |
cfg, _ := common.NewConfigFrom(&metaConfig) | ||
|
||
metaGen := metadata.NewResourceMetadataGenerator(cfg, watcher.Client()) | ||
podMetaGen := metadata.NewPodMetadataGenerator(cfg, nil, watcher.Client(), nil, nil) | ||
podMetaGen := metadata.NewPodMetadataGenerator(cfg, nil, watcher.Client(), nil, nil, &metadata.AddResourceMetadataConfig{Deployment: true}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we leverage the value from the configuration here instead of setting always to true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol I was simply following same like the other arguments and meantime keep the same behavior like previous version. so current configuration doesn't have a section for namespace nor node, wondering if deployment should be added first there.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the later commit I still passed a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, I see! I think we can leave it as is for now and try to address it in general in another round. I will open an issue for this :). |
||
serviceMetaGen := metadata.NewServiceMetadataGenerator(cfg, nil, nil, watcher.Client()) | ||
enricher := buildMetadataEnricher(watcher, | ||
// update | ||
|
@@ -228,7 +228,7 @@ func NewContainerMetadataEnricher( | |
|
||
cfg, _ := common.NewConfigFrom(&metaConfig) | ||
|
||
metaGen := metadata.NewPodMetadataGenerator(cfg, nil, watcher.Client(), nil, nil) | ||
metaGen := metadata.NewPodMetadataGenerator(cfg, nil, watcher.Client(), nil, nil, &metadata.AddResourceMetadataConfig{Deployment: true}) | ||
enricher := buildMetadataEnricher(watcher, | ||
// update | ||
func(m map[string]common.MapStr, r kubernetes.Resource) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just pass the value of
metaConf.Deployment
as bool?