NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.48k stars 13.67k forks source link

gocd-server and gocd-agent hard-code jre in script (and it's not a compatible version) #136511

Open Thra11 opened 3 years ago

Thra11 commented 3 years ago

Describe the bug

In NixOS 21.05 (and probably unstable too), the version of jre is not supported by the gocd-server and gocd-agent versions, and there's no way for the user to choose a different one.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Enable gocd-server in your configuration: services.gocd-server.enable = true;
  2. Run nixos-rebuild switch
  3. Run systemctl status gocd-server. The output is:
    
    ● gocd-server.service - GoCD Server
     Loaded: loaded (/nix/store/cjx4fsk53vgn69zxjqsq71rk41f9lla3-unit-gocd-server.service/gocd-server.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2021-09-02 21:13:09 BST; 1h 5min ago
    Process: 1040 ExecStart=/nix/store/nqb0ixadyh0wvvx7svx8ql2m5zrlr2s3-unit-script-gocd-server-start/bin/gocd-server-start (code=exited, status=1/FAILURE)
    Main PID: 1040 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 2.261s

Sep 02 21:13:06 systemd[1]: Started GoCD Server. Sep 02 21:13:08 gocd-server-start[1051]: [Thu Sep 02 21:13:07 BST 2021] Starting process: Sep 02 21:13:08 gocd-server-start[1051]: [Thu Sep 02 21:13:08 BST 2021] Working directory : /var/lib/go-server Sep 02 21:13:08 gocd-server-start[1051]: [Thu Sep 02 21:13:08 BST 2021] Application arguments: [] Sep 02 21:13:08 gocd-server-start[1051]: [Thu Sep 02 21:13:08 BST 2021] GoCD Version: 19.3.0-8959 Sep 02 21:13:09 gocd-server-start[1051]: Running GoCD requires Java version >= VERSION_1_8 and <= 12. You are currently running with Java version 13. GoCD will now exit! Sep 02 21:13:09 systemd[1]: gocd-server.service: Main process exited, code=exited, status=1/FAILURE Sep 02 21:13:09 systemd[1]: gocd-server.service: Failed with result 'exit-code'. Sep 02 21:13:09 systemd[1]: gocd-server.service: Consumed 2.261s CPU time, no IP traffic.

4. See that there's an option, [`services.gocd-server.packages`](https://search.nixos.org/options?channel=21.05&from=0&size=50&sort=relevance&type=packages&query=gocd), whose default value includes `pkgs.jre`. Try overriding it to use an older version of java:
gocd-server.packages = with pkgs; lib.mkDefault [
  stdenv jre8 git config.programs.ssh.package nix
];
5. nixos-rebuild switch
6. gocd-server ins't automatically restarted. No change to the version error, even after manually restarting.

Turns out the script used to launch the service from `nixos/modules/services/continuous-integration/gocd-server/default.nix` always uses `pkgs.jre`:
```nix
      script = ''
        ${pkgs.git}/bin/git config --global --add http.sslCAinfo /etc/ssl/certs/ca-certificates.crt
        ${pkgs.jre}/bin/java -server ${concatStringsSep " " cfg.startupOptions} \
                               ${concatStringsSep " " cfg.extraOptions}  \
                              -jar ${pkgs.gocd-server}/go-server/go.jar
      '';

Expected behavior

The version of java used in the script should be something that works, and/or there should be an option for the user to choose the java package (I've seen some other nixos modules which do this, given the wide variety of different java package versions, vendors and licenses). I don't know if there are any potential issues with having different versions of java used in the script and the path.

Notify maintainers

@swarren83

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"aarch64-linux"`
 - host os: `Linux 5.12.7, NixOS, 21.05.20210821.a188b85 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210802_47e96bb`
 - nixpkgs: `/home/thrall/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: gocd-server gocd-agent
voanhduy1512 commented 3 years ago

https://github.com/NixOS/nixpkgs/pull/133901 should fix this issue

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info