mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-08 22:21:16 +02:00
Fixed: https://github.com/talos-systems/talos/issues/3686 Replaced sequencer tasks for KSPP and Kubernetes required sysctl props by the ones set by controllers. KernelParam flow includes of 3 controllers and 2 resources: - `KernelParamConfigController` - handles user sysctls coming from v1alpha1 config. - `KernelParamDefaultsController` - handles our built-in KSPP and K8s required sysctls. - `KernelParamSpecController` - consumes `KernelParamSpec`s created by the previous two controllers, applies them and updates the corresponding `KernelParamStatus`. Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
39 lines
968 B
Go
39 lines
968 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package kernel
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path"
|
|
"strings"
|
|
)
|
|
|
|
// Param represents a kernel system property.
|
|
type Param struct {
|
|
Key string
|
|
Value string
|
|
}
|
|
|
|
// WriteParam writes a value to a key under /proc/sys.
|
|
func WriteParam(prop *Param) error {
|
|
return ioutil.WriteFile(prop.Path(), []byte(prop.Value), 0o644)
|
|
}
|
|
|
|
// ReadParam reads a value from a key under /proc/sys.
|
|
func ReadParam(prop *Param) ([]byte, error) {
|
|
return ioutil.ReadFile(prop.Path())
|
|
}
|
|
|
|
// DeleteParam deletes a value from a key under /proc/sys.
|
|
func DeleteParam(prop *Param) error {
|
|
return os.Remove(prop.Path())
|
|
}
|
|
|
|
// Path returns the path to the systctl file under /proc/sys.
|
|
func (prop *Param) Path() string {
|
|
return path.Join("/proc/sys", strings.ReplaceAll(prop.Key, ".", "/"))
|
|
}
|