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

Add check to see if druid is running in kubernetes #17697

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adarshsanjeev
Copy link
Contributor

The PR #16386 changed the docker file to use the canonical hostname instead of ip by default. This was an attempt to fix druid.indexer.task.restoreTasksOnRestart , as it does not work on kubernetes without the canonical hostname.

This change is not backward compatible, as switching to canonical names would not work with docker. This PR attempts to fix this by adding a check to see if the deployment is in a kubernetes environment by checking ${KUBERNETES_SERVICE_HOST} and using canonical hostnames instead of IP addresses only in that case.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

Hmm, why change the name of the variable?

I see that #16386 changed it from DRUID_SET_HOST to DRUID_SET_HOST_IP. I don't see discussion in that PR about why, but changing it back and forth makes it tougher for users to understand what version uses what variable name. IMO better to stick with DRUID_SET_HOST_IP given it was already released that way in Druid 31.

DRUID_SET_HOST=${DRUID_SET_HOST:-1}
else
# Running in kubernetes
DRUID_SET_HOST=${DRUID_SET_HOST:-0}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please include a comment about why the default is different inside and outside of k8s.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@@ -138,8 +138,15 @@ then
setKey _common druid.zk.service.host "${ZOOKEEPER}"
fi

DRUID_SET_HOST_IP=${DRUID_SET_HOST_IP:-0}
if [ "${DRUID_SET_HOST_IP}" = "1" ]
if [ -z ${KUBERNETES_SERVICE_HOST} ]
Copy link
Contributor

Choose a reason for hiding this comment

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

Use [ -z "${KUBERNETES_SERVICE_HOST}" ] instead, it will work better if the variable has whitespace in it. Unlikely but still a good practice with shell scripting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants