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

Common flag env metadata whitelist #2921

Merged
merged 10 commits into from
Aug 26, 2021

Conversation

Colstuwjx
Copy link
Contributor

This is a follow-up PR for #2330, after I proposed that PR, I've seen a contributor submitted PR #2857 in order to introduce containerd whitelist env flag.

Now I merged the containerd and docker env whitelist flags, and just a simple common flag: env_metadata_whitelist, the other two are deprecated while this PR merged.

BTW, I'm not sure about the state of the Mesos container, just keep the same interface signature as well :(

@google-cla google-cla bot added the cla: yes label Aug 16, 2021
@k8s-ci-robot
Copy link
Collaborator

Hi @Colstuwjx. Thanks for your PR.

I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -22,7 +22,6 @@ import (
containerlibcontainer "github.com/google/cadvisor/container/libcontainer"
"github.com/google/cadvisor/fs"
info "github.com/google/cadvisor/info/v1"
"github.com/mesos/mesos-go/api/v1/lib"
Copy link
Contributor Author

@Colstuwjx Colstuwjx Aug 16, 2021

Choose a reason for hiding this comment

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

I found CI error after removed this line:

Error: vet: internal/container/mesos/handler_test.go:31:21: undeclared name: mesos
Error: make: *** [Makefile:71: vet] Error 2
Error: Process completed with exit code 2.

But I have no idea about the reason. Does it only use by our tests?

@Colstuwjx
Copy link
Contributor Author

/cc @dashpole @bobbypage

It seems no meaningful message to debug :(

+ echo 'Deleting /tmp/tmp.DrWtfAH0Ul...'
+ [[ 1001 -ne 0 ]]
+ sudo rm -rf /tmp/tmp.DrWtfAH0Ul
make: *** [Makefile:54: docker-test-integration] Error 143
Error: Process completed with exit code 2.

@eero-t
Copy link
Contributor

eero-t commented Aug 16, 2021

It seems no meaningful message to debug :(

This is the actual problem:

 Waiting for cAdvisor to start ...
!! cAdvisor exited unexpectedly with Exit 0
+ EXIT_VALUE=143

As there's no output, this could be early at startup?

@Colstuwjx
Copy link
Contributor Author

As there's no output, this could be early at startup?

I found an issue that the integration tests are still using the deprecated flag docker_env_metadata_whitelist, I've been fixed them.

BTW, the integration tests should output the logs if there are errors, I'll try to propose another PR for fixing it.

@bobbypage
Copy link
Collaborator

This looks good overall. One thing I'm a bit worried about is removing the existing --containerd_env_metadata_whitelist and --docker_env_metadata_whitelist since it is a breaking change for users. Perhaps we can keep these flags around and just set them equal to --env_metadata_whitelist and leave a note that they are deprecated. Then in a release or two we can fully remove them. What do you think?

@Colstuwjx
Copy link
Contributor Author

Thanks @Colstuwjx for the PR. Do you mind splitting the fix to integration test out into a separate PR so we can unblock this and other PRs in parallel? Thanks!

What do you mean? The integration test-related changes in this PR just changed the flag docker_env_metadata_whitelist to env_metadata_whitelist. I think it's reasonable for including these changes inside this PR, otherwise, it would panic our integration tests as we've seen.

Perhaps we can keep these flags around and just set them equal to --env_metadata_whitelist and leave a note that they are deprecated. Then in a release or two we can fully remove them.

I've been considered this path, it's ok to me, I'll add these deprecated flags back soon.

@Colstuwjx
Copy link
Contributor Author

Ping @bobbypage I've been added the deprecated flags back! Please take a review :)

@bobbypage
Copy link
Collaborator

/retest

@@ -27,7 +27,7 @@ import (

type ContainerHandlerFactory interface {
// Create a new ContainerHandler using this factory. CanHandleAndAccept() must have returned true.
NewContainerHandler(name string, inHostNamespace bool) (c ContainerHandler, err error)
NewContainerHandler(name string, metadataEnvs []string, inHostNamespace bool) (c ContainerHandler, err error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we rename metadataEnvs to metadataEnvAllowList or something like that? From the name, it's not clear that we are only going envs in metadataEnvs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@@ -1856,6 +1856,9 @@ func BaseContainerLabels(whiteList []string) func(container *info.ContainerInfo)
set[ContainerLabelPrefix+k] = v
}
}
for k, v := range container.Spec.Envs {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change needed? It seems like this is change in behavior of adding env to Prometheus labels. I'm not sure how this change is relevant here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like this is change in behavior of adding env to Prometheus labels.

Yes. You could get to know the background from PR 2330 #issue-comment . PR #2330 is original to add container whitelisted envs to prom labels, and @dashpole think it'd better to unify the flags, so I proposed this PR righ now!

If you think it'd better to separate these changes, and make the env changes an individual PR, I'm ok with it :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it, thanks for the explanation.

@bobbypage
Copy link
Collaborator

bobbypage commented Aug 20, 2021

Thanks for updating @Colstuwjx. Overall LGTM, minor nit about naming and also question around why we need to change the labels provided in Prometheus (which seems unrelated to refactoring done here). Thanks!

@bobbypage
Copy link
Collaborator

Please rebase to fix conflicts and update as per #2921 (comment). Thanks!

Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
@Colstuwjx Colstuwjx force-pushed the common-flag-env-metadata-whitelist branch from 44619ec to f448e00 Compare August 24, 2021 01:47
Signed-off-by: colstuwjx <colstuwjx@gmail.com>
@Colstuwjx
Copy link
Contributor Author

Hi @bobbypage

Now I revised the PR changes according to your suggestions! Please take a look again.
Once this PR gets merged, I will take another PR for adding container envs as labels in the prom metrics.

@bobbypage
Copy link
Collaborator

LGTM, thanks!

@bobbypage
Copy link
Collaborator

bobbypage commented Aug 25, 2021

/retest

Waiting for pull-cadvisor-e2e to go green

@Colstuwjx
Copy link
Contributor Author

The error logs shown below:

W0825 22:19:17.344] subprocess.CalledProcessError: Command '('kubetest', '--dump=/workspace/_artifacts', '--gcp-service-account=/etc/service-account/service-account.json', '--up', '--down', '--test', '--deployment=node', '--provider=gce', '--cluster=bootstrap-e2e', '--gcp-network=bootstrap-e2e', '--gcp-project=cadvisor-e2e', '--gcp-zone=us-central1-f', '--node-args=--image-config-file=/workspace/test-infra/jobs/e2e_node/image-config.yaml --test-suite=cadvisor', '--node-tests=true', '--test_args=--nodes=1', '--timeout=10m')' returned non-zero exit status 1

I'm not sure if it's related to this PR.

@bobbypage
Copy link
Collaborator

bobbypage commented Aug 26, 2021

I think CI was failing due to lack of go1.17 upgrade (since the pull-cadvisor-e2e runs in prow with k/k). It should be fixed now after #2929

@bobbypage
Copy link
Collaborator

/retest

@bobbypage
Copy link
Collaborator

Thanks, LGTM!

@bobbypage bobbypage merged commit 2dd0cd9 into google:master Aug 26, 2021
@Colstuwjx Colstuwjx deleted the common-flag-env-metadata-whitelist branch August 27, 2021 01:42
@Colstuwjx
Copy link
Contributor Author

I'm not sure why this PR wasn't been squashed, maybe we could let bot merge the PR, just like k8s projects did?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants