Skip to content
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

[features] Migrate LogCollection feature #484

Merged
merged 6 commits into from
May 12, 2022

Conversation

khewonc
Copy link
Contributor

@khewonc khewonc commented May 9, 2022

What does this PR do?

Migrate LogCollection feature
Add option to GetVolumes to add non-readonly volumes

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Describe your test plan

Write there any instructions and details you may have to test your PR.

@khewonc khewonc requested review from a team as code owners May 9, 2022 02:16
@khewonc khewonc changed the title Migrate LogCollection feature [features] Migrate LogCollection feature May 9, 2022
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: bug, enhancement, refactoring, documentation, tooling

@khewonc khewonc added enhancement New feature or request component/controller labels May 9, 2022
@khewonc khewonc added this to the v1.0.0 milestone May 9, 2022
@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #484 (9c73dfc) into main (7a62cc6) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #484   +/-   ##
=======================================
  Coverage   59.68%   59.68%           
=======================================
  Files           3        3           
  Lines         129      129           
=======================================
  Hits           77       77           
  Misses         40       40           
  Partials       12       12           
Flag Coverage Δ
unittests 59.68% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a62cc6...9c73dfc. Read the comment docs.

Comment on lines 53 to 58
if logCollection.ContainerCollectAll != nil && apiutils.BoolValue(logCollection.ContainerCollectAll) {
f.containerCollectAll = true
}
if apiutils.BoolValue(logCollection.ContainerCollectUsingFiles) {
f.containerCollectUsingFiles = true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if logCollection.ContainerCollectAll != nil && apiutils.BoolValue(logCollection.ContainerCollectAll) {
f.containerCollectAll = true
}
if apiutils.BoolValue(logCollection.ContainerCollectUsingFiles) {
f.containerCollectUsingFiles = true
}
if logCollection.ContainerCollectAll != nil {
// fallback to agent default if not set
f.containerCollectAll = apiutils.BoolValue(logCollection.ContainerCollectAll)
}
f.containerCollectUsingFiles = apiutils.BoolValue(logCollection.ContainerCollectUsingFiles)

does that work?

func (f *logCollectionFeature) ConfigureV1(dda *v1alpha1.DatadogAgent) (reqComp feature.RequiredComponents) {
logCollection := dda.Spec.Features.LogCollection

if logCollection != nil && apiutils.BoolValue(logCollection.Enabled) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if logCollection != nil && apiutils.BoolValue(logCollection.Enabled) {
if apiutils.BoolValue(logCollection.Enabled) {

// ManageNodeAgent allows a feature to configure the Node Agent's corev1.PodTemplateSpec
// It should do nothing if the feature doesn't need to configure it.
func (f *logCollectionFeature) ManageNodeAgent(managers feature.PodTemplateManagers) error {
if f.enable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm good thought; i imagine we'll want to put this one level up, but it's not present yet (in the cluster agent reconciler)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to close the loop on this, we discussed separately but the features are filtered using the RequiredComponents struct a couple levels up. so this isn't needed and it may be possible to get rid of f.enable altogether

func (f *logCollectionFeature) ManageNodeAgent(managers feature.PodTemplateManagers) error {
if f.enable {
// pointerdir volume mount
pointerVol, pointerVolMount := volume.GetVolumes(apicommon.PointerVolumeName, f.tempStoragePath, apicommon.PointerVolumePath, apicommon.PointerVolumeReadOnly)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder whether it's worth having a readOnly const for each mount.. it may become cumbersome for something that isn't likely to change or particularly useful to track (open to debate). as an alternative, maybe we can use generic boolean constants such as

const trueValue = true
const falseValue = false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed separately. Decided on using true/false instead of adding more constants.

// envvars
managers.EnvVar().AddEnvVarToContainer(apicommonv1.CoreAgentContainerName, &corev1.EnvVar{
Name: apicommon.DDLogsEnabled,
Value: strconv.FormatBool(f.enable),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO since it's always true it's ok to be more explicit

@khewonc khewonc merged commit c07038f into main May 12, 2022
@khewonc khewonc deleted the khewonc/logs-migration-feature branch May 12, 2022 02:56
celenechang pushed a commit that referenced this pull request May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants