Skip to content

Conversation

@jsternberg
Copy link
Contributor

This should help prevent a misconfigured redis causing silent failures
and fix issue #108.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling b26d1a0 on jsternberg:master into d548609 on gitlabhq:master.

@MrKeiKun
Copy link

👍

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 658832e on jsternberg:master into d548609 on gitlabhq:master.

@jacobvosmaer
Copy link
Contributor

Nice idea @jsternberg; I have a few comments on the code.

bin/check Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can use if system(...) here; no need to use $?.

@jacobvosmaer
Copy link
Contributor

@jsternberg if you update your PR according to my comments we can merge this.

@jsternberg
Copy link
Contributor Author

I've updated the PR to use the return value of system instead of $?.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4e4dae3 on jsternberg:master into d548609 on gitlabhq:master.

@jsternberg
Copy link
Contributor Author

There was also a commit that was made to bin/check that added a file check in the configuration around config.redis['bin']. The change I made to bin/check should be able to replace that code since that check fails in valid configurations, while this one will succeed in every valid configuration.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can change . " to .".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that to keep it consistent with an earlier line. The other error message in that file has ! ". I thought it was a bit weird, but better to keep it consistent than have different stylings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for being careful; I think the other line is wrong. :) If you want you can remove the space after that !.

@jacobvosmaer
Copy link
Contributor

@jsternberg I agree that your redis check in bin/check is more robust. Feel free to remove the file existence check (config.redis['bin']).

bin/check Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can un-nest these ifs?

print 'Testing cli etc' if system(redis, version etc) puts 'OK' else abort 'FAILED' end print 'Sending ping etc' if system(etc) puts 'OK' else abort 'FAILED' end
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 4cb1d6d on jsternberg:master into 6d1b376 on gitlabhq:master.

bin/check Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can drop the err: '/dev/null' because the error output may be useful.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 3bdd465 on jsternberg:master into 6d1b376 on gitlabhq:master.

bin/check Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

If we drop the err: and out: bits, this will print 'PONG'. That way we would only need

print 'sending ping etc..' unless system(redis, ping, etc) abort 'FAILED' end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's actually more simple than that.

abort unless system(redis, ping, etc)

Redis prints a message to stderr if it fails with an appropriate error message. I can just replace it with that if that works. Example:

jsternberg@laptop:[~/gitlab-shell] $ ./bin/check Check GitLab API access: OK Check directories and files: /home/jsternberg/repositories: OK /home/jsternberg/.ssh/authorized_keys2: OK Testing redis-cli executable: redis-cli 2.6.15 Sending ping to redis server: Could not connect to Redis at 127.0.0.1:6379: Connection refused 
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea! Let's also do that with the other system/abort combo.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 3bdd465 on jsternberg:master into 6d1b376 on gitlabhq:master.

@jacobvosmaer
Copy link
Contributor

Sorry for keeping you so busy @jsternberg with all my comments. :) I think this is very useful but I would also like it to be clean.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 63d5a9f on jsternberg:master into 6d1b376 on gitlabhq:master.

bin/check Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be simpler to just let the redis-cli --version fail?

Copy link
Contributor

Choose a reason for hiding this comment

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

abort('FAILED') unless system(*config.redis_command, '--version')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's in the commit message for that commit. If the redis bin isn't there, system won't print anything. This causes the newline to never be printed. The second check is just to make sure that the executable they specified actually works, or in the case of the redis section missing, env -i redis-cli works.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I missed your commit message.

I tried it out independently in IRB and I also noticed the nil returned by system when the command is not found. I propose to address this by adding a message to the abort (see my comment above). I appreciate that the current solution gives more detailed information, but I am not sure if the added detail is worth the extra code and tying this script more tightly to lib/gitlab_config.rb.

@jsternberg
Copy link
Contributor Author

I rebased the previous commit off and added the abort('FAILED') call.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling c51d834 on jsternberg:master into 6fc922c on gitlabhq:master.

@jacobvosmaer
Copy link
Contributor

This looks great @jsternberg . Could you squash or at least reduce the commits? I appreciate the care you take with your commit messages but we would rather avoid merge commits and detours in master.

@jsternberg
Copy link
Contributor Author

Don't pull those in yet. It looks like I rebased some of the commits into the wrong place.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 89028f5 on jsternberg:master into 6fc922c on gitlabhq:master.

This should help prevent a misconfigured redis causing silent failures and fix issue #108.
The bin/check script now checks if Redis is configured properly.
@jsternberg
Copy link
Contributor Author

Those commits should be good now.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) when pulling acab321 on jsternberg:master into 6fc922c on gitlabhq:master.

jacobvosmaer added a commit that referenced this pull request Nov 20, 2013
Display error and send failure exit status if redis-cli fails
@jacobvosmaer jacobvosmaer merged commit 8d84906 into gitlabhq:master Nov 20, 2013
@jacobvosmaer
Copy link
Contributor

Awesome. Thanks @jsternberg !

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

Labels

None yet

5 participants