[SERVER-1690] CLI subcommands produce confusing failures when puppetserver config corrupted Created: 2016/12/05  Updated: 2017/06/28  Resolved: 2016/12/08

Status: Closed
Project: Puppet Server
Component/s: None
Affects Version/s: None
Fix Version/s: SERVER 5.0.0

Type: Bug Priority: Normal
Reporter: Jeremy Barlow Assignee: Jeremy Barlow
Resolution: Fixed Votes: 0
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Team: Systems Engineering
Story Points: 1
Sprint: SE 2016-12-14
Release Notes: Bug Fix
Release Notes Summary: When puppetserver CLI commands were invoked they did not account for errors raised when loading and validating the puppetserver config. Because of this if an invalid configuration was present and a CLI subcommand was run, the subcommand would crash with an unhelpful error message unrelated to the actual config validation failure. This has been fixed so that errors with an unexpected format, such as errors generated while validating the config, are propagated up the stack without modification.
QA Risk Assessment: Needs Assessment

 Description   

When one of the CLI subcommands is run and a puppetserver config file which has content that violates a schema is parsed, the resulting failure shown on the command line does not give any indication of what the real error is.

For example, I ran the following steps in Puppet Server at the 2.7.1 tag, from source:

1) Set the following bogus variable value in the ./dev/puppetserver.conf file:

jruby-puppet: {
  ...
  master-conf-dir: 0
  ...
}

2) Ran the gem subcommand as follows:

lein gem env

Expected Result:

An error message indicating something about the corrupt master-conf-dir variable value.

Actual Result:

Exception in thread "main" java.lang.AssertionError: Assert failed: (keyword? kw), compiling:(/private/var/folders/y5/24bhmms53nv2b4g8gyq6tl340000gn/T/form-init6633389292647995039.clj:1:125)
	at clojure.lang.Compiler.load(Compiler.java:7391)
	at clojure.lang.Compiler.loadFile(Compiler.java:7317)
	at clojure.main$load_script.invokeStatic(main.clj:275)
	at clojure.main$init_opt.invokeStatic(main.clj:277)
	at clojure.main$init_opt.invoke(main.clj:277)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.AssertionError: Assert failed: (keyword? kw)
	at puppetlabs.kitchensink.core$without_ns.invokeStatic(core.clj:572)
	at puppetlabs.kitchensink.core$without_ns.invoke(core.clj:572)
	at puppetlabs.puppetserver.cli.subcommand$run.invokeStatic(subcommand.clj:40)
	at puppetlabs.puppetserver.cli.subcommand$run.invoke(subcommand.clj:26)
	at puppetlabs.puppetserver.cli.gem$_main.invokeStatic(gem.clj:13)
	at puppetlabs.puppetserver.cli.gem$_main.doInvoke(gem.clj:11)
	at clojure.lang.RestFn.invoke(RestFn.java:457)
	at clojure.lang.Var.invoke(Var.java:394)
	at user$eval5.invokeStatic(form-init6633389292647995039.clj:1)
	at user$eval5.invoke(form-init6633389292647995039.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6927)
	at clojure.lang.Compiler.eval(Compiler.java:6917)
	at clojure.lang.Compiler.load(Compiler.java:7379)
	... 14 more



 Comments   
Comment by Jeremy Barlow [ 2016/12/08 ]

Merged to puppetserver#master at 54ec8ff.

Tests all passing through the full Jenkins pipeline: https://jenkins-master-prod-1.delivery.puppetlabs.net/view/puppetserver/view/all/job/platform_puppetserver_integration-system_no-conditional_full-master/51/.

Loaded puppetserver 2.7.2.master.SNAPSHOT.2016.12.08T1059 on a CentOS 7 VM and re-ran the test scenario from the description. Note that the error message is more informative with this change, even if still not the most user-friendly as is the case with Prismatic schema-derived messages in general:

[root@cn8h8nbrs08ubrn ~]# puppetserver gem env
Exception in thread "main" clojure.lang.ExceptionInfo: Output of initialize-puppet-config does not match schema: {:master-conf-dir (not (instance? java.lang.String 0))}...

Generated at Mon Sep 23 06:23:30 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.