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

feature: add kernel info to EngineVersion metric #2889

Merged

Conversation

KevinBetterQ
Copy link
Contributor

@KevinBetterQ KevinBetterQ commented Jun 4, 2019

Ⅰ. Describe what this PR did

add kernel info to EngineVersion metric

Ⅱ. Does this pull request fix one issue?

fixes #2881

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

added

Ⅳ. Describe how to verify it

$ pouchd -l tcp://0.0.0.0:4243
$ curl http://127.0.0.1:4243/metrics

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Jun 4, 2019

Codecov Report

Merging #2889 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2889      +/-   ##
==========================================
- Coverage   68.86%   68.86%   -0.01%     
==========================================
  Files         291      291              
  Lines       18249    18249              
==========================================
- Hits        12568    12567       -1     
- Misses       4224     4230       +6     
+ Partials     1457     1452       -5
Flag Coverage Δ
#criv1alpha2_test 38.31% <ø> (-0.05%) ⬇️
#integration_test_0 36.24% <ø> (-0.02%) ⬇️
#integration_test_1 35.66% <ø> (-0.03%) ⬇️
#integration_test_2 36.17% <ø> (-0.28%) ⬇️
#integration_test_3 35.54% <ø> (+0.07%) ⬆️
#node_e2e_test 34.21% <ø> (-0.13%) ⬇️
#unittest 28.03% <ø> (ø) ⬆️
Impacted Files Coverage Δ
apis/metrics/metrics.go 100% <ø> (ø) ⬆️
pkg/streams/utils.go 82.14% <0%> (-7.15%) ⬇️
apis/server/utils.go 71.15% <0%> (-3.85%) ⬇️
ctrd/container.go 54.3% <0%> (ø) ⬆️
cri/v1alpha2/cri.go 69.31% <0%> (+0.25%) ⬆️
daemon/logger/jsonfile/utils.go 73.17% <0%> (+1.62%) ⬆️
cri/ocicni/cni_manager.go 61.11% <0%> (+1.85%) ⬆️
cri/ocicni/netns.go 60.81% <0%> (+2.7%) ⬆️

main.go Show resolved Hide resolved
@CodeJuan
Copy link
Contributor

CodeJuan commented Jun 4, 2019

Could you please add test? There is an example case would be helpful.
Thank you very much.

@KevinBetterQ KevinBetterQ changed the title feature: add kernel info to EngineVersion metric [WIP]feature: add kernel info to EngineVersion metric Jun 4, 2019
@KevinBetterQ KevinBetterQ force-pushed the 2881-add-kernel-info branch from 600d701 to 938058f Compare June 4, 2019 08:58
@pouchrobot pouchrobot added size/M and removed size/S labels Jun 4, 2019
@KevinBetterQ KevinBetterQ changed the title [WIP]feature: add kernel info to EngineVersion metric feature: add kernel info to EngineVersion metric Jun 4, 2019
func (suite *APIEngineVersionMetricsSuite) TestEngineVersionMetrics(c *check.C) {
key := "engine_daemon_engine_info"
hasMetric := HasMetric(c, key)
c.Assert(hasMetric, check.Equals, true)
Copy link
Contributor

@CodeJuan CodeJuan Jun 4, 2019

Choose a reason for hiding this comment

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

I'm afraid hasMetric=true isn't good enough to check all label. How about to assert the value of label kernel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add matching label checks

@@ -38,7 +38,7 @@ var (
ImageActionsTimer = metrics.NewLabelTimer(subsystemPouch, "image_actions", "The number of seconds it takes to process each image action", "action")

// EngineVersion records the version and commit information of the engine process.
EngineVersion = metrics.NewLabelGauge(subsystemPouch, "engine", "The version and commit information of the engine process", "commit")
EngineVersion = metrics.NewLabelGauge(subsystemPouch, "engine", "The version and commit information of the engine process", "gitCommit", "pouchVersion", "kernelVersion")
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of labels is used by monitoring system, so it would be better to stay the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keep "commit", add "version" and "kernel"

@KevinBetterQ KevinBetterQ force-pushed the 2881-add-kernel-info branch 3 times, most recently from 579a86e to 6e4062f Compare June 4, 2019 14:44
@pouchrobot pouchrobot added size/L and removed size/M labels Jun 4, 2019
@CodeJuan
Copy link
Contributor

CodeJuan commented Jun 5, 2019

@KevinBetterQ

PANIC: api_system_metrics_test.go:36: APIEngineVersionMetricsSuite.TestEngineVersionMetrics
... Panic: runtime error: index out of range (PC=0x458D5A)
/home/travis/.gimme/versions/go1.10.4.linux.amd64/src/runtime/panic.go:502
  in gopanic
/home/travis/.gimme/versions/go1.10.4.linux.amd64/src/runtime/panic.go:28
  in panicindex
api_system_metrics_test.go:49
  in APIEngineVersionMetricsSuite.TestEngineVersionMetrics
/home/travis/.gimme/versions/go1.10.4.linux.amd64/src/reflect/value.go:308
  in Value.Call
/home/travis/gopath/src/github.com/alibaba/pouch/vendor/github.com/go-check/check/check.go:772
  in suiteRunner.forkTest.func1
/home/travis/gopath/src/github.com/alibaba/pouch/vendor/github.com/go-check/check/check.go:666
  in suiteRunner.forkCall.func1
/home/travis/.gimme/versions/go1.10.4.linux.amd64/src/runtime/asm_amd64.s:2361
  in goexit
OOPS: 0 passed, 1 PANICKED
--- FAIL: Test (0.04s)

@KevinBetterQ KevinBetterQ force-pushed the 2881-add-kernel-info branch 2 times, most recently from 8a0c924 to 1e229b3 Compare June 5, 2019 01:54

// SetUpTest does common setup in the beginning of each test.
func (suite *APIEngineVersionMetricsSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove the setuptest and teardownsuite because the setupsuite is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, already deleted

Signed-off-by: KevinBetterQ <1093850932@qq.com>
@KevinBetterQ KevinBetterQ force-pushed the 2881-add-kernel-info branch from 1e229b3 to 4052bf8 Compare June 5, 2019 10:00
@pouchrobot pouchrobot added size/M and removed size/L labels Jun 5, 2019

regularVersion := `^.*version="(.*?)".*$`
regular = regexp.MustCompile(regularVersion)
params = regular.FindStringSubmatch(versionMetrics)
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 should check the length here.

Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM with little nit

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.

feature: add kernel info to EngineVersion metric
5 participants