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

fix: fix removeImage metric logic #2934

Conversation

KevinBetterQ
Copy link
Contributor

Signed-off-by: KevinBetterQ 1093850932@qq.com

Ⅰ. Describe what this PR did

fixing the statistical logic of ImageActionsCounter metric when removing image

Ⅱ. Does this pull request fix one issue?

fixes #2923

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

added

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Signed-off-by: KevinBetterQ <1093850932@qq.com>
@codecov
Copy link

codecov bot commented Jun 27, 2019

Codecov Report

Merging #2934 into master will increase coverage by 1.32%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2934      +/-   ##
==========================================
+ Coverage   66.78%   68.11%   +1.32%     
==========================================
  Files         289      291       +2     
  Lines       18299    18331      +32     
==========================================
+ Hits        12221    12486     +265     
+ Misses       4645     4383     -262     
- Partials     1433     1462      +29
Flag Coverage Δ
#criv1alpha2_test 34.81% <0%> (?)
#integration_test_0 36.07% <50%> (-0.03%) ⬇️
#integration_test_1 35.51% <50%> (ø) ⬆️
#integration_test_2 36.03% <50%> (-0.01%) ⬇️
#integration_test_3 35.59% <50%> (-0.01%) ⬇️
#node_e2e_test 34.17% <0%> (-0.05%) ⬇️
#unittest 27.98% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
apis/server/image_bridge.go 77.86% <50%> (-0.6%) ⬇️
apis/server/utils.go 71.15% <0%> (-3.85%) ⬇️
cri/ocicni/netns.go 58.1% <0%> (-2.71%) ⬇️
daemon/mgr/spec_apparmor_linux.go 20% <0%> (ø)
daemon/mgr/spec_seccomp_linux.go 71.42% <0%> (ø)
daemon/mgr/container_types.go 71.32% <0%> (+1.47%) ⬆️
daemon/containerio/io.go 72.81% <0%> (+1.94%) ⬆️
cri/v1alpha2/cri_utils.go 89.57% <0%> (+2.7%) ⬆️
daemon/mgr/spec_linux.go 79.37% <0%> (+2.79%) ⬆️
cri/ocicni/cni_manager.go 62.26% <0%> (+2.83%) ⬆️
... and 10 more

@ZYecho
Copy link
Contributor

ZYecho commented Jul 13, 2019

LGTM, @KevinBetterQ could you make sure is this feature still be wanted?

@KevinBetterQ
Copy link
Contributor Author

LGTM, @KevinBetterQ could you make sure is this feature still be wanted?

For status monitoring, it is indeed necessary

@@ -131,7 +131,6 @@ func (s *Server) removeImage(ctx context.Context, rw http.ResponseWriter, req *h

label := util_metrics.ActionDeleteLabel
defer func(start time.Time) {
metrics.ImageActionsCounter.WithLabelValues(label).Inc()
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could judge the return err here to decide how to handle the counter? if err was not found, not add it?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's more clear I think

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rudyfly rudyfly requested a review from Novicei July 7, 2022 11:45
@Novicei
Copy link
Collaborator

Novicei commented Jul 12, 2022

Hi, thank you very much for your submission. I probably understand your logic, which means that the status monitoring in the original defer may lead to unnecessary statistics of the number of actions, because it may not be returned when the image operation is performed. But I think the logic is understandable, when you call the remove operation, it should cause the operation count to be incremented by 1, not what you changed.

@Novicei Novicei closed this Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/log kind/bug This is bug report for project size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] logical problem with the metric 'imageActionCounter' calculation
5 participants