INTPAK-117 Fixes configuring Java Opts 83/68783/3
authorTim Rozet <trozet@redhat.com>
Mon, 26 Feb 2018 19:42:32 +0000 (14:42 -0500)
committerTim Rozet <trozet@redhat.com>
Mon, 5 Mar 2018 15:35:51 +0000 (10:35 -0500)
Migrates configuring Java Options to a more appropriate variable,
"JAVA_OPTS" which is read by karaf as optional settings a user may
provide.  The change also includes moving the configuration by setting
the variable in the karaf file itself, rather than in systemd.  This
allows support for non-systemd OSes and deployment tools.

Change-Id: I2fd3c2a70e8d5f0f0645bc9e354a535d05526fd3
Signed-off-by: Tim Rozet <trozet@redhat.com>
CHANGELOG
manifests/config.pp
manifests/install.pp
metadata.json
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index 1dd2577449532da12acc35e4c36e7ab731e23c92..2a87e889daae577c94ded8e20fd955b15d4bd1d2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -66,3 +66,5 @@
 - Move to using log4j2
 2018-02-26 Release 8.0.1
 - Fix ODL listening on default port when alternate port specified
+2018-03-05 Release 8.1.0
+- Configure Java Options via karaf instead of Systemd
index f41957bd7c17b4a2ab4d196259d14cdf72d1cab4..d309c8f9837d47137fe9118cd5296d8580449ac9 100644 (file)
@@ -19,6 +19,15 @@ class opendaylight::config {
     match => '^featuresBoot=.*$',
   }
 
+  # Modify karaf to include Java options
+  file_line {'Karaf Java Options':
+    ensure => present,
+    path   => '/opt/opendaylight/bin/karaf',
+    line   => "JAVA_OPTS=${opendaylight::java_opts}",
+    match  => '^JAVA_OPTS=.*$',
+    after  => '^PROGNAME=.*$'
+  }
+
   file { 'org.ops4j.pax.web.cfg':
     ensure => file,
     path   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
index 6f59c1f219b2fee5c3123b71354d11bc30216e4f..e8cd8d89b897c213355d23e02f3f603666527faf 100644 (file)
@@ -15,20 +15,4 @@ class opendaylight::install {
     ensure  => present,
   }
 
-  if $::osfamily == 'RedHat' {
-    # Configure the systemd file with Java options
-    file_line { 'java_options_systemd':
-      ensure  => present,
-      path    => '/usr/lib/systemd/system/opendaylight.service',
-      line    => "Environment=_JAVA_OPTIONS=\'${::opendaylight::java_opts}\'",
-      match   => '^Environment.*',
-      after   => 'ExecStart=/opt/opendaylight/bin/start',
-      require => Package['opendaylight'],
-    }
-    ~> exec {'reload_systemd_units':
-      command     => 'systemctl daemon-reload',
-      path        => '/bin',
-      refreshonly => true,
-    }
-  }
 }
index 500e526ff6cc09885a0a291cc62ffd6ff3142811..11b019b9e7b25137b38adf6a353985216c3c0538 100644 (file)
@@ -1,6 +1,6 @@
 {
     "name": "opendaylight-opendaylight",
-    "version": "8.0.1",
+    "version": "8.1.0",
     "author": "Daniel Farrell",
     "summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
     "license": "BSD-2-Clause",
index 37d9b384226430ba535162cfb9b927bd43981338..5d60a6500c40fefbe989f979d602fd8f7585e0d2 100644 (file)
@@ -13,7 +13,9 @@ RSpec::Puppet::Coverage.filters.push(*custom_filters)
 #
 
 # Tests that are common to all possible configurations
-def generic_tests()
+def generic_tests(options = {})
+  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+
   # Confirm that module compiles
   it { should compile }
   it { should compile.with_all_deps }
@@ -59,6 +61,17 @@ def generic_tests()
       'group'   => 'odl',
     )
   }
+
+  it {
+    should contain_file_line('Karaf Java Options').with(
+      'ensure' => 'present',
+      'path'   => '/opt/opendaylight/bin/karaf',
+      'line'   => "JAVA_OPTS=#{java_opts}",
+      'match'  => '^JAVA_OPTS=.*$',
+      'after'  => '^PROGNAME=.*$'
+    )
+  }
+
 end
 
 # Shared tests that specialize in testing log file size and rollover
@@ -272,7 +285,7 @@ end
 def rpm_install_tests(options = {})
   # Extract params
   rpm_repo = options.fetch(:rpm_repo, 'https://nexus.opendaylight.org/content/repositories/opendaylight-oxygen-epel-7-$basearch-devel')
-  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+
 
   # Default to CentOS 7 Yum repo URL
 
@@ -300,15 +313,6 @@ def rpm_install_tests(options = {})
       'ensure'   => 'present',
     )
   }
-
-  it {
-    should contain_file_line('java_options_systemd').with(
-      'ensure' => 'present',
-      'path' => '/usr/lib/systemd/system/opendaylight.service',
-      'line' => "Environment=_JAVA_OPTIONS=\'#{java_opts}\'",
-      'after' => 'ExecStart=/opt/opendaylight/bin/start',
-    )
-  }
 end
 
 def deb_install_tests(options = {})
index 8586519f3ebcf257b2c8b1a700b82fb3865d501a..16b5045447cc0688acc08209162aef8b900ad94c 100644 (file)
@@ -108,7 +108,9 @@ end
 
 # Shared function that handles generic validations
 # These should be common for all odl class param combos
-def generic_validations()
+def generic_validations(options = {})
+  java_opts = options.fetch(:java_opts, '-Djava.net.preferIPv4Stack=true')
+
   # Verify ODL's directory
   describe file('/opt/opendaylight/') do
     it { should be_directory }
@@ -159,6 +161,14 @@ def generic_validations()
     it { should be_grouped_into 'odl' }
   end
 
+  # Should contain karaf file with Java options set
+  describe file('/opt/opendaylight/bin/karaf') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /^JAVA_OPTS=#{java_opts}$/ }
+  end
+
   # Should contain ODL NB port config file
   describe file('/opt/opendaylight/etc/jetty.xml') do
     it { should be_file }