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

Limit scope of logs writable by ipamd container #987

Merged
merged 1 commit into from
Jun 1, 2020

Conversation

anguslees
Copy link
Contributor

Reduce the logs exposed to ipamd container to just
/var/log/aws-routed-eni/ rather than all of /var/log (!)

Also correct documented log file defaults:

  • AWS_VPC_K8S_PLUGIN_LOG_FILE defaults to
    /var/log/aws-routed-eni/plugin.log in scripts/entrypoint.sh#L44

  • AWS_VPC_K8S_CNI_LOG_FILE defaults to
    /host/var/log/aws-routed-eni/ipamd.log in utils/logger/config.go#L47

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@anguslees
Copy link
Contributor Author

(This PR is based on #986 - will be rebased/delayed/etc, depending on what happens with that PR)

Note the default for AWS_VPC_K8S_CNI_LOG_FILE is a bit confusing, since /host/foo assumes a particular container volume setup. Perhaps we should take the opportunity to change the container default, rather than document the existing behaviour. Either way it wouldn't affect anyone using our provided manifests.

@mogren
Copy link
Contributor

mogren commented May 20, 2020

Perhaps we should take the opportunity to change the container default, rather than document the existing behaviour. Either way it wouldn't affect anyone using our provided manifests.

Yes, I totally agree. I would probably prefer to switch to log to stdout by default, since the eks-log-collector.sh script already fetches the pod logs.

@anguslees
Copy link
Contributor Author

I would probably prefer to switch to log to stdout by default

I could also change the code/image to default to stdout, but then point it back to the existing files in the manifest (so no change for people using the manifest).

Let me know what you want me to do here (if anything).

@anguslees anguslees requested a review from mogren May 20, 2020 21:47
@mogren
Copy link
Contributor

mogren commented May 21, 2020

I guess it's safer to just keep the default file for now, and just clean up the mounts. Just needs a rebase to make the changes a bit easier to see. 😄

@anguslees
Copy link
Contributor Author

(Rebased)

Comment on lines +188 to +192
path: "/var/log/aws-routed-eni",
type: "DirectoryOrCreate",
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -172,7 +173,7 @@ local awsnode = {
volumeMounts: [
{mountPath: "/host/opt/cni/bin", name: "cni-bin-dir"},
{mountPath: "/host/etc/cni/net.d", name: "cni-net-dir"},
{mountPath: "/host/var/log", name: "log-dir"},
{mountPath: "/var/log/aws-routed-eni", name: "log-dir"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the /host/ part here so that both log files end up in the same host folder? With this config, ipamd.log will be inside the container only, in /host/var/log/aws-routed-eni/, and the plugin.log file from the host is visible as /var/log/aws-routed-eni/plugin.log. Makes it more clear that it's actually a host mounted directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, reverted this part of the PR to continue using an explicit /host prefix.

Fwiw, I changed the AWS_VPC_K8S_CNI_LOG_FILE and mountPath in this PR to the same value so ipamd.log was still writing to the same real host /var/log/aws-routed-eni/. I was trying to reduce confusion by using identical paths inside and outside the container, but obviously that didn't work 😛

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh... Thanks. Was too confusing for me for sure 😆

Reduce the logs exposed to ipamd container to just
`/var/log/aws-routed-eni/` rather than all of `/var/log`

Also correct documented log file defaults:

- `AWS_VPC_K8S_PLUGIN_LOG_FILE` defaults to
`/var/log/aws-routed-eni/plugin.log` in scripts/entrypoint.sh#L44

- `AWS_VPC_K8S_CNI_LOG_FILE` defaults to
`/host/var/log/aws-routed-eni/ipamd.log` in utils/logger/config.go#L47
Copy link
Contributor

@mogren mogren left a comment

Choose a reason for hiding this comment

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

LGTM!

@mogren mogren merged commit f1f9068 into aws:master Jun 1, 2020
@mogren mogren added this to the v1.7.0 milestone Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants