Skip to content

Commit

Permalink
util: add defaulting to blkio qos to improve robustness (#2238)
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Zhu <[email protected]>
  • Loading branch information
zqzten authored Nov 5, 2024
1 parent e37628f commit 949aa79
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 10 deletions.
60 changes: 50 additions & 10 deletions pkg/util/sloconfig/nodeslo_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ func DefaultResourceQOSStrategy() *slov1alpha1.ResourceQOSStrategy {
Enable: pointer.Bool(false),
MemoryQOS: *DefaultMemoryQOS(apiext.QoSLSR),
},
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
NetworkQOS: &slov1alpha1.NetworkQOSCfg{
Enable: pointer.Bool(false),
NetworkQOS: *NoneNetworkQOS(),
Expand All @@ -241,6 +245,10 @@ func DefaultResourceQOSStrategy() *slov1alpha1.ResourceQOSStrategy {
Enable: pointer.Bool(false),
MemoryQOS: *DefaultMemoryQOS(apiext.QoSLS),
},
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
NetworkQOS: &slov1alpha1.NetworkQOSCfg{
Enable: pointer.Bool(false),
NetworkQOS: *NoneNetworkQOS(),
Expand All @@ -259,6 +267,10 @@ func DefaultResourceQOSStrategy() *slov1alpha1.ResourceQOSStrategy {
Enable: pointer.Bool(false),
MemoryQOS: *DefaultMemoryQOS(apiext.QoSBE),
},
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
NetworkQOS: &slov1alpha1.NetworkQOSCfg{
Enable: pointer.Bool(false),
NetworkQOS: *NoneNetworkQOS(),
Expand All @@ -277,15 +289,34 @@ func DefaultResourceQOSStrategy() *slov1alpha1.ResourceQOSStrategy {
Enable: pointer.Bool(false),
MemoryQOS: *DefaultMemoryQOS(apiext.QoSSystem),
},
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
NetworkQOS: &slov1alpha1.NetworkQOSCfg{
Enable: pointer.Bool(false),
NetworkQOS: *NoneNetworkQOS(),
},
},
CgroupRoot: &slov1alpha1.ResourceQOS{
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
},
}
}

func NoneResourceQOS(qos apiext.QoSClass) *slov1alpha1.ResourceQOS {
// cgroup root case: only used by blkio qos
if qos == apiext.QoSNone {
return &slov1alpha1.ResourceQOS{
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
}
}
return &slov1alpha1.ResourceQOS{
CPUQOS: &slov1alpha1.CPUQOSCfg{
Enable: pointer.Bool(false),
Expand All @@ -299,6 +330,10 @@ func NoneResourceQOS(qos apiext.QoSClass) *slov1alpha1.ResourceQOS {
Enable: pointer.Bool(false),
MemoryQOS: *NoneMemoryQOS(),
},
BlkIOQOS: &slov1alpha1.BlkIOQOSCfg{
Enable: pointer.Bool(false),
BlkIOQOS: *NoneBlkIOQOS(),
},
NetworkQOS: &slov1alpha1.NetworkQOSCfg{
Enable: pointer.Bool(false),
NetworkQOS: *NoneNetworkQOS(),
Expand Down Expand Up @@ -337,6 +372,20 @@ func NoneMemoryQOS() *slov1alpha1.MemoryQOS {
}
}

func NoneBlkIOQOS() *slov1alpha1.BlkIOQOS {
return &slov1alpha1.BlkIOQOS{}
}

func NoneNetworkQOS() *slov1alpha1.NetworkQOS {
zero := intstr.FromInt32(0)
return &slov1alpha1.NetworkQOS{
IngressRequest: &zero,
IngressLimit: &zero,
EgressRequest: &zero,
EgressLimit: &zero,
}
}

func NoneResourceQOSPolicies() *slov1alpha1.ResourceQOSPolicies {
noneCPUPolicy := slov1alpha1.CPUQOSPolicyGroupIdentity
defaultNetQoSPolicy := slov1alpha1.NETQOSPolicyTC
Expand All @@ -354,6 +403,7 @@ func NoneResourceQOSStrategy() *slov1alpha1.ResourceQOSStrategy {
LSClass: NoneResourceQOS(apiext.QoSLS),
BEClass: NoneResourceQOS(apiext.QoSBE),
SystemClass: NoneResourceQOS(apiext.QoSSystem),
CgroupRoot: NoneResourceQOS(apiext.QoSNone),
}
}

Expand Down Expand Up @@ -385,13 +435,3 @@ func DefaultSystemStrategy() *slov1alpha1.SystemStrategy {
func DefaultExtensions() *slov1alpha1.ExtensionsMap {
return getDefaultExtensionsMap()
}

func NoneNetworkQOS() *slov1alpha1.NetworkQOS {
zero := intstr.FromInt(0)
return &slov1alpha1.NetworkQOS{
IngressRequest: &zero,
IngressLimit: &zero,
EgressRequest: &zero,
EgressLimit: &zero,
}
}
1 change: 1 addition & 0 deletions pkg/util/sloconfig/nodeslo_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func Test_NoneResourceQOSStrategy(t *testing.T) {
LSClass: NoneResourceQOS(apiext.QoSLS),
BEClass: NoneResourceQOS(apiext.QoSBE),
SystemClass: NoneResourceQOS(apiext.QoSSystem),
CgroupRoot: NoneResourceQOS(apiext.QoSNone),
}
got := NoneResourceQOSStrategy()
assert.Equal(t, expect, got)
Expand Down

0 comments on commit 949aa79

Please sign in to comment.