Solr
  1. Solr
  2. SOLR-7545

SOLR_HOST parameter not honoured in bin/solr and SolrCLI

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.2
    • Component/s: None
    • Labels:
      None

      Description

      It seems there are a few places in bin/solr (and maybe SolrCLI class?) where localhost is hardcoded, and hence the SOLR_HOST parameter isn't taking effect. Will add a patch to fix this shortly.

      1. solr.cmd
        48 kB
        Ishan Chattopadhyaya
      2. SOLR-7545_SolrCLI_refactoring.patch
        2 kB
        Ishan Chattopadhyaya
      3. SOLR-7545.patch
        10 kB
        Ishan Chattopadhyaya
      4. SOLR-7545.patch
        10 kB
        Ishan Chattopadhyaya
      5. SOLR-7545.patch
        10 kB
        Ishan Chattopadhyaya
      6. SOLR-7545.patch
        10 kB
        Ishan Chattopadhyaya
      7. SOLR-7545.patch
        10 kB
        Ishan Chattopadhyaya
      8. SOLR-7545.patch
        11 kB
        Ishan Chattopadhyaya

        Activity

        Hide
        Ishan Chattopadhyaya added a comment -

        Here's a patch that makes the hostname configurable with the bin/solr scripts.

        Show
        Ishan Chattopadhyaya added a comment - Here's a patch that makes the hostname configurable with the bin/solr scripts.
        Hide
        Ishan Chattopadhyaya added a comment -

        Previous patch compulsorily set the SOLR_HOST, which had the side effect of starting solr with -Dhost=$SOLR_HOST. Fixed that by adding a new variable HOSTNAME (couldn't think of any other variable name) that uses SOLR_HOST value if set, or else "localhost".

        Show
        Ishan Chattopadhyaya added a comment - Previous patch compulsorily set the SOLR_HOST, which had the side effect of starting solr with -Dhost=$SOLR_HOST. Fixed that by adding a new variable HOSTNAME (couldn't think of any other variable name) that uses SOLR_HOST value if set, or else "localhost".
        Hide
        Shawn Heisey added a comment -

        I'm pretty sure that defaulting to localhost with no other input is a bad idea. SolrCloud uses Java methods to find its own IP address, which I believe normally defaults to the first IP address it finds on the system that's not assigned to a loopback interface. This allows a multi-host cloud to work without configuring hostnames on each system as long as there's only one IP address on each one. If you change that to localhost, then a multi-host cloud will no longer function unless the user explicitly configures the hostname on every system, which would be a serious regression.

        Show
        Shawn Heisey added a comment - I'm pretty sure that defaulting to localhost with no other input is a bad idea. SolrCloud uses Java methods to find its own IP address, which I believe normally defaults to the first IP address it finds on the system that's not assigned to a loopback interface. This allows a multi-host cloud to work without configuring hostnames on each system as long as there's only one IP address on each one. If you change that to localhost, then a multi-host cloud will no longer function unless the user explicitly configures the hostname on every system, which would be a serious regression.
        Hide
        Ishan Chattopadhyaya added a comment -

        The point of this patch is just to remove the hardcoded localhost to the one provided in SOLR_HOST, or else default to localhost. But this is only for connecting to a running solr instance (by use of another variable, HOSTNAME). While starting up solr, the previous behaviour is retained, i.e. use SOLR_HOST if specified but default to IP address based lookup if not specified (by use of -Dhost= param).

        Show
        Ishan Chattopadhyaya added a comment - The point of this patch is just to remove the hardcoded localhost to the one provided in SOLR_HOST, or else default to localhost. But this is only for connecting to a running solr instance (by use of another variable, HOSTNAME). While starting up solr, the previous behaviour is retained, i.e. use SOLR_HOST if specified but default to IP address based lookup if not specified (by use of -Dhost= param).
        Hide
        Anshum Gupta added a comment -

        LGTM. +1

        Show
        Anshum Gupta added a comment - LGTM. +1
        Hide
        Ramkumar Aiyengar added a comment -

        Looks good. Can you replace HOSTNAME with something else? HOSTNAME is a UNIX shell variable set on some systems to the current hostname. SOLR_TOOL_HOST?

        Show
        Ramkumar Aiyengar added a comment - Looks good. Can you replace HOSTNAME with something else? HOSTNAME is a UNIX shell variable set on some systems to the current hostname. SOLR_TOOL_HOST?
        Hide
        Ishan Chattopadhyaya added a comment -

        Ramkumar Aiyengar Thanks for your review. I was at a loss for how to name that variable, and SOLR_TOOL_HOST seems fine I've updated the patch.

        Show
        Ishan Chattopadhyaya added a comment - Ramkumar Aiyengar Thanks for your review. I was at a loss for how to name that variable, and SOLR_TOOL_HOST seems fine I've updated the patch.
        Hide
        Ramkumar Aiyengar added a comment -

        Did you patch solr.cmd against the source or copy across the file and diff? I am getting patch failed due to different line endings..

        Show
        Ramkumar Aiyengar added a comment - Did you patch solr.cmd against the source or copy across the file and diff? I am getting patch failed due to different line endings..
        Hide
        Ishan Chattopadhyaya added a comment -

        Oh. I created the patch in shell (Linux), just applied through Eclipse and applies cleanly. Do you mean there's some unix vs. windows line ending issue (\r\n vs \n)? I'll test on a Windows machine in a while.

        Show
        Ishan Chattopadhyaya added a comment - Oh. I created the patch in shell (Linux), just applied through Eclipse and applies cleanly. Do you mean there's some unix vs. windows line ending issue (\r\n vs \n)? I'll test on a Windows machine in a while.
        Hide
        Ramkumar Aiyengar added a comment -

        I didn't test on Windows as well, depend on you for that This was just that I couldn't apply the patch. May be I will just apply the changes if this doesn't work..

        Show
        Ramkumar Aiyengar added a comment - I didn't test on Windows as well, depend on you for that This was just that I couldn't apply the patch. May be I will just apply the changes if this doesn't work..
        Hide
        Ishan Chattopadhyaya added a comment -

        Just tested to verify it works on Windows. I've attached the full solr.cmd file after the patch.

        Show
        Ishan Chattopadhyaya added a comment - Just tested to verify it works on Windows. I've attached the full solr.cmd file after the patch.
        Hide
        ASF subversion and git services added a comment -

        Commit 1679899 from Ramkumar Aiyengar in branch 'dev/trunk'
        [ https://svn.apache.org/r1679899 ]

        SOLR-7545: Honour SOLR_HOST parameter with bin/solr

        {,.cmd}
        Show
        ASF subversion and git services added a comment - Commit 1679899 from Ramkumar Aiyengar in branch 'dev/trunk' [ https://svn.apache.org/r1679899 ] SOLR-7545 : Honour SOLR_HOST parameter with bin/solr {,.cmd}
        Hide
        ASF subversion and git services added a comment -

        Commit 1679900 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1679900 ]

        SOLR-7545: Honour SOLR_HOST parameter with bin/solr

        {,.cmd}
        Show
        ASF subversion and git services added a comment - Commit 1679900 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1679900 ] SOLR-7545 : Honour SOLR_HOST parameter with bin/solr {,.cmd}
        Hide
        Ramkumar Aiyengar added a comment -

        Committed. Ishan Chattopadhyaya, do you think further changes are needed with SolrCLI?

        Show
        Ramkumar Aiyengar added a comment - Committed. Ishan Chattopadhyaya , do you think further changes are needed with SolrCLI ?
        Hide
        Ishan Chattopadhyaya added a comment -

        Thanks a lot, Ramkumar Aiyengar.
        For SolrCLI, I just had a few minor refactoring changes in mind. I've attached a patch. Nothing blocking or burning, just for future convenience. Please feel free to give it a pass and close the issue.

        Show
        Ishan Chattopadhyaya added a comment - Thanks a lot, Ramkumar Aiyengar . For SolrCLI, I just had a few minor refactoring changes in mind. I've attached a patch. Nothing blocking or burning, just for future convenience. Please feel free to give it a pass and close the issue.
        Hide
        ASF subversion and git services added a comment -

        Commit 1681305 from Ramkumar Aiyengar in branch 'dev/trunk'
        [ https://svn.apache.org/r1681305 ]

        SOLR-7545: Replace some hardcoded occurrences of default URL

        Show
        ASF subversion and git services added a comment - Commit 1681305 from Ramkumar Aiyengar in branch 'dev/trunk' [ https://svn.apache.org/r1681305 ] SOLR-7545 : Replace some hardcoded occurrences of default URL
        Hide
        ASF subversion and git services added a comment -

        Commit 1681307 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1681307 ]

        SOLR-7545: Replace some hardcoded occurrences of default URL

        Show
        ASF subversion and git services added a comment - Commit 1681307 from Ramkumar Aiyengar in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1681307 ] SOLR-7545 : Replace some hardcoded occurrences of default URL
        Hide
        Ramkumar Aiyengar added a comment -

        Thanks Ishan.

        I have now committed the SolrCLI changes as well. I have set the fix version here to be 5.2 (for the main change), but not pushed the SolrCLI to the branch, as it was just a few lines with no functional impact.

        Show
        Ramkumar Aiyengar added a comment - Thanks Ishan. I have now committed the SolrCLI changes as well. I have set the fix version here to be 5.2 (for the main change), but not pushed the SolrCLI to the branch, as it was just a few lines with no functional impact.
        Hide
        Anshum Gupta added a comment -

        Bulk close for 5.2.0.

        Show
        Anshum Gupta added a comment - Bulk close for 5.2.0.

          People

          • Assignee:
            Ramkumar Aiyengar
            Reporter:
            Ishan Chattopadhyaya
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development