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

koordlet: support block I/O QoS #1144

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

TheBeatles1994
Copy link
Contributor

@TheBeatles1994 TheBeatles1994 commented Mar 27, 2023

Ⅰ. Describe what this PR does

Ⅱ. Does this pull request fix one issue?

fixes #1003

Ⅲ. Describe how to verify it

Ⅳ. Special notes for reviews

V. Checklist

  • I have written necessary docs and comments
  • I have added necessary unit tests and integration tests
  • All checks passed in make test

@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Patch coverage: 47.19% and project coverage change: -1.09 ⚠️

Comparison is base (c88a2d4) 66.10% compared to head (930b61d) 65.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1144      +/-   ##
==========================================
- Coverage   66.10%   65.02%   -1.09%     
==========================================
  Files         303      311       +8     
  Lines       31593    32719    +1126     
==========================================
+ Hits        20885    21274     +389     
- Misses       9179     9884     +705     
- Partials     1529     1561      +32     
Flag Coverage Δ
unittests 65.02% <47.19%> (-1.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/koordlet/metriccache/metric_cache.go 57.03% <0.00%> (-2.06%) ⬇️
pkg/koordlet/metriccache/storage_tables.go 57.14% <ø> (ø)
pkg/koordlet/metrics/common.go 61.22% <0.00%> (-15.70%) ⬇️
pkg/koordlet/metricsadvisor/metrics_advisor.go 86.15% <ø> (ø)
pkg/koordlet/resmanager/resmanager.go 54.54% <0.00%> (-0.84%) ⬇️
pkg/koordlet/statesinformer/states_informer.go 66.66% <0.00%> (-4.13%) ⬇️
pkg/koordlet/util/cgroup_parent_utils.go 93.75% <0.00%> (-6.25%) ⬇️
pkg/koordlet/util/node.go 5.06% <0.00%> (-0.35%) ⬇️
pkg/koordlet/util/system/cgroup_resource.go 80.68% <ø> (ø)
pkg/koordlet/util/system/util_test_tool.go 50.00% <ø> (ø)
... and 8 more

... and 12 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jasonliu747 jasonliu747 changed the title support io qos koordlet: support block I/O QoS Mar 27, 2023
@eahydra eahydra added area/koordlet enhancement New feature or request labels Mar 27, 2023
@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 4 times, most recently from 5d2fe53 to 7ba6beb Compare March 28, 2023 03:22
apis/slo/v1alpha1/nodeslo_types.go Show resolved Hide resolved
pkg/features/koordlet_features.go Show resolved Hide resolved
resmanager *resmanager
executor resourceexecutor.ResourceUpdateExecutor
blkioScanner util.LocalStorageScanner
pvcInformer cache.SharedIndexInformer
Copy link
Contributor

Choose a reason for hiding this comment

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

i remember we have a TODO here about "getting pod volume from local"

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 solve the problem now or leave a todo 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.

I have extended the interface of the states informer by adding the GetVolumeName function, which allows users to retrieve the relevant storage volume name through the PVC name.

strategy := nodeSLO.Spec.ResourceQOSStrategy
// lsr
if strategy.LSRClass != nil && strategy.LSRClass.BlkIOQOS != nil && *strategy.LSRClass.BlkIOQOS.Enable && len(strategy.LSRClass.BlkIOQOS.Blocks) != 0 {
klog.Warningf("%s: configuring blkio of LSRClass is not supported!", BlkIOReconcileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

consider create an warning event to NodeSLO or Pod for bad format config

Copy link
Member

@chzhj chzhj Mar 29, 2023

Choose a reason for hiding this comment

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

create warning event in reconcile may cause too many events?

Copy link
Contributor

Choose a reason for hiding this comment

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

we can add a flow control, like create event at least 10 minutes or more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should add more information to the "NodeSLO" status field, such as warnings and error messages to provide better visibility into the status of the node.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, this is also an option. we can compare before update to avoid too many requests, and warning events can also be used for alarm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, there is no definition for the status of NodeSLO. Shall we create a to-do for it?

pkg/koordlet/resmanager/blkio_reconcile.go Show resolved Hide resolved
pkg/koordlet/util/system/cgroup_resource.go Outdated Show resolved Hide resolved
}

// resourceType sysutil.ResourceType, parentDir string, value string, updateFunc UpdateFunc
func NewBlkIOResourceUpdater(file sysutil.Resource, value string, parentDir string) *CgroupResourceUpdater {
Copy link
Member

Choose a reason for hiding this comment

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

Could we register the cgroup updater of the blkio resource in DefaultCgroupUpdaterFactory to support cgroups-v2 and maintain the blkio updater uniformly? Afterward, the callers can use the blkio updater via DefaultCgroupUpdaterFactory.New(resourceType, cgroupParent, value, auditor).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
)

func NewLocalStorageScanner(interval time.Duration) LocalStorageScanner {
Copy link
Member

@saintube saintube Mar 30, 2023

Choose a reason for hiding this comment

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

could you move the scanner as a plugin of the metric advisor(collector) since it starts a goroutine to collect the node disk info periodically? or we may leave a TODO 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.

done

// GetPodCgroupDirWithKube gets the full pod cgroup parent dir with the podParentDir (excluding kubepods dir).
// @podKubeRelativeDir kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/
// @return kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/
func GetPodCgroupDirWithKube(podParentDir string) string {
Copy link
Member

Choose a reason for hiding this comment

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

Please do not use GetPodCgroupDirWithKube anymore, as it is just removed recently. Instead, use the podMeta.podParentDir directly. See #1129.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 3 times, most recently from 3efd6be to 6bf6915 Compare April 3, 2023 09:10
type NodeLocalStorageInfo struct {
util.LocalStorageInfo
// map is not thread safe. so "concurrent read/write of Map" can cause error.
RWLock sync.RWMutex
Copy link
Member

Choose a reason for hiding this comment

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

is it no longer in use?

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 is used in BlkIOReconcile module (pkg/koordlet/resmanager/blkio_reconcile.go) for getting storage info.

Copy link
Member

Choose a reason for hiding this comment

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

perhaps the mutex lock is unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

klog.Errorf("insert node local storage info error: %v", err)
}

n.started.Store(true)
Copy link
Member

Choose a reason for hiding this comment

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

Some other modules rely on the status started of the CPU Info while sharing the status in collectNodeLocalStorageInfo may corrupt the condition.
e.g. The nodeTopologyInformer requires the CPU Info synced, so it can report the correct CPU topology.
How about moving the collection of the local storage into a new plugin?

Copy link
Contributor Author

@TheBeatles1994 TheBeatles1994 Apr 10, 2023

Choose a reason for hiding this comment

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

Maybe we can rename NodeInfoCollector plugin to NodeCPUInfoCollector plugin, and add a new plugin named NodeStorageInfoCollector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or just remove n.started.Store(true)?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I prefer option one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// deviceName: /dev/sdb
// diskNumber: 253:16
func (b *BlkIOReconcile) getDiskNumberFromDevice(deviceName string) (string, error) {
storageInfo, err := b.resmanager.metricCache.GetNodeLocalStorageInfo(&metriccache.QueryParam{})
Copy link
Member

Choose a reason for hiding this comment

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

perhaps we only need to invoke GetNodeLocalStorageInfo once in a reconcile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// GetCgroupRootBlkIOAbsoluteDir gets the root blkio directory
// @output /sys/fs/cgroup/blkio
func GetCgroupRootBlkIOAbsoluteDir() string {
return path.Join(system.Conf.CgroupRootDir, system.CgroupBlkioDir)
Copy link
Member

Choose a reason for hiding this comment

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

please use filepath.Join instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 2 times, most recently from a38f0ff to e1bb381 Compare April 14, 2023 01:57
// @return like kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice/
// /sys/fs/cgroup/blkio/kubepods.slice/kubepods-burstable.slice/kubepods-pod7712555c_ce62_454a_9e18_9ff0217b8941.slice
func GetPodCgroupBlkIOAbsolutePath(podParentDir string) string {
return path.Join(system.Conf.CgroupRootDir, system.CgroupBlkioDir, podParentDir)
Copy link
Member

@saintube saintube Apr 14, 2023

Choose a reason for hiding this comment

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

A minor issue: Please use filepath.Join and check the other modifications where the path pkg is still adopted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are many other people's codes that also use the path.Join function, do I need to change them all at once?

Copy link
Member

Choose a reason for hiding this comment

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

Not required in this patch. Feel free to do the cleanup in another PR.

@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 2 times, most recently from a530b0f to 63ab8ea Compare April 14, 2023 09:31
@zwzhang0107
Copy link
Contributor

consider using mount info to get the pvc path
https://github.com/kubernetes/cri-api/blob/master/pkg/apis/runtime/v1/api.proto#L1243

@hormes hormes added this to the v1.3 milestone Apr 18, 2023
@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 4 times, most recently from 76a07b7 to 4b480ff Compare April 23, 2023 04:41
@TheBeatles1994 TheBeatles1994 force-pushed the support-io-qos branch 2 times, most recently from 46ff289 to 2264019 Compare April 24, 2023 03:10
Signed-off-by: 惠志 <huizhi.szh@alibaba-inc.com>
@zwzhang0107
Copy link
Contributor

/lgtm

@zwzhang0107
Copy link
Contributor

/approve

@zwzhang0107
Copy link
Contributor

/assign @FillZpp @jasonliu747

@FillZpp
Copy link
Member

FillZpp commented Apr 24, 2023

/approve

Copy link
Member

@jasonliu747 jasonliu747 left a comment

Choose a reason for hiding this comment

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

/lgtm

@koordinator-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FillZpp, jasonliu747, zwzhang0107

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@koordinator-bot koordinator-bot bot merged commit 3f9fb9a into koordinator-sh:main Apr 26, 2023
s.volumeNameMap[util.GetNamespacedName(pvc.Namespace, pvc.Name)] = pvc.Spec.VolumeName
}

func newPVCInformer(client clientset.Interface) cache.SharedIndexInformer {
Copy link
Contributor

Choose a reason for hiding this comment

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

the pvc informer should be restrict on the node, otherwise it may be raise the memory used and the kube-apiserver pressure.

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.

[proposal] support BlkIO QoS
9 participants