Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 306424

Summary: [reconciler] Optionally installed IU not removed when dependent IU is removed
Product: [Eclipse Project] Equinox Reporter: DJ Houghton <dj.houghton>
Component: p2Assignee: DJ Houghton <dj.houghton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: irbull, john.arthorne, leberre, pascal, tjwatson
Version: 3.6   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
3.6 test case none

Description DJ Houghton CLA 2010-03-18 15:06:01 EDT
Consider the following:
- Bundle A requires bundle B
- both A and B are in the dropins folder
- thus both IUs are considered optional
- both are installed

Now delete B from the dropins and start up.

The result is that A is still there (INSTALLED state according to the OSGi console) and both A and B are in the bundles.info file, which is incorrect.

Although A has a strict requirement on B, I would expect A to be uninstalled if B cannot be found since it is only optional.

I debugged the problem and we are creating a profile change request correctly (removing B) but when we pass that to the planner, we do not get back any uninstall operands.

I will construct a simple test case reproducing this.
Comment 1 DJ Houghton CLA 2010-03-18 15:31:55 EDT
Created attachment 162460 [details]
3.6 test case

This is a test case which exhibits the problem.
Comment 2 DJ Houghton CLA 2010-03-18 15:32:50 EDT
Adding Daniel to the CC as he may be interested in this case.
Comment 3 Daniel Le Berre CLA 2010-03-18 16:09:33 EDT
I will take a look at that testcase ASAP.
Comment 4 Daniel Le Berre CLA 2010-03-29 18:40:42 EDT
Here is the pseudo boolean problem sent to SAT4J.

* #variable= 5 #constraint= 4 
min: -9 AbstractVariable: 1108267618 -28 a 1.0.0  ;
a 1.0.0 -> b 1.0.0  ;
AbstractVariable: 1108267618 1269902161327 0.0.0.1269902161327 -> a 1.0.0  ;
AbstractVariable: 1108267618 + AbstractVariable: 1528185295 <= 1 ;
1269902161327 0.0.0.1269902161327 -> AbstractVariable: 1108267618 OR AbstractVariable: 1528185295  ;


There is no mention of B here.

The problem lies either:
1) in the slicer that hides B to the solver.
2) in the profile change request that should consider that something that is no longer in the profile has been removed.
3) in the encoding of optionality :)
Comment 5 DJ Houghton CLA 2010-04-08 17:37:57 EDT
I've released the (disabled) test case to HEAD.
Comment 6 Pascal Rapicault CLA 2010-04-11 09:38:28 EDT
I have reviewed this test case and the behaviour you experience is the expected one (meaning that the test case as written is head is expected to fail). You have to remember that the removal as done through a PCR.remove expresses an intention and not a forced removal. This is consistent with what we do in the other cases where the uninstallation of a lower level IUs does not force the removal of the IUs depending on it (e.g. removing EMF does not force the removal of GMF).
In this particular example, this means that even though you express the desire to have B removed, given that A depends on it and requires it, it will stay. 

Should you desire to force the removal of B (for example because B is no longer on disk in the case of a dropin), you would have to specify a "forced removal" by specifying a negated requirement on the profile change request. For example:
		IRequirement negateB = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, b.getId(), new VersionRange(b.getVersion(), true, b.getVersion(), true), null, 0, 0, false);
		Collection<IRequirement> extraReqs = new ArrayList<IRequirement>();
		extraReqs.add(negateB);
		changeRequest.addExtraRequirements(extraReqs);
Comment 7 John Arthorne CLA 2010-04-12 14:11:34 EDT
See also bug 270195.
Comment 8 DJ Houghton CLA 2010-04-12 16:16:43 EDT
Ok, thanks for the hints. I will review the code and see what I can do about making the reconciler case work.
Comment 9 DJ Houghton CLA 2010-04-12 16:58:20 EDT
Released code in the reconciler to add the forced remove for anything which has been moved. Added test case for this. Also updated and released the planner test case.

Closing.