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

Fixes #14814: Send the run log at the end of the run through HTTP #224

Conversation

amousset
Copy link
Member

@amousset
Copy link
Member Author

PR rebased

@amousset amousset force-pushed the arch_14814/send_the_run_log_at_the_end_of_the_run_through_http branch from 85946ff to d96dc2c Compare July 15, 2019 08:34
qa-test Outdated
set -ex

# Shellcheck
find . -path ./.git -prune -o -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; -print |
Copy link
Member

Choose a reason for hiding this comment

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

suggestion for more performance with big files:
find . -type f -exec bash -c "head -n1 {} | grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)'" ; -print

COLOR="-Cnever"

# When debugging, reports will be huge, skip HTTP reporting
DONT_DO_HTTP=0
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer a DO_HTTP name, and a true/false value

@@ -27,6 +27,8 @@
# @man +
# @man *-R*: run the agent in completely unparsed mode, with no return code of 1 in case of error. A little faster.
# @man +
# @man *-N-: do not write log in outputs dir (used when called internally)
Copy link
Member

Choose a reason for hiding this comment

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

-N- ?

@amousset
Copy link
Member Author

PR updated with a new commit

@@ -0,0 +1,8 @@
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

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

Not an include

# Same as in agent with a T instead of space (iso8601 UTC)
date=$(/bin/date -u "+%Y-%m-%dT%T+00:00")
printf "${date} %s\n" "$line"
done
Copy link
Member

Choose a reason for hiding this comment

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

newline

@amousset
Copy link
Member Author

PR updated with a new commit

# Timestamps all lines
while IFS= read -r line; do
# Same as in agent with a T instead of space (iso8601 UTC)
date=$(/bin/date -u "+%Y-%m-%dT%T+00:00")
Copy link
Member

Choose a reason for hiding this comment

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

date should be in path, just use date

report_file="${TMP_REPORTS_DIR}/${report_file_name}"
touch "${report_file}"
chmod 600 "${report_file}"
runlog_output='tee ${report_file}'
Copy link
Member

Choose a reason for hiding this comment

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

""

logdir=/var/rudder/cfengine-community/outputs
touch "${logdir}/${logfile}"
chmod 600 "${logdir}/${logfile}"
log_outputs='tee ${logdir}/${logfile}'
Copy link
Member

Choose a reason for hiding this comment

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

""

runlog_output='cat'
fi

"${RUDDER_VAR}/cfengine-community/bin/cf-agent" ${VERBOSITY} ${COLOR} -K ${BUNDLE} ${CLASS} | eval $log_outputs | eval $timestamp | eval $runlog_output | eval ${PRETTY}
Copy link
Member

Choose a reason for hiding this comment

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

remove some evals

return 1
fi

# (Very likely) atomic move in ready reports dir
Copy link
Member

Choose a reason for hiding this comment

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

yes except if they are on a different filesystem

Copy link
Member Author

@amousset amousset Jul 16, 2019

Choose a reason for hiding this comment

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

hence the very likely, because /var/rudder/ is very likely on a single FS

@amousset
Copy link
Member Author

PR updated with a new commit

1 similar comment
@amousset
Copy link
Member Author

PR updated with a new commit

@Normation-Quality-Assistant

OK, squash merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant force-pushed the arch_14814/send_the_run_log_at_the_end_of_the_run_through_http branch from bc73b86 to 2b3d1fc Compare July 16, 2019 14:13
@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 2b3d1fc into Normation:master Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants