Skip to content

Commit

Permalink
Merge pull request #12735 from MusicDin/depr/limits-network-priority
Browse files Browse the repository at this point in the history
Remove deprecated instance config option limits.network.priority
  • Loading branch information
tomponline authored Jan 18, 2024
2 parents 47c9f67 + 453e30e commit 7803112
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 164 deletions.
14 changes: 0 additions & 14 deletions doc/config_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,20 +449,6 @@ Specify an integer between 0 and 10.
The higher the value, the less likely the instance is to be swapped to disk.
```

````{config:option} limits.network.priority instance-resource-limits
:defaultdesc: "`0` (minimum)"
:liveupdate: "yes"
:shortdesc: "Priority of the instance's network requests"
:type: "integer"
```{important}
This option is deprecated. Use the per-NIC `limits.priority` option instead.
```

Controls how much priority to give to the instance's network requests when under load.

Specify an integer between 0 and 10.
````

```{config:option} limits.processes instance-resource-limits
:condition: "container"
:defaultdesc: "empty"
Expand Down
15 changes: 0 additions & 15 deletions lxd/cgroup/abstraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,21 +746,6 @@ func (cg *CGroup) SetCPUCfsLimit(limitPeriod int64, limitQuota int64) error {
return ErrUnknownVersion
}

// SetNetIfPrio sets the priority for the process.
func (cg *CGroup) SetNetIfPrio(limit string) error {
version := cgControllers["net_prio"]
switch version {
case Unavailable:
return ErrControllerMissing
case V1:
return cg.rw.Set(version, "net_prio", "net_prio.ifpriomap", limit)
case V2:
return ErrControllerMissing
}

return ErrUnknownVersion
}

// SetHugepagesLimit applies a limit to the number of processes.
func (cg *CGroup) SetHugepagesLimit(pageType string, limit int64) error {
version := cgControllers["hugetlb"]
Expand Down
34 changes: 0 additions & 34 deletions lxd/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,39 +623,6 @@ func deviceTaskBalance(s *state.State) {
}
}

func deviceNetworkPriority(s *state.State, netif string) {
// Don't bother running when CGroup support isn't there
if !s.OS.CGInfo.Supports(cgroup.NetPrio, nil) {
return
}

instances, err := instance.LoadNodeAll(s, instancetype.Container)
if err != nil {
return
}

for _, c := range instances {
// Extract the current priority
networkPriority := c.ExpandedConfig()["limits.network.priority"]
if networkPriority == "" {
continue
}

networkInt, err := strconv.Atoi(networkPriority)
if err != nil {
continue
}

// Set the value for the new interface
cg, err := c.CGroup()
if err != nil {
continue
}

_ = cg.SetNetIfPrio(fmt.Sprintf("%s %d", netif, networkInt))
}
}

