Bug 743968

Summary: Candlepin Breaks If Importing Rules Missing Namespaces
Product: [Community] Candlepin Reporter: Devan Goodwin <dgoodwin>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 0.5CC: cduryee, lzap
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-07-17 13:04:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Devan Goodwin 2011-10-06 15:36:01 UTC
Description of problem:

If you attempt to import a manifest.zip with an older rules file (one that does not contain a namespace that exists the code now expects), the import will fail.

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

candlepin-0.4.19-1

How reproducible:

Very

Steps to Reproduce:
1. Generate an manifest.zip on a Candlepin prior to candlepin-0.4.17-1.
2. Attempt to import it on a Candlepin later than 0.4.18.

There are probably easier ways to reproduce too, if you edit default-rules.js in a source checkout, remove the Compliance namespace, and then run the unit tests, you'll see mass failures with the same stack trace.
  
Actual results:

Candlepin will break very badly:

com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, org.fedoraproject.candlepin.policy.js.RuleParseException: org.mozilla.javascript.EcmaError: ReferenceError: "Compliance" is not defined. (rules#24)
  at org.fedoraproject.candlepin.policy.js.compliance.ComplianceRules.<init>(ComplianceRules.java:44)
  while locating org.fedoraproject.candlepin.policy.js.compliance.ComplianceRules
    for parameter 14 at org.fedoraproject.candlepin.controller.CandlepinPoolManager.<init>(CandlepinPoolManager.java:100)
  while locating org.fedoraproject.candlepin.controller.CandlepinPoolManager

1 error
	at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:767)
	at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:793)
	at org.fedoraproject.candlepin.test.DatabaseTestFixture.init(DatabaseTestFixture.java:176)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.fedoraproject.candlepin.policy.js.RuleParseException: org.mozilla.javascript.EcmaError: ReferenceError: "Compliance" is not defined. (rules#24)
	at org.fedoraproject.candlepin.policy.js.JsRules.init(JsRules.java:70)
	at org.fedoraproject.candlepin.policy.js.compliance.ComplianceRules.<init>(ComplianceRules.java:47)
	at org.fedoraproject.candlepin.policy.js.compliance.ComplianceRules$$FastClassByGuice$$5d4dbf30.newInstance(<generated>)
	at com.google.inject.internal.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
	at com.google.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
	at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:85)
	at com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
	at com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
	at com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
	at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:84)
	at com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
	at com.google.inject.InjectorImpl$4$1.call(InjectorImpl.java:758)
	at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
	at com.google.inject.InjectorImpl$4.get(InjectorImpl.java:754)
	... 25 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "Compliance" is not defined. (rules#24)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
	at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717)
	at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1692)
	at org.mozilla.javascript.gen.c1._c5(rules:24)
	at org.mozilla.javascript.gen.c1.call(rules)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
	at org.mozilla.javascript.gen.c1.call(rules)
	at org.fedoraproject.candlepin.policy.js.JsRules.init(JsRules.java:63)
	... 38 more



Expected results:

This is hard to say, it would be nice to be more tolerant of this, but even if we are the app is not going to function properly without those namespaces being there. Not really sure what we should do, if anything...

Comment 1 Devan Goodwin 2011-11-07 13:55:33 UTC
*** Bug 751101 has been marked as a duplicate of this bug. ***

Comment 2 Devan Goodwin 2011-11-10 20:48:09 UTC
Modified the bind rule so manifest consumers cannot see or bind to anything pool derived.

Will appear in candlepin-0.4.26-1:

master: 987f600f1f5e1b3bdf8a8d7ebb0d2c6e4457843f
0.4: e72a8d2da0709e344a3f3c782313563b544696e7

Comment 3 Devan Goodwin 2011-11-10 20:48:32 UTC
Sorry, disregard, wrong bug tab. :(

Comment 4 Devan Goodwin 2012-01-03 15:36:47 UTC
Discussed in email thread, proposed solution is to use the meta.json in the manifest zip. If the version there is less than the version of the candlepin server we're importing into, skip *just* the import of the rules. This will continue using the default rules that came with the newer candlepin rpm.

Comment 5 Chris Duryee 2012-01-11 19:50:12 UTC
53a3a8eea015 master 0.5.9+

QE note: I tested this by taking an older manifest (say, from October) and importing into the latest candlepin, verified the log warning message was printed, then did basic sanity testing to make sure nothing broke, which proved the incompatible rules weren't imported. The log message looks like this (2 lines, at WARN logging):

Incompatible rules: import version {0} older than our version {1}
Manifest data will be imported without rules import.

Comment 6 Bryan Kearney 2012-07-17 13:04:52 UTC
Marking all community bugs modified or beyong as closed.