-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add ability to reset password in JedisFactory #1606
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
Conversation
yapei123
commented
Sep 13, 2017
- Change JedisFactory to public
- add a new method to reset password
dupe of #1605 ? |
@marcosnils I removed that branch since of something messed up. I have closed #1605. |
@marcosnils I would love to add it to JedisCluster also add tests. Can I have some helps from you or other members on how to run the tests? I've tried to run 'make start', 'make test' but failed. |
@yapei123 sure, please share your erros and I'll try to help you to get the tests passed. |
@yapei123 do you have maven installed?. Seems like the makefile is complaining that maven is not installed. Which linux distribution are you using? |
@yapei123 maybe some weird race condition or something. If tests pass on you IDE then it's ok. Is this PR ready to be reviewed?. Can you please squash the commits? |
As you can see this PR has 15 commits. It's simpler to review if you just squash them all together and you just send few of them. Check https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git |
59f4f03
to
15aadd1
Compare
@marcosnils just realized the JedisCluster might not be able to add the feature of 'reset password at runtime' since the JedisFactory needs to be created for each node and put into a List and it's hard to get hold of the JedsFactory for each node. |
a5370bb
to
404d4d6
Compare
ready for code reviewing. Thanks! |
It would be really cool to get this merged so that an application can update the Redis password at runtime. @marcosnils is there anything holding up merging this? |
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.
Left minor comments but overall LGTM. @marcosnils Please continue review this.
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.
add fail()
below pool.getResource()
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.
done
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.
Let's wrap with try-catch and remove expected statement. The test will pass even JedisConnectionException is thrown from obj1.
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.
done
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.
Let's wrap with try-catch and remove expected statement. The test will pass even JedisConnectionException is thrown from obj1.
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.
done
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.
add fail()
below pool.getResource()
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.
done
f04f266
to
fb581c7
Compare
@chrisribble IMO, both scenarios should be successful. Choosing only one doesn't sound right to me. Waiting for your response on my query about creating new pool. |
b6b0a07
to
813cb62
Compare
@chrisribble @sazzad16 There are two tests: one tests resetting password from bad to good, another from good to bad. The first one has no issue. |
@sazzad16 Yes, the purpose of this PR is to avoid creating a new pool when you want to change the password that is used for new connections (resources). The purpose of the PR is not to force the existing resources to be closed/released/etc when the password is changed. Instead of creating a new pool in the test, what if we request a second resource while holding the first resource? That will ensure that the pool has to create a new connection with the bad password. Sequence of actions:
How does that sound? |
a875867
to
5394045
Compare
JedisSentinelPool
I'm strongly against this idea that already requested resources would enforced to be unclosed for a valid operation in Pool.getResource(). I hope you'd understand my viewpoint. PS: This is my own view. Other collaborators may agree with you. We can wait for them to respond. |
@sazzad16 I guess I don't understand completely because it's not that the underlying code has to enforce that the requested resource is unclosed; it's just that there's no straightforward way to validate that the password has been changed without keeping the previously-requested resource unclosed because there is no external way for the caller to tell the pool to evict a closed resource. Without the closed (released) resource being evicted from the pool, we will get it again the next time we call getResource. Do you have any other ideas on a safe way to evict the resource from the pool without resorting to clearing the entire pool? I think maybe it's a mistake to be writing a test for this behavior (switching good password to bad password) using JedisPool and that the test should be directly validating the behavior on JedisFactory. What do you think? |
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.
@yapei123 I know it has been a long time, but would you be able to address change requests only within this review?
JedisPool pool = new JedisPool(new JedisPoolConfig(), factory); | ||
Jedis obj = null; | ||
try { | ||
pool.getResource(); |
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.
Get this resource and close it properly, just to avoid any possible connection leak.
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, new JedisPoolConfig(), factory); | ||
Jedis obj = null; | ||
try { | ||
pool.getResource(); |
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.
Get this resource and close it properly, just to avoid any possible connection leak. try-with-resources can be used for convenience.
fail("Could not get resource from pool"); | ||
} catch (JedisConnectionException e) { | ||
factory.setPassword("foobared"); | ||
obj = pool.getResource(); |
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.
Close obj
within this catch block. Optionally, you can declare obj
(aka Jedis obj = pool.getResource();
) here with/without try-with-resources.
fail("Could not get resource from pool"); | ||
} catch (JedisConnectionException e) { | ||
factory.setPassword("foobared"); | ||
obj = pool.getResource(); |
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.
Close obj
within this catch block. Optionally, you can declare obj
(aka Jedis obj = pool.getResource();
) here with/without try-with-resources.