Skip to content

Commit

Permalink
Merge pull request #135 from klihub/fixes/nuke-unused-scripts-rules-a…
Browse files Browse the repository at this point in the history
…nd-defunct-functionality

cleanup: nuke unused scripts, Makefile bits and defunct functionality.
  • Loading branch information
marquiz committed Oct 11, 2023
2 parents a826ac6 + 94b494b commit 66ed9f4
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 2,005 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ ifdef IMAGE_REPO
override IMAGE_REPO := $(IMAGE_REPO)/
endif

# Determine binary version and buildid, and versions for rpm, deb, and tar packages.
# Determine binary version and buildid.
BUILD_VERSION := $(shell scripts/build/get-buildid --version --shell=no)
BUILD_BUILDID := $(shell scripts/build/get-buildid --buildid --shell=no)
RPM_VERSION := $(shell scripts/build/get-buildid --rpm --shell=no)
DEB_VERSION := $(shell scripts/build/get-buildid --deb --shell=no)
TAR_VERSION := $(shell scripts/build/get-buildid --tar --shell=no)
GOLICENSES_VERSION ?= v1.6.0

GO_CMD := go
GO_BUILD := $(GO_CMD) build
Expand Down
12 changes: 0 additions & 12 deletions cmd/plugins/balloons/policy/balloons-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/containers/nri-plugins/pkg/resmgr/cache"
cpucontrol "github.com/containers/nri-plugins/pkg/resmgr/control/cpu"
"github.com/containers/nri-plugins/pkg/resmgr/events"
"github.com/containers/nri-plugins/pkg/resmgr/introspect"
policy "github.com/containers/nri-plugins/pkg/resmgr/policy"
"github.com/containers/nri-plugins/pkg/utils"
idset "github.com/intel/goresctrl/pkg/utils"
Expand Down Expand Up @@ -283,12 +282,6 @@ func (p *balloons) UpdateResources(c cache.Container) error {
return nil
}

// Rebalance tries to find an optimal allocation of resources for the current containers.
func (p *balloons) Rebalance() (bool, error) {
log.Debug("(not) rebalancing containers...")
return false, nil
}

