Bug 1496179 - Unable to set control policies for Kubernetes Events from OpenShift
Summary: Unable to set control policies for Kubernetes Events from OpenShift
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Control
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Ari Zellner
QA Contact: Einat Pacifici
URL:
Whiteboard: container
Depends On:
Blocks: 1505908 1530651 1530653
TreeView+ depends on / blocked
 
Reported: 2017-09-26 15:26 UTC by myoder
Modified: 2020-12-14 10:14 UTC (History)
9 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1505908 1530651 1530653 (view as bug list)
Environment:
Last Closed: 2018-06-21 20:49:29 UTC
Category: Bug
Cloudforms Team: Container Management
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description myoder 2017-09-26 15:26:37 UTC
Description of problem:

Looking to have a control policy to be triggered on specific OpenShift events, such as CONTAINER_KILLING, CONTAINER_CREATED, etc.

I have created a control policy for each object (Host, VM, Replicator, etc) and enabled all Container events, and attached it to a policy profile and attached that to my OpenShift provider.

In a test environment 10.13.145.142 admin:smartvm

Events Processed in Automate:
    492 CONTAINER_CREATED
      5 CONTAINER_FAILED
      5 CONTAINER_KILLING
    477 CONTAINER_STARTED
      5 POD_FAILEDSCHEDULING
     78 POD_SCHEDULED
     77 REPLICATOR_SUCCESSFULCREATE

Policies Triggered:
     20 container-image-control
      1 pod-control
     77 replicator-control

You can see many events are processed, but only certain events trigger a control policy.


Version-Release number of selected component (if applicable):
5.8.1.5

How reproducible:
Always

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Greg McCullough 2017-09-27 19:46:22 UTC
Lucy - Can you take a first pass at this and see if we need someone from the container team review?

Comment 3 Federico Simoncelli 2017-09-28 08:07:07 UTC
Beni is this similar to (or even a duplicate of) bug 1489616?

Comment 4 Beni Paskin-Cherniavsky 2017-09-28 09:18:24 UTC
If the problem is only CONTAINER_* events:
Working as Designed, but confusing, probably worth implementing.
CONTAINER_* are collected as EmsEvents, but there is no Automate definitions
triggering policy MiqEvent.

https://github.com/ManageIQ/manageiq-content/tree/master/content/automate/ManageIQ/System/Event/EmsEvent/Kubernetes.class/

- CONTAINER_* do event_action_refresh
- POD_* do event_action_refresh & event_action_policy
- REPLICATOR_* do event_action_refresh & event_action_policy
- NODE_* do event_action_refresh & event_action_policy

I believe these 4 are everything we collect.
https://github.com/ManageIQ/manageiq-providers-kubernetes/blob/master/app/models/manageiq/providers/kubernetes/container_manager/event_catcher_mixin.rb
(on kubernetes/openshift side these are just Pod, Replicator, Node, our event catchers translates Pod events that identify a specific container into CONTAINER_* instead of POD_* EmsEvent.)

Federico, when I implemented container policies, you said to support just Pods, Nodes, Replicators.  Were container events deliberately excluded?
Or now that I think of it, did I misundertood you and you meant all openshift Pod events, which on our side should include both Pod and Container policies?

Comment 5 Federico Simoncelli 2017-10-02 21:53:41 UTC
(In reply to Beni Paskin-Cherniavsky from comment #4)
> Federico, when I implemented container policies, you said to support just
> Pods, Nodes, Replicators.  Were container events deliberately excluded?
> Or now that I think of it, did I misundertood you and you meant all
> openshift Pod events, which on our side should include both Pod and
> Container policies?

Argh, yes, in terms of writing policies we want to support Pods, Nodes and Replicators but it doesn't mean they're 1:1 with events that are raised.

How long would it take to make the CONTAINER event trigger the Pods Policies?

Comment 6 Beni Paskin-Cherniavsky 2017-10-03 21:09:09 UTC
Trigger Pod policies — nice!  I expect it to be very easy.
Create the automate yamls, and possibly tweak function finding event target.
Only laborous part will be checking it actually works for each possible event.

(If OTOH you wanted to support Container policies, that would add UI work)

Comment 9 Beni Paskin-Cherniavsky 2017-11-15 10:32:54 UTC
There is a mild but sticky benefit to doing the extra work to add Container Policies rather than tying these events to Pod Policies:
If condition target is a specific container, you to ask question about that specific container (eg. this container restart count > 5 AND this container hourly max memory > 1GB).
If target is pod, you can only ask about the pod, and some things about ALL its containers.
I don't know if that has any actual use case.

The catch:
if we now decide this benefit is negligible and tie this to Pod Policies, and later discover a stronger use case and need to switch to Container Policies, it will be nearly **impossible to migrate** existing Pod Policies.
(there is very little ability to introspect MiqExpression, only to evaluate it.  transforming expressions to be around a different subject would be a research project...)

So, what should it be?

Comment 10 Federico Simoncelli 2017-11-20 10:40:26 UTC
(In reply to Beni Paskin-Cherniavsky from comment #9)
> if we now decide this benefit is negligible and tie this to Pod Policies,
> and later discover a stronger use case and need to switch to Container
> Policies, it will be nearly **impossible to migrate** existing Pod Policies.

Can't you route the same event to two objects?

E.g. today we implement the Pod support (routing the event to the Pod), users will start writing their Pod-based policies. Tomorrow we'll route the event to Containers as well and we'll enable more granular policies to be written without invalidating the old ones (the Pod-based ones).

Comment 11 Ari Zellner 2017-11-26 09:34:58 UTC
(In reply to Federico Simoncelli from comment #10)

> Can't you route the same event to two objects?

For infra you can create a policy for a VM and attach the policy to the Host, Cluster or Provider of the VM. To have something similar, I think this requires us to go with attaching events to containers since we need to create the policy for them.

Comment 12 Barak 2017-11-28 11:00:08 UTC
After discussion with Federico,
My conclusion is to go currently only with POD policy (for container events),
ManageIQ currently can not facilitate container level operations or policies (even no UI for it).
If such a need will come up in the future it will be discussed (along with possible racy situation where an event is routed to both policies)

Comment 15 Ari Zellner 2017-12-21 15:05:01 UTC
Note: theres an IMPORTANT limitation here

These events will trigger policies ONLY IF their target(pod in this scenario)  is in the DB. events like "pod container created" will not be picked up and will still generate an "Unable to find target" error message. 
this is because in most cases the pod will not be in the DB before the container created event is received.

Comment 16 Ari Zellner 2017-12-21 15:07:27 UTC
(In reply to Ari Zellner from comment #15)
> Note: theres an IMPORTANT limitation here
> 
> These events will trigger policies ONLY IF their target(pod in this
> scenario)  is in the DB. events like "pod container created" will not be
> picked up and will still generate an "Unable to find target" error message. 
> this is because in most cases the pod will not be in the DB before the
> container created event is received.

BZ for this problem is https://bugzilla.redhat.com/show_bug.cgi?id=1367114


Note You need to log in before you can comment on or make changes to this bug.