Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

filter events for non k8s.io namespaces #984

Merged
merged 1 commit into from
Dec 5, 2018
Merged

filter events for non k8s.io namespaces #984

merged 1 commit into from
Dec 5, 2018

Conversation

mikebrow
Copy link
Member

@mikebrow mikebrow commented Dec 4, 2018

Resolve issue firecracker-microvm/firecracker-containerd#35

Signed-off-by: Mike Brown brownwm@us.ibm.com

@@ -198,6 +198,11 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
e := any.(*eventtypes.TaskExit)
logrus.Infof("TaskExit event %+v", e)
// Use ID instead of ContainerID to rule out TaskExit event for exec.
if e.ID == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think current logic can handle this case, and firecracker should have ID here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would handle it, but is that a requirement that we should force on all containers created in containerd?

Would be nice to have a namespace filter on these events I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the behavior should be equivalent to does not exist, vs error prefix is invalid..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we don't need this.

If we want to consider empty string, we should do it for sandbox/container and image for consistency, which i feel like is not that necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's at least keep this PR only add the namespace filter for easy cherrypick

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.. the filter for namespace will be enough..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh.. so the subscriptions return any events that match, so we could request any for our namespace or any for the ones we already subscribe to, but it does not filter out by namespace unless that is the only filter used.

@mikebrow mikebrow changed the title [WIP] filter task exits with no id filter task exits with no id Dec 4, 2018
@@ -198,6 +198,11 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
e := any.(*eventtypes.TaskExit)
logrus.Infof("TaskExit event %+v", e)
// Use ID instead of ContainerID to rule out TaskExit event for exec.
if e.ID == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's at least keep this PR only add the namespace filter for easy cherrypick

@@ -98,6 +99,7 @@ func (em *eventMonitor) subscribe(subscriber events.Subscriber) {
`topic=="/tasks/exit"`,
`topic=="/tasks/oom"`,
`topic~="/images/"`,
`namespace==` + constants.K8sContainerdNamespace,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add double quote for the namespace for consistency.

Actually I can't find a document for this immediately, let's keep it the same with the previous code to make sure it works.

fmt.Sprintf(namespace=="%s", constants.K8sContainerdNamespace)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to switch to manual filter on our side..

@Random-Liu Random-Liu added this to the v1.0 milestone Dec 4, 2018
@mikebrow mikebrow changed the title filter task exits with no id filter task exits no non k8s.io namespaces Dec 4, 2018
@mikebrow mikebrow changed the title filter task exits no non k8s.io namespaces filter events for non k8s.io namespaces Dec 4, 2018
@Random-Liu
Copy link
Member

/lgtm

And we should cherrypick

Signed-off-by: Mike Brown <brownwm@us.ibm.com>
@k8s-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Dec 4, 2018
@mikebrow mikebrow added the lgtm label Dec 4, 2018
@mikebrow
Copy link
Member Author

mikebrow commented Dec 4, 2018

apply lgtm.. only cleaned up the comments..

@mikebrow
Copy link
Member Author

mikebrow commented Dec 4, 2018

some examples.. works good:

DEBU[2018-12-04T16:58:32.866937914-06:00] Received containerd event timestamp - 2018-12-04 22:58:32.866834642 +0000 UTC, namespace - "k8s.io", topic - "/tasks/exit" 
INFO[2018-12-04T16:58:32.867023114-06:00] TaskExit event &TaskExit{ContainerID:15facd79e0d76f089482fc68fb93a86a2ceb1b5bc3a0d5887913dff1980a5bd8,ID:15facd79e0d76f089482fc68fb93a86a2ceb1b5bc3a0d5887913dff1980a5bd8,Pid:21781,ExitStatus:137,ExitedAt:2018-12-04 22:58:32.849277372 +0000 UTC,} 
INFO[2018-12-04T16:58:32.915158898-06:00] shim reaped                                   id=15facd79e0d76f089482fc68fb93a86a2ceb1b5bc3a0d5887913dff1980a5bd8
DEBU[2018-12-04T16:58:32.924834388-06:00] event published                               ns=k8s.io topic="/tasks/delete" type=containerd.events.TaskDelete
INFO[2018-12-04T16:58:32.924859171-06:00] StopPodSandbox for "15f" returns successfully 
INFO[2018-12-04T16:58:41.319307267-06:00] RemovePodSandbox for "15f"                   
DEBU[2018-12-04T16:58:41.323315376-06:00] event published                               ns=k8s.io topic="/snapshot/remove" type=containerd.events.SnapshotRemove
DEBU[2018-12-04T16:58:41.325615875-06:00] event published                               ns=k8s.io topic="/containers/delete" type=containerd.events.ContainerDelete
INFO[2018-12-04T16:58:41.325702524-06:00] RemovePodSandbox "15f" returns successfully  
DEBU[2018-12-04T16:58:41.612929921-06:00] schedule snapshotter cleanup                  snapshotter=overlayfs
DEBU[2018-12-04T16:58:41.615814064-06:00] removed snapshot                              key="k8s.io/3303/61708c81069a51dc1994efa472c9cd5c12dc3dc43a039bde3e8ee8d659695561" snapshotter=overlayfs
DEBU[2018-12-04T16:58:41.617682641-06:00] removed snapshot                              key="k8s.io/3302/c3d4e8ebb1a88f414c14f38e8d987b4f9002aa3af6871ac5c6e59340d1b580b3" snapshotter=overlayfs
DEBU[2018-12-04T16:58:41.619533625-06:00] removed snapshot                              key="k8s.io/3304/15facd79e0d76f089482fc68fb93a86a2ceb1b5bc3a0d5887913dff1980a5bd8" snapshotter=overlayfs
DEBU[2018-12-04T16:58:41.621079004-06:00] snapshot garbage collected                    d=8.087352ms snapshotter=overlayfs
DEBU[2018-12-04T16:58:41.621127367-06:00] garbage collected                             d=4.021299ms
DEBU[2018-12-04T17:09:43.861221422-06:00] (*service).Write started                      expected=sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812 ref="index-sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812" total=2699
DEBU[2018-12-04T17:09:43.869060039-06:00] (*service).Write started                      expected=sha256:915f390a8912e16d4beb8689720a17348f3f6d1a7b659697df850ab625ea29d5 ref="manifest-sha256:915f390a8912e16d4beb8689720a17348f3f6d1a7b659697df850ab625ea29d5" total=527
DEBU[2018-12-04T17:09:43.876878092-06:00] (*service).Write started                      expected=sha256:90e01955edcd85dac7985b72a8374545eac617ccdddcc992b732e43cd42534af ref="layer-sha256:90e01955edcd85dac7985b72a8374545eac617ccdddcc992b732e43cd42534af" total=727978
DEBU[2018-12-04T17:09:43.876878068-06:00] (*service).Write started                      expected=sha256:59788edf1f3e78cd0ebe6ce1446e9d10788225db3dedcfd1a59f764bad2b2690 ref="config-sha256:59788edf1f3e78cd0ebe6ce1446e9d10788225db3dedcfd1a59f764bad2b2690" total=1496
DEBU[2018-12-04T17:09:43.882514683-06:00] create image                                  name="docker.io/library/busybox:latest" target=sha256:2a03a6059f21e150ae84b0973863609494aad70f0a80eaeb64bddd8d92465812
DEBU[2018-12-04T17:09:43.886122860-06:00] event published                               ns=default topic="/images/update" type=containerd.services.images.v1.ImageUpdate
DEBU[2018-12-04T17:09:43.886284187-06:00] Received containerd event timestamp - 2018-12-04 23:09:43.886112495 +0000 UTC, namespace - "default", topic - "/images/update" 
DEBU[2018-12-04T17:09:43.886295728-06:00] Ignoring events in namespace - "default"     

DEBU[2018-12-04T17:10:30.523745645-06:00] event published                               ns=default topic="/tasks/start" type=containerd.events.TaskStart
DEBU[2018-12-04T17:11:23.124164583-06:00] event published                               ns=default topic="/tasks/exit" type=containerd.events.TaskExit
DEBU[2018-12-04T17:11:23.124654089-06:00] Received containerd event timestamp - 2018-12-04 23:11:23.124143978 +0000 UTC, namespace - "default", topic - "/tasks/exit" 
DEBU[2018-12-04T17:11:23.124699541-06:00] Ignoring events in namespace - "default"     

@Random-Liu Random-Liu merged commit db0c4de into containerd:master Dec 5, 2018
Random-Liu added a commit that referenced this pull request Dec 5, 2018
Random-Liu added a commit that referenced this pull request Dec 5, 2018
thaJeztah added a commit to thaJeztah/containerd that referenced this pull request Feb 13, 2019
…06d9200e95

includes backports of:

- containerd/cri#984 filter events for non k8s.io namespaces (resolves firecracker-microvm/firecracker-containerd#35)
- containerd/cri#991 Remove container lifecycle image dependency (fixes containerd/cri#990)
- containerd/cri#1016 [release/1.0] Specify platform for image pull (fixes containerd/cri#1015)
- containerd/cri#1027 Fix the log ending newline handling (fixes containerd/cri#1026)
- containerd/cri#1042 Set /etc/hostname (fixes containerd/cri#1041)
- containerd/cri#1045 Fix env performance issue (fixes containerd/cri#1044)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants