Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add protection to syntax errors #247

Closed
wants to merge 2 commits into from
Closed

Add protection to syntax errors #247

wants to merge 2 commits into from

Conversation

ad-m
Copy link
Contributor

@ad-m ad-m commented May 25, 2017

This is a protection against accidental changes that may crasj Chaous, especially the update module and self healing. It prevents, for example, the problem with Chaous as in #237. The update will be paused until the problem is fixed. However, this does not mean that the code can not be changed (the repo is still updated).

@rudehn
Copy link
Contributor

rudehn commented May 25, 2017

The only problem with this is it checks for compile errors before it pulls down the new code. Once the new code is pulled (with syntax errors), the bot is restarted and the errors cause the bot to crash.

If you could do this sort of check after the startup.d/10-git-pull.sh, it would be more useful I think

Just spitballing now, you could pull the code, detect it doesn't compile, send a message to the bot (before restarting it), to have the bot put a git issue up, or even try to revert the changes and identify which PR caused the issue

@ad-m
Copy link
Contributor Author

ad-m commented May 25, 2017

I do not think you're right (it's the opposite of what you write). However, I have made the appropriate changes with the hope that you will now vote for them.

if [ "$?" != "0" ]
then
echo "There is syntax error. This may endanger chaos. Pauses updates."
killall bash
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how this is any better than what we're currently doing. Exiting here by killing bash will kill chaos since it replaces itself with startup.sh when it needs an update. Supervisor will make a few restart attempts, but since nothing will have changed, those will fail. What we really need is a way to test each PR before merging it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, chaos will not be stopped. Chaos is not run by bash and through the supervisord. If the update process is interrupted, it will not affect the server, so server can merge a new PR which fix errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Click my link. Chaos literally overwrites itself (that is, its process) with the shell script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chaos overwrites itself, but running chaos use in-memory version of code. So we pull new code, check syntax, but if the code is incorrect - restart does not take place.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Chaos runs, merges PRs, and sees it needs an update.
  2. Chaos replaces itself with startup.sh. At this point, chaos.py is no longer running.
  3. startup.sh runs, sees the new Python code doesn't compile, and kills itself.
  4. Supervisor notices chaos died and attempts to restart it. The new code* fails repeatedly.

* I'll be honest, I haven't looked into Supervisor at all, but I would find it hard to believe that it keeps the old copy around until reread is issued. It seems much more likely to me that it will execute the newly pulled, bad code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reddraggone9 , chaos.py is a daemon. Demons use in principle use the version loaded into memory. Supervisord restart the demon if them crash. If no fail there is no restart, so version loaded into memory is used. Until restart chaos.py use in-memory version.

Copy link
Contributor

Choose a reason for hiding this comment

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

umm that's not a daemon. That code you linked is tied to Chaos' process. Once Chaos' process is replaced, that code is no longer running.

Copy link
Contributor

Choose a reason for hiding this comment

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

"in-memory" where? Chaos' process is overwritten so that's out. It's not feasible for Supervisor to have a backup copy of the entire process and it wouldn't work even if it did. Does Supervisor somehow magically back up all the files needed to run Chaos when it first runs Chaos? Point me to the documentation which says that. If there's some other "in-memory" place that I'm missing, explain it in detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chaos' process is not replaced until the restart. Unless something is misunderstood and there is no long process.

Copy link
Contributor

Choose a reason for hiding this comment

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

Chaos does spawn a child for the web server, but unless something's happening in schedule, there's only one process managing PRs. That's also the original process started by Supervisor and the one overwritten by startup.sh.

If I'm missing a place where it forks, please point me to it.

@rudehn
Copy link
Contributor

rudehn commented May 25, 2017

I do not think you're right (it's the opposite of what you write). However, I have made the appropriate changes with the hope that you will now vote for them.

Initially when you did the syntax check, you checked the current files chaosbot is using. If the bot is running, these checks will pass. The only case where the checks fail is when we pull new code in. That occurred after your checks, so nothing different was really being done.

@@ -7,7 +7,7 @@ git clone "$REPO_URL" "$TEST_DIR";
pushd "$TEST_DIR";

# Code auditing section
python -m py_compile $(find . -name '*.py');
find . -name '*.py' -print0 | xargs -0 python -m py_compile;
Copy link
Contributor

@reddraggone9 reddraggone9 May 25, 2017

Choose a reason for hiding this comment

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

python3 -m py_compile **/*.py would be cleaner.

@reddraggone9
Copy link
Contributor

It looks like this was superseded by #250. Shouldn't this be closed?

@PlasmaPower
Copy link
Contributor

@reddraggone9 Yeah. It'll be closed if the author closes it or no one comments on it in 24 hours (so please don't comment unless you have something important).

@reddraggone9
Copy link
Contributor

I wrote that mainly for @ad-m. I know that he's online and active.

@reddraggone9
Copy link
Contributor

@PlasmaPower Also #218 (comment)

@chaosbot
Copy link
Collaborator

🙅 PR rejected with a vote of 1 for and 4 against, with a weighted total of -3.0 and a threshold of 6.1.

Open a new PR to restart voting.

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

Successfully merging this pull request may close these issues.

5 participants