Bug 1417935

Summary: VM to host affinity : conflict detection mechanism
Product: [oVirt] ovirt-engine Reporter: Yanir Quinn <yquinn>
Component: Backend.CoreAssignee: Yanir Quinn <yquinn>
Status: CLOSED CURRENTRELEASE QA Contact: Artyom <alukiano>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.0CC: bugs, mgoldboi, yquinn
Target Milestone: ovirt-4.1.1Keywords: Triaged
Target Release: 4.1.1.3Flags: rule-engine: ovirt-4.1+
rule-engine: exception+
mgoldboi: planning_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Affinity conflicts detection mechanism was missing for VM to host affinity feature Consequence: In case there were conflicts that resulted from 2 or more affinity groups with VM to host and VM to VM affinity, the user wouldn't get any warnings about these conflicts (although they would not necessarily interrupt the normal flow of the system) Fix: Conflict detection mechanism was added to the rule enforcement manager flow and when adding/editing affinity groups via UI or SDK. the following conflicts are checked: 1.Hosts that have enforcing positive and negative affinity conflicts 2.Hosts that have positive and negative affinity conflicts. 3.Non intersecting hosts conflicts. 4.VM to host affinity with positive VM to VM conflicts. 5.VM to host affinity with negative VM to VM conflicts Result: For (1) - If adding/editing an affinity group causes that conflict, the user will get an error that states he cannot add/edit the current affinity group due to that conflict For the other conflicts, when detected, a warning message will appear in UI (audit log) when adding/editing an affinity group and in engine.log when the conflict is detected in the affinity rule enforcer process (here, the conflict check is done if the rule enforcer find a candidate VM for migration)
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-21 09:42:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: SLA RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yanir Quinn 2017-01-31 13:02:04 UTC
Add a conflict detection mechanism to detected restricting and non restricting conflicts caused by new and exiting affinity groups.
Error messages will be prompt when a new affinity group cannot be created via REST/SDK for VM to host affinity due to these conflicts.
Warning messages will be prompt in REST/SDK and in engine.log as part of the Affinity rule enforcer manager with existing and possible conflicts.

Comment 1 Artyom 2017-03-13 09:01:29 UTC
Hi Yanir, can you please specify cases, when the error will appear and when the warning will appear?

Comment 2 Yanir Quinn 2017-03-13 09:09:22 UTC
(In reply to Artyom from comment #1)
> Hi Yanir, can you please specify cases, when the error will appear and when
> the warning will appear?

The cases are mentioned in the doc text. 
In addition you can view them on the slides/video:

https://mojo.redhat.com/docs/DOC-1130159-vm-to-host-affinity
(pages 25,26 on VM to host affinity.odp)

Comment 3 Yanir Quinn 2017-03-13 09:13:55 UTC
(In reply to Yanir Quinn from comment #2)
> (In reply to Artyom from comment #1)
> > Hi Yanir, can you please specify cases, when the error will appear and when
> > the warning will appear?
> 
> The cases are mentioned in the doc text. 
> In addition you can view them on the slides/video:
> 
> https://mojo.redhat.com/docs/DOC-1130159-vm-to-host-affinity
> (pages 25,26 on VM to host affinity.odp)

Just to clarify about Error and Warning messages.
Error will appear only when you try to define a new enforcing vm to host affinity group that conflict with an existing enforcing vm to host affinity group
(e.g.  VM_A + Host_A  exists and you try to add VM_A - Host_A) 
you will not be allowed to add the affinity group in this case.

the rest of the use cases will not result in an error, the affinity groups will be added and you will get an error in audit.log and engine.log (engine log errors will appear from the affinity rule enforcer when it will find a vm to migrate - find vm to migrate and warn about conflicts)

Comment 4 Yanir Quinn 2017-03-13 09:16:55 UTC
(In reply to Yanir Quinn from comment #3)
> (In reply to Yanir Quinn from comment #2)
> > (In reply to Artyom from comment #1)
> > > Hi Yanir, can you please specify cases, when the error will appear and when
> > > the warning will appear?
> > 
> > The cases are mentioned in the doc text. 
> > In addition you can view them on the slides/video:
> > 
> > https://mojo.redhat.com/docs/DOC-1130159-vm-to-host-affinity
> > (pages 25,26 on VM to host affinity.odp)
> 
> Just to clarify about Error and Warning messages.
> Error will appear only when you try to define a new enforcing vm to host
> affinity group that conflict with an existing enforcing vm to host affinity
> group
> (e.g.  VM_A + Host_A  exists and you try to add VM_A - Host_A) 
> you will not be allowed to add the affinity group in this case.
> 
> the rest of the use cases will not result in an error, the affinity groups
> will be added and you will get a Warning in audit.log and engine.log (engine
> log Warnings will appear from the affinity rule enforcer when it will find a
> vm to migrate - find vm to migrate and warn about conflicts)

Comment 5 Artyom 2017-03-15 09:17:42 UTC
Verified on rhevm-4.1.1.4-0.1.el7.noarch

Scenario 1
==========
affinity_group_1 - hard,positive
    hosts - host1
    vms - vm1
affinity_group_2 - hard,positive
    vms - vm1,vm2
affinity_group_3 - hard,negative
    hosts - host1
    vms - vm2

017-03-15 05:06:57,134-04 WARN  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-21) [ddfb2b76-e9f1-4651-8725-613cd521cc6b] EVENT_ID: VM_TO_HOST_CONFLICTS_POSITIVE_VM_TO_VM_AFFINITY(10,358), Correlation ID: ddfb2b76-e9f1-4651-8725-613cd521cc6b, Call Stack: null, Custom Event ID: -1, Message: The affinity groups: test_3,test_1, with hosts : 2411f6f7-b0dd-4413-a1b5-cc0d039fd82b and VMs: f3ee19f2-8f89-43a9-ba10-445c10e861f2,a22df7a0-b4ec-4fb7-aa6d-aa9572dffdbb, have conflicts between VM to host affinity and VM to VM positive affinity.


Scenario 2
==========
affinity_group_1 - hard,positive
    hosts - host1
    vms - vm1
affinity_group_2 - hard,negative
    hosts - host1
    vms - vm1

<fault>
<detail>[action type failed affinity hosts rules collision, affinitygroups: test 1,test 2, hosts: 2411f6f7-b0dd-4413-a1b5-cc0d039fd82b, vms: a22df7a0-b4ec-4fb7-aa6d-aa9572dffdbb]</detail>
<reason>Operation Failed</reason>
</fault>


Scenario 3
==========
affinity_group_1 - hard,positive
    hosts - host1
    vms - vm1
affinity_group_2 - soft,negative
    hosts - host1
    vms - vm1


2017-03-15 05:15:13,506-04 WARN  [org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector] (default task-2) [ef9b272f-05cf-407c-be31-bcfb9d540cb8] EVENT_ID: VM_TO_HOST_CONFLICT_IN_POSITIVE_AND_NEGATIVE_AFFINITY(10,357), Correlation ID: ef9b272f-05cf-407c-be31-bcfb9d540cb8, Call Stack: null, Custom Event ID: -1, Message: The affinity groups: test_1,test_2, with hosts: 2411f6f7-b0dd-4413-a1b5-cc0d039fd82b and VMs: a22df7a0-b4ec-4fb7-aa6d-aa9572dffdbb, have VM to host conflicts between positive and negative affinity groups.