Switch eventlogger to journald by default

[NO TESTS NEEDED] Since we are just testing the default.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-08-04 15:24:29 -04:00
committed by Nalin Dahyabhai
parent d1137664fe
commit 6b06e9b77c
14 changed files with 112 additions and 31 deletions

View File

@ -448,14 +448,24 @@ func (i *Image) removeRecursive(ctx context.Context, rmMap map[string]*RemoveIma
return parent.removeRecursive(ctx, rmMap, processedIDs, "", options)
}
var errTagDigest = errors.New("tag by digest not supported")
// Tag the image with the specified name and store it in the local containers
// storage. The name is normalized according to the rules of NormalizeName.
func (i *Image) Tag(name string) error {
if strings.HasPrefix(name, "sha256:") { // ambiguous input
return errors.Wrap(errTagDigest, name)
}
ref, err := NormalizeName(name)
if err != nil {
return errors.Wrapf(err, "error normalizing name %q", name)
}
if _, isDigested := ref.(reference.Digested); isDigested {
return errors.Wrap(errTagDigest, name)
}
logrus.Debugf("Tagging image %s with %q", i.ID(), ref.String())
if i.runtime.eventChannel != nil {
defer i.runtime.writeEvent(&Event{ID: i.ID(), Name: name, Time: time.Now(), Type: EventTypeImageTag})
@ -480,7 +490,7 @@ var errUntagDigest = errors.New("untag by digest not supported")
// the local containers storage. The name is normalized according to the rules
// of NormalizeName.
func (i *Image) Untag(name string) error {
if strings.HasPrefix(name, "sha256:") {
if strings.HasPrefix(name, "sha256:") { // ambiguous input
return errors.Wrap(errUntagDigest, name)
}
@ -488,6 +498,11 @@ func (i *Image) Untag(name string) error {
if err != nil {
return errors.Wrapf(err, "error normalizing name %q", name)
}
if _, isDigested := ref.(reference.Digested); isDigested {
return errors.Wrap(errUntagDigest, name)
}
name = ref.String()
logrus.Debugf("Untagging %q from image %s", ref.String(), i.ID())

View File

@ -104,7 +104,6 @@ func Login(ctx context.Context, systemContext *types.SystemContext, opts *LoginO
return errors.Wrap(err, "get credentials for repository")
}
} else {
// nolint: staticcheck
authConfig, err = config.GetCredentials(systemContext, registry)
if err != nil {
return errors.Wrap(err, "get credentials")
@ -321,7 +320,6 @@ func Logout(systemContext *types.SystemContext, opts *LogoutOptions, args []stri
return errors.Wrap(err, "get credentials for repository")
}
} else {
// nolint: staticcheck
authConfig, err = config.GetCredentials(systemContext, registry)
if err != nil {
return errors.Wrap(err, "get credentials")

View File

@ -274,6 +274,9 @@ type EngineConfig struct {
// MachineEnabled indicates if Podman is running in a podman-machine VM
MachineEnabled bool `toml:"machine_enabled,omitempty"`
// MachineImage is the image used when creating a podman-machine VM
MachineImage string `toml:"machine_image,omitempty"`
// MultiImageArchive - if true, the container engine allows for storing
// archives (e.g., of the docker-archive transport) with multiple
// images. By default, Podman creates single-image archives.
@ -691,8 +694,8 @@ func (c *Config) Validate() error {
}
func (c *EngineConfig) findRuntime() string {
// Search for crun first followed by runc and kata
for _, name := range []string{"crun", "runc", "kata"} {
// Search for crun first followed by runc, kata, runsc
for _, name := range []string{"crun", "runc", "kata", "runsc"} {
for _, v := range c.OCIRuntimes[name] {
if _, err := os.Stat(v); err == nil {
return name

View File

@ -60,23 +60,23 @@ default_capabilities = [
]
# A list of sysctls to be set in containers by default,
# specified as "name=value",
# specified as "name = value",
# for example:"net.ipv4.ping_group_range = 0 0".
#
default_sysctls = [
"net.ipv4.ping_group_range=0 0",
"net.ipv4.ping_group_range = 0 0",
]
# A list of ulimits to be set in containers by default, specified as
# "<ulimit name>=<soft limit>:<hard limit>", for example:
# "nofile=1024:2048"
# "<ulimit name> = <soft limit>:<hard limit>", for example:
# "nofile = 1024:2048"
# See setrlimit(2) for a list of resource names.
# Any limit not specified here will be inherited from the process launching the
# container engine.
# Ulimits has limits for non privileged container engines.
#
#default_ulimits = [
# "nofile=1280:2560",
# "nofile = 1280:2560",
#]
# List of devices. Specified as
@ -381,6 +381,9 @@ default_sysctls = [
#
#machine_enabled = false
# The image used when creating a podman-machine VM.
# machine_image = "testing"
# MultiImageArchive - if true, the container engine allows for storing archives
# (e.g., of the docker-archive transport) with multiple images. By default,
# Podman creates single-image archives.

View File

@ -105,8 +105,6 @@ const (
DefaultApparmorProfile = apparmor.Profile
// SystemdCgroupsManager represents systemd native cgroup manager
SystemdCgroupsManager = "systemd"
// DefaultLogDriver is the default type of log files
DefaultLogDriver = "k8s-file"
// DefaultLogSizeMax is the default value for the maximum log size
// allowed for a container. Negative values mean that no limit is imposed.
DefaultLogSizeMax = -1
@ -339,6 +337,7 @@ func defaultConfigFromMemory() (*EngineConfig, error) {
// constants.
c.LockType = "shm"
c.MachineEnabled = false
c.MachineImage = "testing"
c.ChownCopiedFiles = true
@ -549,6 +548,7 @@ func (c *Config) LogDriver() string {
return c.Containers.LogDriver
}
// MachineEnabled returns if podman is running inside a VM or not
func (c *Config) MachineEnabled() bool {
return c.Engine.MachineEnabled
}
@ -558,3 +558,9 @@ func (c *Config) MachineEnabled() bool {
func (c *Config) RootlessNetworking() string {
return c.Containers.RootlessNetworking
}
// MachineImage returns the image to be
// used when creating a podman-machine VM
func (c *Config) MachineImage() string {
return c.Engine.MachineImage
}

View File

@ -1,7 +1,12 @@
// +build !systemd
// +build !systemd !cgo
package config
const (
// DefaultLogDriver is the default type of log files
DefaultLogDriver = "k8s-file"
)
func defaultCgroupManager() string {
return CgroupfsCgroupsManager
}

View File

@ -1,4 +1,4 @@
// +build systemd
// +build systemd,cgo
package config
@ -9,11 +9,19 @@ import (
"github.com/containers/common/pkg/cgroupv2"
"github.com/containers/storage/pkg/unshare"
"github.com/coreos/go-systemd/v22/sdjournal"
)
var (
systemdOnce sync.Once
usesSystemd bool
systemdOnce sync.Once
usesSystemd bool
journaldOnce sync.Once
usesJournald bool
)
const (
// DefaultLogDriver is the default type of log files
DefaultLogDriver = "journald"
)
func defaultCgroupManager() string {
@ -29,20 +37,17 @@ func defaultCgroupManager() string {
}
func defaultEventsLogger() string {
if useSystemd() {
if useJournald() {
return "journald"
}
return "file"
}
func defaultLogDriver() string {
// If we decide to change the default for logdriver, it should be done here.
if useSystemd() {
return DefaultLogDriver
if useJournald() {
return "journald"
}
return DefaultLogDriver
return "k8s-file"
}
func useSystemd() bool {
@ -56,3 +61,19 @@ func useSystemd() bool {
})
return usesSystemd
}
func useJournald() bool {
journaldOnce.Do(func() {
if !useSystemd() {
return
}
journal, err := sdjournal.NewJournal()
if err != nil {
return
}
journal.Close()
usesJournald = true
return
})
return usesJournald
}

View File

@ -1,4 +1,4 @@
package version
// Version is the version of the build.
const Version = "0.42.1"
const Version = "0.43.0"