mirror of
https://github.com/containers/podman.git
synced 2025-11-13 01:29:06 +08:00
vendor c/common
Update the recent events-log changes to fix the build error. [NO NEW TESTS NEEDED] since there's no functional change. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
43
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
43
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
@@ -252,7 +252,7 @@ type EngineConfig struct {
|
||||
|
||||
// EventsLogFileMaxSize sets the maximum size for the events log. When the limit is exceeded,
|
||||
// the logfile is rotated and the old one is deleted.
|
||||
EventsLogFileMaxSize uint64 `toml:"events_logfile_max_size,omitempty,omitzero"`
|
||||
EventsLogFileMaxSize eventsLogMaxSize `toml:"events_logfile_max_size,omitzero"`
|
||||
|
||||
// EventsLogger determines where events should be logged.
|
||||
EventsLogger string `toml:"events_logger,omitempty"`
|
||||
@@ -581,7 +581,6 @@ type Destination struct {
|
||||
// with cgroupv2v2. Other OCI runtimes are not yet supporting cgroupv2v2. This
|
||||
// might change in the future.
|
||||
func NewConfig(userConfigPath string) (*Config, error) {
|
||||
|
||||
// Generate the default config for the system
|
||||
config, err := DefaultConfig()
|
||||
if err != nil {
|
||||
@@ -765,7 +764,6 @@ func (c *Config) addCAPPrefix() {
|
||||
|
||||
// Validate is the main entry point for library configuration validation.
|
||||
func (c *Config) Validate() error {
|
||||
|
||||
if err := c.Containers.Validate(); err != nil {
|
||||
return errors.Wrap(err, "validating containers config")
|
||||
}
|
||||
@@ -822,7 +820,6 @@ func (c *EngineConfig) Validate() error {
|
||||
// It returns an `error` on validation failure, otherwise
|
||||
// `nil`.
|
||||
func (c *ContainersConfig) Validate() error {
|
||||
|
||||
if err := c.validateUlimits(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -954,7 +951,6 @@ func (c *Config) GetDefaultEnvEx(envHost, httpProxy bool) []string {
|
||||
// Capabilities returns the capabilities parses the Add and Drop capability
|
||||
// list from the default capabiltiies for the container
|
||||
func (c *Config) Capabilities(user string, addCapabilities, dropCapabilities []string) ([]string, error) {
|
||||
|
||||
userNotRoot := func(user string) bool {
|
||||
if user == "" || user == "root" || user == "0" {
|
||||
return false
|
||||
@@ -1014,7 +1010,7 @@ func Device(device string) (src, dst, permissions string, err error) {
|
||||
// IsValidDeviceMode checks if the mode for device is valid or not.
|
||||
// IsValid mode is a composition of r (read), w (write), and m (mknod).
|
||||
func IsValidDeviceMode(mode string) bool {
|
||||
var legalDeviceMode = map[rune]bool{
|
||||
legalDeviceMode := map[rune]bool{
|
||||
'r': true,
|
||||
'w': true,
|
||||
'm': true,
|
||||
@@ -1065,7 +1061,6 @@ func rootlessConfigPath() (string, error) {
|
||||
}
|
||||
|
||||
func stringsEq(a, b []string) bool {
|
||||
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
@@ -1150,10 +1145,10 @@ func (c *Config) Write() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
configFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
|
||||
configFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1266,3 +1261,33 @@ func (c *Config) setupEnv() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// eventsLogMaxSize is the type used by EventsLogFileMaxSize
|
||||
type eventsLogMaxSize uint64
|
||||
|
||||
// UnmarshalText parses the JSON encoding of eventsLogMaxSize and
|
||||
// stores it in a value.
|
||||
func (e *eventsLogMaxSize) UnmarshalText(text []byte) error {
|
||||
// REMOVE once writing works
|
||||
if string(text) == "" {
|
||||
return nil
|
||||
}
|
||||
val, err := units.FromHumanSize((string(text)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if val < 0 {
|
||||
return fmt.Errorf("events log file max size cannot be negative: %s", string(text))
|
||||
}
|
||||
*e = eventsLogMaxSize(uint64(val))
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalText returns the JSON encoding of eventsLogMaxSize.
|
||||
func (e eventsLogMaxSize) MarshalText() ([]byte, error) {
|
||||
if uint64(e) == DefaultEventsLogSizeMax || e == 0 {
|
||||
v := []byte{}
|
||||
return v, nil
|
||||
}
|
||||
return []byte(fmt.Sprintf("%d", e)), nil
|
||||
}
|
||||
|
||||
12
vendor/github.com/containers/common/pkg/config/containers.conf
generated
vendored
12
vendor/github.com/containers/common/pkg/config/containers.conf
generated
vendored
@@ -373,11 +373,14 @@ default_sysctls = [
|
||||
# Define where event logs will be stored, when events_logger is "file".
|
||||
#events_logfile_path=""
|
||||
|
||||
# Sets the maximum size for events_logfile_path in bytes. When the limit is exceeded,
|
||||
# the logfile will be rotated and the old one will be deleted.
|
||||
# Sets the maximum size for events_logfile_path.
|
||||
# The size can be b (bytes), k (kilobytes), m (megabytes), or g (gigabytes).
|
||||
# The format for the size is `<number><unit>`, e.g., `1b` or `3g`.
|
||||
# If no unit is included then the size will be read in bytes.
|
||||
# When the limit is exceeded, the logfile will be rotated and the old one will be deleted.
|
||||
# If the maximum size is set to 0, then no limit will be applied,
|
||||
# and the logfile will not be rotated.
|
||||
#events_logfile_max_size = 0
|
||||
#events_logfile_max_size = "1m"
|
||||
|
||||
# Selects which logging mechanism to use for container engine events.
|
||||
# Valid values are `journald`, `file` and `none`.
|
||||
@@ -629,7 +632,7 @@ default_sysctls = [
|
||||
|
||||
# Host directories to be mounted as volumes into the VM by default.
|
||||
# Environment variables like $HOME as well as complete paths are supported for
|
||||
# the source and destination. An optional third field `:ro` can be used to
|
||||
# the source and destination. An optional third field `:ro` can be used to
|
||||
# tell the container engines to mount the volume readonly.
|
||||
#
|
||||
# volumes = [
|
||||
@@ -641,3 +644,4 @@ default_sysctls = [
|
||||
# TOML does not provide a way to end a table other than a further table being
|
||||
# defined, so every key hereafter will be part of [machine] and not the
|
||||
# main config.
|
||||
|
||||
|
||||
15
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
15
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
@@ -109,7 +109,6 @@ func parseSubnetPool(subnet string, size int) SubnetPool {
|
||||
Base: &nettypes.IPNet{IPNet: *n},
|
||||
Size: size,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -128,6 +127,9 @@ const (
|
||||
// DefaultLogSizeMax is the default value for the maximum log size
|
||||
// allowed for a container. Negative values mean that no limit is imposed.
|
||||
DefaultLogSizeMax = -1
|
||||
// DefaultEventsLogSize is the default value for the maximum events log size
|
||||
// before rotation.
|
||||
DefaultEventsLogSizeMax = uint64(1000000)
|
||||
// DefaultPidsLimit is the default value for maximum number of processes
|
||||
// allowed inside a container
|
||||
DefaultPidsLimit = 2048
|
||||
@@ -156,7 +158,6 @@ const (
|
||||
|
||||
// DefaultConfig defines the default values from containers.conf
|
||||
func DefaultConfig() (*Config, error) {
|
||||
|
||||
defaultEngineConfig, err := defaultConfigFromMemory()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -263,6 +264,8 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
|
||||
|
||||
c.EventsLogFilePath = filepath.Join(c.TmpDir, "events", "events.log")
|
||||
|
||||
c.EventsLogFileMaxSize = eventsLogMaxSize(DefaultEventsLogSizeMax)
|
||||
|
||||
c.CompatAPIEnforceDockerHub = true
|
||||
|
||||
if path, ok := os.LookupEnv("CONTAINERS_STORAGE_CONF"); ok {
|
||||
@@ -399,10 +402,10 @@ func defaultTmpDir() (string, error) {
|
||||
}
|
||||
libpodRuntimeDir := filepath.Join(runtimeDir, "libpod")
|
||||
|
||||
if err := os.Mkdir(libpodRuntimeDir, 0700|os.ModeSticky); err != nil {
|
||||
if err := os.Mkdir(libpodRuntimeDir, 0o700|os.ModeSticky); err != nil {
|
||||
if !os.IsExist(err) {
|
||||
return "", err
|
||||
} else if err := os.Chmod(libpodRuntimeDir, 0700|os.ModeSticky); err != nil {
|
||||
} else if err := os.Chmod(libpodRuntimeDir, 0o700|os.ModeSticky); err != nil {
|
||||
// The directory already exist, just set the sticky bit
|
||||
return "", errors.Wrap(err, "set sticky bit on")
|
||||
}
|
||||
@@ -466,6 +469,10 @@ func (c *Config) NetNS() string {
|
||||
return c.Containers.NetNS
|
||||
}
|
||||
|
||||
func (c EngineConfig) EventsLogMaxSize() uint64 {
|
||||
return uint64(c.EventsLogFileMaxSize)
|
||||
}
|
||||
|
||||
// SecurityOptions returns the default security options
|
||||
func (c *Config) SecurityOptions() []string {
|
||||
securityOpts := []string{}
|
||||
|
||||
2
vendor/github.com/containers/common/pkg/config/systemd.go
generated
vendored
2
vendor/github.com/containers/common/pkg/config/systemd.go
generated
vendored
@@ -58,7 +58,6 @@ func useSystemd() bool {
|
||||
val := strings.TrimSuffix(string(dat), "\n")
|
||||
usesSystemd = (val == "systemd")
|
||||
}
|
||||
return
|
||||
})
|
||||
return usesSystemd
|
||||
}
|
||||
@@ -82,7 +81,6 @@ func useJournald() bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
})
|
||||
return usesJournald
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user