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

Parser wait for template functionality does not work correctly #248

Open
ivan-sap opened this issue Sep 12, 2016 · 2 comments · May be fixed by #249
Open

Parser wait for template functionality does not work correctly #248

ivan-sap opened this issue Sep 12, 2016 · 2 comments · May be fixed by #249

Comments

@ivan-sap
Copy link

Parser wait for template functionality does not work correctly. It does not wait for any template, because of bogus wait implementation.

The following code should wait for specific template to be available in ElasticSearch [1]

function wait_for_template {
  local template_name="$1"
  local MASTER_URL="<%= p("logstash.output.elasticsearch.data_hosts").first %>:9200"

  set +e
  while true;  do
    echo "Waiting for index template to be uploaded: $template_name"
    curl -X HEAD -f -i "$MASTER_URL"/_template/$template_name > /dev/null 2>&1
    [ $? ] && break
    sleep 5
  done
  set -e
  echo "Found $template_name"
}

But actually the [ $? ] && break statement is fully evaluated, which causes the loop to break, even if the curl exited with a non-zero status. Changing the statement to [ $? -eq 0 ] && break should do the trick.

[1]

function wait_for_template {
local template_name="$1"
local MASTER_URL="<%= p("logstash.output.elasticsearch.data_hosts").first %>:9200"
set +e
while true; do
echo "Waiting for index template to be uploaded: $template_name"
curl -X HEAD -f -i "$MASTER_URL"/_template/$template_name > /dev/null 2>&1
[ $? ] && break
sleep 5
done
set -e
echo "Found $template_name"
}

@cf-gitbot
Copy link
Collaborator

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

nmaslarski pushed a commit to nmaslarski/logsearch-boshrelease that referenced this issue Sep 13, 2016
This fixes logsearch#248.

Signed-off-by: Nikolay Maslarski <[email protected]>
@ivan-sap ivan-sap linked a pull request Sep 13, 2016 that will close this issue
@ivan-sap
Copy link
Author

PR #249 proposes a fix for the issue. However, if the template is not found within 30 seconds, Monit will give up on starting the process and report an error.

From the Monit documentation:

In the case of a process check, Monit will wait up to 30 seconds for the
start/stop action to finish before giving up and report an error.
You can override this timeout using the TIMEOUT option.

Do you think 30 seconds are sufficient for this , or we should add with TIMEOUT option to the Monit start command?

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

Successfully merging a pull request may close this issue.

2 participants