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

Unable to detect openjdk java verion. #6081

Closed
Magicloud opened this issue Aug 6, 2019 · 4 comments · Fixed by #10765
Closed

Unable to detect openjdk java verion. #6081

Magicloud opened this issue Aug 6, 2019 · 4 comments · Fixed by #10765
Labels

Comments

@Magicloud
Copy link

Nomad version

v0.9.4

Operating system and Environment details

CentOS 7

Issue

I cannot use driver.java.version constraint since it cannot get valid nodes.

Reproduction steps

Use following driver and contraint.

      driver = "java"
      constraint {
        attribute = "${driver.java.version}"
        operator  = ">="
        value     = "11.0.0"
      }

Without the contraint (comment the whole object), task running fine. With the contraint, I got

Constraint "${driver.java.version} >= 11.0.0" filtered 1 nodes

While java version is:

openjdk version "11.0.4" 2019-07-16 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)
@tgross
Copy link
Member

tgross commented Aug 8, 2019

Hello @Magicloud, thanks for your report!
I was able to partially reproduce what you’re seeing as follows:

$ docker run -it centos:7 /bin/bash
[root@b08656f9475b /]# yum install java-11-openjdk curl unzip
[root@b08656f9475b /]# curl -o nomad.zip https://releases.hashicorp.com/nomad/0.9.4/nomad_0.9.4_linux_amd64.zip
[root@b08656f9475b /]# unzip nomad.zip
[root@b08656f9475b /]# ./nomad agent -dev

and then submit the following job:

job "example" {
  datacenters = ["dc1"]

  type = "service"
  constraint {
    attribute = "${driver.java.version}"
    operator  = ">="
    value     = "11.0.0"
  }

  group "example" {
    task "example" {
      driver = "java"
      config {
        jar_path    = "local/hello.jar"
        jvm_options = ["-Xmx2048m", "-Xms256m"]
      }
    }
  }
}

which returned the following:

[root@b08656f9475b /]# ./nomad job run ./java.nomad
==> Monitoring evaluation "cda32b2b"
    Evaluation triggered by job "example"
    Evaluation status changed: "pending" -> "complete"
==> Evaluation "cda32b2b" finished with status "complete" but failed to place all allocations:
    Task Group "example" (failed to place 1 allocation):
      * Constraint "${driver.java.version} > 11.0.0" filtered 1 nodes
    Evaluation "5a36988b" waiting for additional capacity to place remainder

when I do java --version I get:

[root@b08656f9475b /]# java --version
openjdk 11.0.4 2019-07-16 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)

It looks like this version of the JDK doesn’t include " around the version and that’s throwing off the regex we use to parse the version; if I put this string into our unit tests for the java version parsing, I see the version doesn’t come back as 11.0.4 as I’d expect. But that version string isn’t quite what you’re showing in your report. Can you confirm whether you ran that java --version command on the client?

@Magicloud
Copy link
Author

Yes, my bad. I pasted java version strings from wrong term. The CentOS one is like yours, no quotes.

@chriswhite199
Copy link

chriswhite199 commented Nov 7, 2019

I have a similar issue to this - java driver is not detecting for the following:

openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)

Client in the UI shows java detected: No.

Is there any debug logging i can enable to help diagnose?

Update: NVM, verbose node status shows my issue is that i'm not running nomad as root.

@tgross tgross added this to the near-term milestone Nov 7, 2019
@tgross tgross modified the milestones: near-term, unscheduled Jan 9, 2020
@schmichael schmichael added the stage/needs-verification Issue needs verifying it still exists label Sep 23, 2020
@tgross tgross removed this from the unscheduled milestone Feb 12, 2021
shoenig added a commit that referenced this issue Jun 15, 2021
This PR improves the regular expression used for matching the java
version string, which varies a lot depending on the java vendor and
version.

These are the example strings we now test for:

java version "1.7.0_80"
openjdk version "11.0.1" 2018-10-16
openjdk version "11.0.1" 2018-10-16
java version "1.6.0_36"
openjdk version "1.8.0_192"
openjdk 11.0.11 2021-04-20 LTS

The last one is a new test added on behalf of #6081, which is
still broken on today's CentOS 7 default JDK package.

openjdk 11.0.11 2021-04-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.11+9-LTS, mixed mode, sharing)

==> Evaluation "21c6caf7" finished with status "complete" but failed to place all allocations:
    Task Group "example" (failed to place 1 allocation):
      * Constraint "${driver.java.version} >= 11.0.0": 1 nodes excluded by filter
    Evaluation "2b737d48" waiting for additional capacity to place remainder

Fixes #6081
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants