Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Cgroupv2: Added CPU, Memory metrics #1376

Merged
AkihiroSuda merged 1 commit intocontainerd:masterfrom
Zyqsempai:add-cgroups-v2-metrics
Jan 21, 2020
Merged

Cgroupv2: Added CPU, Memory metrics #1376
AkihiroSuda merged 1 commit intocontainerd:masterfrom
Zyqsempai:add-cgroups-v2-metrics

Conversation

@Zyqsempai
Copy link
Contributor

Related to containerd/containerd#3726

Vendor updated to the last and stble versions of contqinerd and cgroups
Added cgroupv2 metrics.

Signed-off-by: Boris Popovschi zyqsempai@mail.ru

@k8s-ci-robot
Copy link

Hi @Zyqsempai. Thanks for your PR.

I'm waiting for a containerd 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.

Details

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.

cs.Memory = &runtime.MemoryUsage{
Timestamp: stats.Timestamp.UnixNano(),
WorkingSetBytes: &runtime.UInt64Value{
Value: metrics.Memory.Usage,
Copy link
Member

Choose a reason for hiding this comment

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

needs consideration for inactive_file as in v1 implementation? (I haven't looked into whether v2 inactive_file really corresponds to v1 total_inactive_file)

cc @Random-Liu

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's a good question actually, but it seems like they just removed prefix total from all the metrics in v2.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

/ok-to-test /lgtm

@AkihiroSuda
Copy link
Member

/ok-to-test

cs.Cpu = &runtime.CpuUsage{
Timestamp: stats.Timestamp.UnixNano(),
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: metrics.CPU.Usage.Total},
switch s.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use switch metric := s.(type) { and then you dont need the type assertion below.

if err != nil {
return nil, errors.Wrap(err, "failed to extract container metrics")
}
metrics := s.(*v1.Metrics)
Copy link
Contributor

Choose a reason for hiding this comment

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

@Random-Liu - This would have previously panic'd if this wasnt the return type. Should we have a default case where we return error or maintain this?

Copy link
Member

Choose a reason for hiding this comment

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

The CRI expects failure on conversion errors. We should not panic... we should return the error.

Copy link
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

I like it! Minor questions

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

LGTM, but please consider squashing commits

@Zyqsempai Zyqsempai force-pushed the add-cgroups-v2-metrics branch from 292737b to e67cc43 Compare January 15, 2020 09:31
Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

See comment on vndr update.

@Zyqsempai Zyqsempai force-pushed the add-cgroups-v2-metrics branch from e67cc43 to b515c20 Compare January 15, 2020 20:55
@AkihiroSuda
Copy link
Member

/test pull-cri-containerd-verify

1 similar comment
@AkihiroSuda
Copy link
Member

/test pull-cri-containerd-verify

@mikebrow
Copy link
Member

/test pull-cri-containerd-verify

@AkihiroSuda
Copy link
Member

vendor failing

I0116 14:33:35.417] These files were modified:
I0116 14:33:35.418] 
I0116 14:33:35.418]  M vendor/github.com/Microsoft/hcsshim/container.go
I0116 14:33:35.418]  M vendor/github.com/Microsoft/hcsshim/go.mod
I0116 14:33:35.418]  M vendor/github.com/Microsoft/hcsshim/hcn/hcn.go
I0116 14:33:35.418]  M vendor/github.com/Microsoft/hcsshim/hcn/hcnglobals.go
I0116 14:33:35.418]  M vendor/github.com/Microsoft/hcsshim/hcn/hcnloadbalancer.go
I0116 14:33:35.419]  M vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
I0116 14:33:35.419]  M vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
I0116 14:33:35.419]  M vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
I0116 14:33:35.419]  M vendor/github.com/Microsoft/hcsshim/internal/vmcompute/vmcompute.go
I0116 14:33:35.419]  M vendor/github.com/Microsoft/hcsshim/osversion/windowsbuilds.go
I0116 14:33:35.419] 
W0116 14:33:35.430] make: *** [Makefile:71: check-vendor] Error 1

Signed-off-by: Boris Popovschi <zyqsempai@mail.ru>
@Zyqsempai Zyqsempai force-pushed the add-cgroups-v2-metrics branch from b515c20 to 6b8846c Compare January 17, 2020 09:55
@AkihiroSuda
Copy link
Member

/test pull-cri-containerd-node-e2e

@jterry75
Copy link
Contributor

Green!

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

LGTM but a typo

}
}
default:
return &cs, errors.New(fmt.Sprintf("unxpected metrics type: %v", metrics))
Copy link
Member

Choose a reason for hiding this comment

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

typo: "unxpected"

Also, you can use errors.Errorf here.

@AkihiroSuda
Copy link
Member

merging, typo is negligible

@AkihiroSuda AkihiroSuda merged commit 5e5960f into containerd:master Jan 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants