Skip to content

Commit

Permalink
feat(qrm): refine healthz
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzzhhb committed Feb 23, 2024
1 parent 0b71607 commit 1d11a30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import (
maputil "k8s.io/kubernetes/pkg/util/maps"

apiconsts "github.com/kubewharf/katalyst-api/pkg/consts"

"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/advisorsvc"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/commonstate"
memconsts "github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/consts"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/dynamicpolicy/memoryadvisor"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/dynamicpolicy/state"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/util"
Expand Down Expand Up @@ -293,7 +293,7 @@ func (p *DynamicPolicy) handleAdvisorDropCache(
err error
)
defer func() {
_ = general.UpdateHealthzStateByError(HealthCheckDropCache, err)
_ = general.UpdateHealthzStateByError(memconsts.HealthCheckDropCache, err)
}()

dropCache := calculationInfo.CalculationResult.Values[string(memoryadvisor.ControlKnobKeyDropCache)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/kubewharf/katalyst-api/pkg/consts"
apiconsts "github.com/kubewharf/katalyst-api/pkg/consts"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/commonstate"
memconsts "github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/consts"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/dynamicpolicy/oom"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/dynamicpolicy/state"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/util"
Expand Down Expand Up @@ -103,7 +104,7 @@ func (p *DynamicPolicy) setExtraControlKnobByConfigs() {
podList []*v1.Pod
)
defer func() {
_ = general.UpdateHealthzStateByError(HealthCheckSetExtraControlKnob, err)
_ = general.UpdateHealthzStateByError(memconsts.HealthCheckSetExtraControlKnob, err)
}()

if p.metaServer == nil {
Expand Down Expand Up @@ -163,7 +164,7 @@ func (p *DynamicPolicy) applyExternalCgroupParams() {

var err error
defer func() {
_ = general.UpdateHealthzStateByError(HealthCheckApplyExternalCGParams, err)
_ = general.UpdateHealthzStateByError(memconsts.HealthCheckApplyExternalCGParams, err)
}()

podEntries := p.state.GetPodResourceEntries()[v1.ResourceMemory]
Expand Down Expand Up @@ -239,13 +240,13 @@ func (p *DynamicPolicy) checkMemorySet() {

defer func() {
if err != nil {
_ = general.UpdateHealthzState(HealthCheckMemSet, general.HealthzCheckStateNotReady, err.Error())
_ = general.UpdateHealthzState(memconsts.HealthCheckMemSet, general.HealthzCheckStateNotReady, err.Error())
} else if invalidMemSet {
_ = general.UpdateHealthzState(HealthCheckMemSet, general.HealthzCheckStateNotReady, "invalid mem set exists")
_ = general.UpdateHealthzState(memconsts.HealthCheckMemSet, general.HealthzCheckStateNotReady, "invalid mem set exists")
} else if memorySetOverlap {
_ = general.UpdateHealthzState(HealthCheckMemSet, general.HealthzCheckStateNotReady, "mem set overlap")
_ = general.UpdateHealthzState(memconsts.HealthCheckMemSet, general.HealthzCheckStateNotReady, "mem set overlap")
} else {
_ = general.UpdateHealthzState(HealthCheckMemSet, general.HealthzCheckStateReady, "")
_ = general.UpdateHealthzState(memconsts.HealthCheckMemSet, general.HealthzCheckStateReady, "")
}
}()

Expand Down Expand Up @@ -378,7 +379,7 @@ func (p *DynamicPolicy) clearResidualState() {
residualSet := make(map[string]bool)

defer func() {
_ = general.UpdateHealthzStateByError(HealthCheckClearResidualState, err)
_ = general.UpdateHealthzStateByError(memconsts.HealthCheckClearResidualState, err)
}()

ctx := context.Background()
Expand Down Expand Up @@ -632,7 +633,7 @@ func (p *DynamicPolicy) syncOOMPriority(conf *coreconfig.Configuration,
)

defer func() {
_ = general.UpdateHealthzStateByError(HealthCheckOOMPriority, errors.NewAggregate(append(updateBPFMapErr, err)))
_ = general.UpdateHealthzStateByError(memconsts.HealthCheckOOMPriority, errors.NewAggregate(append(updateBPFMapErr, err)))
}()

if p.oomPriorityMap == nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/agent/qrm-plugins/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package memory

import (
"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/agent/qrm"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/consts"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/memory/dynamicpolicy"
)

func init() {
qrm.RegisterMemoryPolicyInitializer(dynamicpolicy.MemoryResourcePluginPolicyNameDynamic, dynamicpolicy.NewDynamicPolicy)
qrm.RegisterMemoryPolicyInitializer(consts.MemoryResourcePluginPolicyNameDynamic, dynamicpolicy.NewDynamicPolicy)
}

0 comments on commit 1d11a30

Please sign in to comment.