-
Notifications
You must be signed in to change notification settings - Fork 1.3k
vRouters fixes & performance improvement #2089
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,39 +27,29 @@ log_it() { | |
| echo "$(date) : $*" >> $log | ||
| } | ||
|
|
||
| while getopts 'c:' OPTION | ||
| do | ||
| case $OPTION in | ||
| c) cfg="$OPTARG" | ||
| ;; | ||
| esac | ||
| done | ||
| while getopts 'c:' OPTION; do | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this condensed? it is not speeding up execution is it? only reducing readability afaict
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one, I am OK with. |
||
| case $OPTION in | ||
| c) cfg="$OPTARG" ;; | ||
| esac; done | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. especially this line is concluding two levels of indentation at once. Please keep them for readability
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one, I agree with Daan. We are changing the indentation scope which is confusing. |
||
|
|
||
| while read line | ||
| do | ||
| export DEFER_CONFIG=true | ||
| while read line; do | ||
| #comment | ||
| if [[ $line == \#* ]] | ||
| then | ||
| continue | ||
| fi | ||
| if [[ $line == \#* ]]; then | ||
| continue | ||
|
|
||
| if [ "$line" == "<version>" ] | ||
| then | ||
| elif [ "$line" == "<version>" ]; then | ||
| read line | ||
| version=$line | ||
| log_it "VR config: configuation format version $version" | ||
| #skip </version> | ||
| read line | ||
| continue | ||
| fi | ||
|
|
||
| if [ "$line" == "<script>" ] | ||
| then | ||
| elif [ "$line" == "<script>" ]; then | ||
| read line | ||
| log_it "VR config: executing: $line" | ||
| eval $line >> $log 2>&1 | ||
| if [ $? -ne 0 ] | ||
| then | ||
| if [ $? -ne 0 ]; then | ||
| log_it "VR config: executing failed: $line" | ||
| # expose error info to mgmt server | ||
| echo "VR config: execution failed: \"$line\", check $log in VR for details " 1>&2 | ||
|
|
@@ -68,30 +58,30 @@ do | |
| #skip </script> | ||
| read line | ||
| log_it "VR config: execution success " | ||
| continue | ||
| fi | ||
|
|
||
| if [ "$line" == "<file>" ] | ||
| then | ||
| elif [ "$line" == "<file>" ]; then | ||
| read line | ||
| file=$line | ||
| log_it "VR config: creating file: $file" | ||
| rm -f $file | ||
| while read -r line | ||
| do | ||
| if [ "$line" == "</file>" ] | ||
| then | ||
| while read -r line; do | ||
| if [ "$line" == "</file>" ]; then | ||
| break | ||
| fi | ||
| echo $line >> $file | ||
| done | ||
| log_it "VR config: create file success" | ||
| continue | ||
|
|
||
| fi | ||
|
|
||
| done < $cfg | ||
|
|
||
| #remove the configuration file, log file should have all the records as well | ||
| rm -f $cfg | ||
| # archive the configuration file | ||
| mv $cfg /var/cache/cloud/processed/ | ||
|
|
||
| unset DEFER_CONFIG | ||
| # trigger finish_config() | ||
| /opt/cloud/bin/configure.py | ||
|
|
||
| # Flush kernel conntrack table | ||
| log_it "VR config: Flushing conntrack table" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finish_config should be ignored when file name is vm_dhcp_entry.json or vm_metadata.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that exactly what it says or am I having a complete brainfart here???
(DEFER_CONFIG is set and vm_dhcp/vm_metadata) || finish_config()
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of dhcp or metadata from vr_cfg.sh, we will ignorethe finish_config and run the following at the end.
/opt/cloud/bin/configure.py vm_dhcp_entry.json
or
/opt/cloud/bin/configure.py vm_metadata.json
for others, finish_config should be executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that exactly what it says or am I having a complete brainfart here???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@The-Loeki looked at the code again, the code is correct.
At the first sight I thought it is
if not (os.environ.get('DEFER_CONFIG', False)) and sys.argv[1] in ('vm_dhcp_entry.json', 'vm_metadata.json'):
sorry for misunderstanding.