Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use virtual Java packages on Red Hat and set java_bin #627

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,24 @@ Note that the symble `:ezbake` is not strictly necessary here.
Composite EZBake projects usually do not define their own services but rather
provide a list of dependencies which themselves define TK services. Because of
this it is not strictly necessary to define a profile such as `:ezbake` shown
above; although it is conceivable that such a composite project may define its
own services, it is unlikely and ill-advised because no one likes blurred lines
in architectural diagrams. Just look at the Leaning Tower of Pisa.
above.

If the composite project needs to define build time templates, such as `resources/ext/cli_defaults/cli-defaults.sh.erb`
EZbake will only include items that are in jars on the class path at the time
the project is staged. As a result, the project must include a self-referential dependency
in the `ezbake` profile. This will allow ezbake to discover these files correctly.
```clojure
(def my-project-version "0.0.1-SNAPSHOT")

(defproject somenamespace/myproject my-project-version
...
:profiles {
...
:ezbake {:dependencies [[mynamespace/myproject ~my-project-version]]}
...
}
)
```

#### Additional Uberjars

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Init settings for <%= EZBake::Config[:project] %>
###########################################

# Location of your Java binary (version 8)
JAVA_BIN="/usr/bin/java"
# Location of your Java binary
#JAVA_BIN=""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found out that the puppetserver bin (which I can't find the source of now) also reads the defaults file. If that needs JAVA_BIN then this change is breaking.


# Modify this if you'd like to change the memory allocation, enable JMX, etc
JAVA_ARGS="<%= EZBake::Config[:java_args] %>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#set default privileges to -rw-r-----
umask 027

JAVA_BIN=<%= EZBake::Config[:java_bin] %>

# You should only need to edit the default/<%= EZBake::Config[:project] %> file and not
# this init script directly
if [ -r "/etc/default/<%= EZBake::Config[:project] %>" ] ; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Wants=<%= EZBake::Config[:start_after].map {|dep| "#{dep}.service" }.join(" ") %

[Service]
Type=forking
Environment=JAVA_BIN="<%= EZBake::Config[:java_bin] %>"
EnvironmentFile=/etc/default/<%= EZBake::Config[:project] %>
User=<%= EZBake::Config[:user] %>
TimeoutStartSec=<%= EZBake::Config[:start_timeout] %>
Expand Down
36 changes: 20 additions & 16 deletions resources/puppetlabs/lein-ezbake/template/global/ext/fpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
options.old_sles = 0
options.sles = 0
options.java = 'java-1.8.0-openjdk-headless'
options.java_bin = '/usr/bin/java'
options.release = 1
options.platform_version = 0
options.is_pe = false
Expand Down Expand Up @@ -181,25 +182,28 @@
options.systemd_el = 1
elsif options.operating_system == :el && options.os_version >= 7 # systemd el
if ! options.is_pe
# https://bugzilla.redhat.com/show_bug.cgi?id=2224427
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug is resolved, so it could be dropped. But this at least provides a reference of why it's there.

fpm_opts << "--depends tzdata-java"
options.java =
case options.platform_version
when 8
# rpm on Redhat 7 may not support OR dependencies
if options.os_version == 7
'java-11-openjdk-headless'
elsif options.os_version == 8
'(java-17-openjdk-headless or java-11-openjdk-headless)'
elsif options.os_version == 9
'java-17-openjdk-headless'
else
fail "Unrecognized el os version #{options.os_version}"
end
when 6..7
'java-1.8.0-openjdk-headless'
case options.platform_version
when 8
# rpm on Redhat 7 may not support OR dependencies
if options.os_version == 7
options.java = 'jre-11-headless'
options.java_bin = '/usr/lib/jvm/jre-11/bin/java'
elsif options.os_version == 8
options.java = '(jre-17-headless or jre-11-headless)'
# TODO: which bin to use? /usr/bin/java may be anything
elsif options.os_version == 9
options.java = 'jre-17-headless'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can question why EL 9 always uses Java 17 while EL 8 uses 17 or 11. Both EL 8 and EL 9 provide both versions.

Copy link
Contributor

@austb austb Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can blame me for that one. At the time I did this because I wanted to require 17 where possible because it lined up with what we are using in PE and most heavily testing, but from what I could tell the initial releases of EL 8 were before Java 17 was released and would have only had 11.

options.java_bin = '/usr/lib/jvm/jre-17/bin/java'
else
fail "Unknown Puppet Platform Version #{options.platform_version}"
fail "Unrecognized el os version #{options.os_version}"
end
when 6..7
options.java = 'java-1.8.0-openjdk-headless'
else
fail "Unknown Puppet Platform Version #{options.platform_version}"
end
end

options.systemd = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Wants=<%= EZBake::Config[:start_after].map {|dep| "#{dep}.service" }.join(" ") %

[Service]
Type=forking
Environment=JAVA_BIN="<%= EZBake::Config[:java_bin] %>"
EnvironmentFile=/etc/sysconfig/<%= EZBake::Config[:project] %>
User=<%= EZBake::Config[:user] %>
TimeoutStartSec=<%= EZBake::Config[:start_timeout] %>
Expand Down