// deviceEventListener starts the event listener for resource scheduling.
// Accepts stateFunc which will be called each time it needs a fresh state.State.
func deviceEventListener(stateFunc func() *state.State) {
Expand Down Expand Up @@ -695,7 +662,6 @@ func deviceEventListener(stateFunc func() *state.State) {
}

logger.Debugf("Scheduler: network: %s has been added: updating network priorities", e[0])
deviceNetworkPriority(s, e[0])
err = networkAutoAttach(s.DB.Cluster, e[0])
if err != nil {
logger.Warn("Failed to auto-attach network", logger.Ctx{"err": err})
Expand Down
76 changes: 0 additions & 76 deletions lxd/instance/drivers/driver_lxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2549,17 +2549,6 @@ func (d *lxc) onStart(_ map[string]string) error {
// Trigger a rebalance
cgroup.TaskSchedulerTrigger("container", d.name, "started")

// Apply network priority
if d.expandedConfig["limits.network.priority"] != "" {
go func(d *lxc) {
d.fromHook = false
err := d.setNetworkPriority()
if err != nil {
d.logger.Error("Failed to apply network priority", logger.Ctx{"err": err})
}
}(d)
}

// Record last start state.
err = d.recordLastState()
if err != nil {
Expand Down Expand Up @@ -4623,11 +4612,6 @@ func (d *lxc) Update(args db.InstanceArgs, userRequested bool) error {
}
}
}
} else if key == "limits.network.priority" {
err := d.setNetworkPriority()
if err != nil {
return err
}
} else if key == "limits.cpu" || key == "limits.cpu.nodes" {
// Trigger a scheduler re-run
cgroup.TaskSchedulerTrigger("container", d.name, "changed")
Expand Down Expand Up @@ -7958,66 +7942,6 @@ func (d *lxc) removeDiskDevices() error {
return nil
}

// Network I/O limits.
func (d *lxc) setNetworkPriority() error {
// Load the go-lxc struct.
cc, err := d.initLXC(false)
if err != nil {
return err
}

// Load the cgroup struct.
cg, err := d.cgroup(cc, true)
if err != nil {
return err
}

// Check that the container is running
if d.InitPID() <= 0 {
return fmt.Errorf("Can't set network priority on stopped container")
}

// Don't bother if the cgroup controller doesn't exist
if !d.state.OS.CGInfo.Supports(cgroup.NetPrio, cg) {
return nil
}

// Extract the current priority
networkPriority := d.expandedConfig["limits.network.priority"]
if networkPriority == "" {
networkPriority = "0"
}

networkInt, err := strconv.Atoi(networkPriority)
if err != nil {
return err
}

// Get all the interfaces
netifs, err := net.Interfaces()
if err != nil {
return err
}

// Check that we at least succeeded to set an entry
success := false
var lastError error
for _, netif := range netifs {
err = cg.SetNetIfPrio(fmt.Sprintf("%s %d", netif.Name, networkInt))
if err == nil {
success = true
} else {
lastError = err
}
}

if !success {
return fmt.Errorf("Failed to set network device priority: %s", lastError)
}

return nil
}

// IsFrozen returns if instance is frozen.
func (d *lxc) IsFrozen() bool {
return d.statusCode() == api.Frozen
Expand Down
9 changes: 0 additions & 9 deletions lxd/metadata/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,6 @@
"type": "integer"
}
},
{
"limits.network.priority": {
"defaultdesc": "`0` (minimum)",
"liveupdate": "yes",
"longdesc": "```{important}\nThis option is deprecated. Use the per-NIC `limits.priority` option instead.\n```\n\nControls how much priority to give to the instance's network requests when under load.\n\nSpecify an integer between 0 and 10.",
"shortdesc": "Priority of the instance's network requests",
"type": "integer"
}
},
{
"limits.processes": {
"condition": "container",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bash/lxd-client
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ _have lxc && {
limits.cpu limits.cpu.allowance limits.cpu.priority \
limits.disk.priority limits.memory limits.memory.enforce \
limits.memory.hugepages limits.kernel \
limits.memory.swap limits.memory.swap.priority limits.network.priority \
limits.memory.swap limits.memory.swap.priority \
limits.processes linux.kernel_modules migration.incremental.memory \
migration.incremental.memory.goal nvidia.runtime \
nvidia.driver.capabilities nvidia.require.cuda nvidia.require.driver \
Expand Down
15 changes: 0 additions & 15 deletions shared/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,6 @@ var InstanceConfigKeysAny = map[string]func(value string) error{
return nil
},

// lxdmeta:generate(entity=instance, group=resource-limits, key=limits.network.priority)
// ```{important}
// This option is deprecated. Use the per-NIC `limits.priority` option instead.
// ```
//
// Controls how much priority to give to the instance's network requests when under load.
//
// Specify an integer between 0 and 10.
// ---
// type: integer
// defaultdesc: `0` (minimum)
// liveupdate: yes
// shortdesc: Priority of the instance's network requests
"limits.network.priority": validate.Optional(validate.IsPriority),

// Caller is responsible for full validation of any raw.* value.

// lxdmeta:generate(entity=instance, group=raw, key=raw.apparmor)
Expand Down

0 comments on commit 7803112

Please sign in to comment.