// HandleEvent handles policy-specific events.
func (p *balloons) HandleEvent(*events.Policy) (bool, error) {
log.Debug("(not) handling event...")
Expand All @@ -300,11 +293,6 @@ func (p *balloons) ExportResourceData(c cache.Container) map[string]string {
return nil
}

// Introspect provides data for external introspection.
func (p *balloons) Introspect(*introspect.State) {
return
}

// GetTopologyZones returns the policy/pool data for 'topology zone' CRDs.
func (b *balloons) GetTopologyZones() []*policy.TopologyZone {
return nil
Expand Down
11 changes: 0 additions & 11 deletions cmd/plugins/template/policy/template-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
logger "github.com/containers/nri-plugins/pkg/log"
"github.com/containers/nri-plugins/pkg/resmgr/cache"
"github.com/containers/nri-plugins/pkg/resmgr/events"
"github.com/containers/nri-plugins/pkg/resmgr/introspect"
policyapi "github.com/containers/nri-plugins/pkg/resmgr/policy"
)

Expand Down Expand Up @@ -94,22 +93,12 @@ func (p *policy) UpdateResources(c cache.Container) error {
return nil
}

// Rebalance tries to find an optimal allocation of resources for the current containers.
func (p *policy) Rebalance() (bool, error) {
return true, nil
}

// HandleEvent handles policy-specific events.
func (p *policy) HandleEvent(e *events.Policy) (bool, error) {
log.Info("received policy event %s.%s with data %v...", e.Source, e.Type, e.Data)
return true, nil
}

// Introspect provides data for external introspection.
func (p *policy) Introspect(state *introspect.State) {
return
}

// DescribeMetrics generates policy-specific prometheus metrics data descriptors.
func (p *policy) DescribeMetrics() []*prometheus.Desc {
return nil
Expand Down
12 changes: 0 additions & 12 deletions cmd/plugins/topology-aware/policy/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,6 @@ func (m *mockContainer) SetBlockIOClass(string) {
func (m *mockContainer) GetBlockIOClass() string {
panic("unimplemented")
}
func (m *mockContainer) SetToptierLimit(int64) {
panic("unimplemented")
}
func (m *mockContainer) GetToptierLimit() int64 {
panic("unimplemented")
}
func (m *mockContainer) SetPageMigration(*cache.PageMigrate) {
return
}
func (m *mockContainer) GetPageMigration() *cache.PageMigrate {
return nil
}
func (m *mockContainer) GetPending() []string {
panic("unimplemented")
}
Expand Down
30 changes: 0 additions & 30 deletions cmd/plugins/topology-aware/policy/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/containers/nri-plugins/pkg/utils/cpuset"

"github.com/containers/nri-plugins/pkg/kubernetes"
"github.com/containers/nri-plugins/pkg/resmgr/cache"
system "github.com/containers/nri-plugins/pkg/sysfs"
idset "github.com/intel/goresctrl/pkg/utils"
Expand Down Expand Up @@ -667,7 +666,6 @@ func (p *policy) applyGrant(grant Grant) {
if mems != "" {
log.Debug(" => pinning to memory %s", mems)
container.SetCpusetMems(mems)
p.setDemotionPreferences(container, grant)
} else {
log.Debug(" => not pinning memory, memory set is empty...")
}
Expand Down Expand Up @@ -739,34 +737,6 @@ func (p *policy) updateSharedAllocations(grant *Grant) {
}
}

// setDemotionPreferences sets the dynamic demotion preferences a container.
func (p *policy) setDemotionPreferences(c cache.Container, g Grant) {
log.Debug("%s: setting demotion preferences...", c.PrettyName())

// System containers should not be demoted.
if c.GetNamespace() == kubernetes.NamespaceSystem {
c.SetPageMigration(nil)
return
}

memType := g.GetMemoryNode().GetMemoryType()
if memType&memoryDRAM == 0 || memType&memoryPMEM == 0 {
c.SetPageMigration(nil)
return
}

dram := g.GetMemoryNode().GetMemset(memoryDRAM)
pmem := g.GetMemoryNode().GetMemset(memoryPMEM)

log.Debug("%s: eligible for demotion from %s to %s NUMA node(s)",
c.PrettyName(), dram, pmem)

c.SetPageMigration(&cache.PageMigrate{
SourceNodes: dram,
TargetNodes: pmem,
})
}

func (p *policy) filterInsufficientResources(req Request, originals []Node) []Node {
sufficient := make([]Node, 0)

Expand Down
68 changes: 0 additions & 68 deletions cmd/plugins/topology-aware/policy/topology-aware-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"

"github.com/containers/nri-plugins/pkg/utils/cpuset"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
resapi "k8s.io/apimachinery/pkg/api/resource"

Expand All @@ -28,7 +27,6 @@ import (
"github.com/containers/nri-plugins/pkg/cpuallocator"
"github.com/containers/nri-plugins/pkg/resmgr/cache"
"github.com/containers/nri-plugins/pkg/resmgr/events"
"github.com/containers/nri-plugins/pkg/resmgr/introspect"

policyapi "github.com/containers/nri-plugins/pkg/resmgr/policy"
system "github.com/containers/nri-plugins/pkg/sysfs"
Expand Down Expand Up @@ -199,33 +197,6 @@ func (p *policy) UpdateResources(container cache.Container) error {
return nil
}

// Rebalance tries to find an optimal allocation of resources for the current containers.
func (p *policy) Rebalance() (bool, error) {
var errors error

containers := p.cache.GetContainers()
movable := []cache.Container{}

for _, c := range containers {
if c.GetQOSClass() != v1.PodQOSGuaranteed {
p.ReleaseResources(c)
movable = append(movable, c)
}
}

for _, c := range movable {
if err := p.AllocateResources(c); err != nil {
if errors == nil {
errors = err
} else {
errors = policyError("%v, %v", errors, err)
}
}
}

return true, errors
}

// HandleEvent handles policy-specific events.
func (p *policy) HandleEvent(e *events.Policy) (bool, error) {
log.Debug("received policy event %s.%s with data %v...", e.Source, e.Type, e.Data)
Expand Down Expand Up @@ -256,45 +227,6 @@ func (p *policy) HandleEvent(e *events.Policy) (bool, error) {
return false, nil
}

// Introspect provides data for external introspection.
func (p *policy) Introspect(state *introspect.State) {
pools := make(map[string]*introspect.Pool, len(p.pools))
for _, node := range p.nodes {
cpus := node.GetSupply()
pool := &introspect.Pool{
Name: node.Name(),
CPUs: cpus.SharableCPUs().Union(cpus.IsolatedCPUs()).String(),
Memory: node.GetMemset(memoryAll).String(),
}
if parent := node.Parent(); !parent.IsNil() {
pool.Parent = parent.Name()
}
if children := node.Children(); len(children) > 0 {
pool.Children = make([]string, 0, len(children))
for _, c := range children {
pool.Children = append(pool.Children, c.Name())
}
}
pools[pool.Name] = pool
}
state.Pools = pools

assignments := make(map[string]*introspect.Assignment, len(p.allocations.grants))
for _, g := range p.allocations.grants {
a := &introspect.Assignment{
ContainerID: g.GetContainer().GetID(),
CPUShare: g.SharedPortion(),
ExclusiveCPUs: g.ExclusiveCPUs().Union(g.IsolatedCPUs()).String(),
Pool: g.GetCPUNode().Name(),
}
if g.SharedPortion() > 0 || a.ExclusiveCPUs == "" {
a.SharedCPUs = g.SharedCPUs().String()
}
assignments[a.ContainerID] = a
}
state.Assignments = assignments
}

// DescribeMetrics generates policy-specific prometheus metrics data descriptors.
func (p *policy) DescribeMetrics() []*prometheus.Desc {
return nil
Expand Down
20 changes: 2 additions & 18 deletions docs/resource-policy/developers-guide/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ for:

NRI-RP implements an event processing pipeline. In addition to NRI events,
it processes a set of other events that are not directly related to or the
result of NRI requests.
These events are typically internally generated within NRI-RP. They can be
the result of changes in the state of some containers or the utilization
of a shared system resource, which potentially could warrant an attempt to
rebalance the distribution of resources among containers to bring the system
closer to an optimal state. Some events can also be generated by policies.
result of NRI requests. These events are typically internally generated within
NRI-RP.

The Resource Manager component of NRI-RP implements the basic control
flow of the processing pipeline. It passes control to all the
Expand Down Expand Up @@ -114,18 +110,6 @@ following, based on the event type:
2. Call policy event handler.
3. Invoke the controller layer for post-policy processing (same as step 5 for requests).
4. Release the pipeline lock.
- For metrics events:
1. Perform collection/processing/correlation.
2. Engage the processing pipeline lock.
3. Update cache objects as/if necessary.
4. Request rebalancing as/if necessary.
5. Release pipeline lock.
- For rebalance events:
1. Engage the processing pipeline lock.
2. Invoke policy layer for rebalancing.
3. Invoke the controller layer for post-policy processing (same as step 5 for requests).
4. Release the pipeline lock.


### [Cache](tree:/pkg/resmgr/cache/)

Expand Down
27 changes: 0 additions & 27 deletions docs/resource-policy/policy/topology-aware.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ The `topology-aware` policy has the following features:
typically found on some special-purpose computing systems
- cold start
* pin workload exclusively to PMEM for an initial warm-up period
- dynamic page demotion
* forcibly migrate read-only and idle container memory pages to PMEM

## Activating the Policy

Expand Down Expand Up @@ -359,31 +357,6 @@ In the above example, `container1` would be initially granted only PMEM
memory controller, but after 60 seconds the DRAM controller would be
added to the container memset.

## Dynamic Page Demotion

The `topology-aware` policy also supports dynamic page demotion. With dynamic
demotion enabled, rarely-used pages are periodically moved from DRAM to PMEM
for those workloads which are assigned to use both DRAM and PMEM memory types.
The configuration for this feature is done using three configuration keys:
`DirtyBitScanPeriod`, `PageMovePeriod`, and `PageMoveCount`. All of these
parameters need to be set to non-zero values in order for dynamic page demotion
to get enabled. See this configuration file fragment as an example:

```yaml
policy:
Active: topology-aware
topology-aware:
DirtyBitScanPeriod: 10s
PageMovePeriod: 2s
PageMoveCount: 1000
```

In this setup, every pid in every container in every non-system pod
fulfilling the memory container requirements would have their page ranges
scanned for non-accessed pages every ten seconds. The result of the scan
would be fed to a page-moving loop, which would attempt to move 1000 pages
every two seconds from DRAM to PMEM.

## Container memory requests and limits

Due to inaccuracies in how `nri-resource-policy` calculates memory requests for
Expand Down
Loading

0 comments on commit 66ed9f4

Please sign in to comment.