mirror of
https://github.com/containers/podman.git
synced 2025-05-20 00:27:03 +08:00
auto update: create an event
Create an auto-update event for each invocation, independent if images and containers are updated or not. Those events will be indicated in the events already but users will now know why. Fixes: #14283 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -89,8 +89,8 @@ func (p *Pod) newPodEvent(status events.Status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// newSystemEvent creates a new event for libpod as a whole.
|
// NewSystemEvent creates a new event for libpod as a whole.
|
||||||
func (r *Runtime) newSystemEvent(status events.Status) {
|
func (r *Runtime) NewSystemEvent(status events.Status) {
|
||||||
e := events.NewEvent(status)
|
e := events.NewEvent(status)
|
||||||
e.Type = events.System
|
e.Type = events.System
|
||||||
|
|
||||||
|
@ -150,6 +150,8 @@ func StringToStatus(name string) (Status, error) {
|
|||||||
switch name {
|
switch name {
|
||||||
case Attach.String():
|
case Attach.String():
|
||||||
return Attach, nil
|
return Attach, nil
|
||||||
|
case AutoUpdate.String():
|
||||||
|
return AutoUpdate, nil
|
||||||
case Build.String():
|
case Build.String():
|
||||||
return Build, nil
|
return Build, nil
|
||||||
case Checkpoint.String():
|
case Checkpoint.String():
|
||||||
|
@ -930,7 +930,7 @@ func (r *Runtime) refresh(alivePath string) error {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
r.newSystemEvent(events.Refresh)
|
r.NewSystemEvent(events.Refresh)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func (r *Runtime) renumberLocks() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r.newSystemEvent(events.Renumber)
|
r.NewSystemEvent(events.Renumber)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/containers/image/v5/transports/alltransports"
|
"github.com/containers/image/v5/transports/alltransports"
|
||||||
"github.com/containers/podman/v4/libpod"
|
"github.com/containers/podman/v4/libpod"
|
||||||
"github.com/containers/podman/v4/libpod/define"
|
"github.com/containers/podman/v4/libpod/define"
|
||||||
|
"github.com/containers/podman/v4/libpod/events"
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v4/pkg/systemd"
|
"github.com/containers/podman/v4/pkg/systemd"
|
||||||
systemdDefine "github.com/containers/podman/v4/pkg/systemd/define"
|
systemdDefine "github.com/containers/podman/v4/pkg/systemd/define"
|
||||||
@ -142,6 +143,8 @@ func AutoUpdate(ctx context.Context, runtime *libpod.Runtime, options entities.A
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
runtime.NewSystemEvent(events.AutoUpdate)
|
||||||
|
|
||||||
// Update all images/container according to their auto-update policy.
|
// Update all images/container according to their auto-update policy.
|
||||||
var allReports []*entities.AutoUpdateReport
|
var allReports []*entities.AutoUpdateReport
|
||||||
updatedRawImages := make(map[string]bool)
|
updatedRawImages := make(map[string]bool)
|
||||||
|
@ -135,15 +135,27 @@ function _confirm_update() {
|
|||||||
# This test can fail in dev. environment because of SELinux.
|
# This test can fail in dev. environment because of SELinux.
|
||||||
# quick fix: chcon -t container_runtime_exec_t ./bin/podman
|
# quick fix: chcon -t container_runtime_exec_t ./bin/podman
|
||||||
@test "podman auto-update - label io.containers.autoupdate=image" {
|
@test "podman auto-update - label io.containers.autoupdate=image" {
|
||||||
|
since=$(date --iso-8601=seconds)
|
||||||
|
run_podman auto-update
|
||||||
|
is "$output" ""
|
||||||
|
run_podman events --filter type=system --since $since --stream=false
|
||||||
|
is "$output" ""
|
||||||
|
|
||||||
generate_service alpine image
|
generate_service alpine image
|
||||||
|
|
||||||
_wait_service_ready container-$cname.service
|
_wait_service_ready container-$cname.service
|
||||||
|
since=$(date --iso-8601=seconds)
|
||||||
run_podman auto-update --dry-run --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
|
run_podman auto-update --dry-run --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
|
||||||
is "$output" ".*container-$cname.service,quay.io/libpod/alpine:latest,pending,registry.*" "Image update is pending."
|
is "$output" ".*container-$cname.service,quay.io/libpod/alpine:latest,pending,registry.*" "Image update is pending."
|
||||||
|
run_podman events --filter type=system --since $since --stream=false
|
||||||
|
is "$output" ".* system auto-update"
|
||||||
|
|
||||||
|
since=$(date --iso-8601=seconds)
|
||||||
run_podman auto-update --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
|
run_podman auto-update --format "{{.Unit}},{{.Image}},{{.Updated}},{{.Policy}}"
|
||||||
is "$output" "Trying to pull.*" "Image is updated."
|
is "$output" "Trying to pull.*" "Image is updated."
|
||||||
is "$output" ".*container-$cname.service,quay.io/libpod/alpine:latest,true,registry.*" "Image is updated."
|
is "$output" ".*container-$cname.service,quay.io/libpod/alpine:latest,true,registry.*" "Image is updated."
|
||||||
|
run_podman events --filter type=system --since $since --stream=false
|
||||||
|
is "$output" ".* system auto-update"
|
||||||
|
|
||||||
_confirm_update $cname $ori_image
|
_confirm_update $cname $ori_image
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user