Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Set non-interactive default for set_security #150

Merged
merged 1 commit into from
Mar 13, 2014

Conversation

sagelywizard
Copy link
Contributor

Prior to this commit, a node would respect MM for clustered set_security
requests while still contributing to get_security requests. This would
lead to a situation where a user would change the security header for a
clustered DB, but the update would only reach a subset of the shards. On
subsequent requests, intermittant permission errors would be returned
due to security headers being inconsistent between shards.

BugzID: 28847

@sagelywizard
Copy link
Contributor Author

The changes to fabric_rpc and fabric_rpc2 are the same. Only fabric_rpc is used in the actual codebase, but I thought that it couldn't hurt being consistent.

@@ -217,6 +217,7 @@ get_update_seq(DbName) ->
with_db(DbName, [], {couch_db, get_update_seq, []}).

set_security(DbName, SecObj, Options) ->
erlang:put(io_ignore_mm, true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be nicer to wrap the call to with_db in a pair of calls to set the IO priority to a non-interactive value? That'd simplify the diff as well as prevent the maintenance mode bypass from leaking out of this call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Point taken, but I don't think that's quite the right way to do that. IO priority is passed via the options to with_db. So, how about setting a non-interactive default in the fabric_rpc handler? Just pushed a thing.

@sagelywizard
Copy link
Contributor Author

Though that last change makes the commit msg not quite right, so I'd have to change that.

@@ -216,7 +216,13 @@ get_doc_count(DbName) ->
get_update_seq(DbName) ->
with_db(DbName, [], {couch_db, get_update_seq, []}).

set_security(DbName, SecObj, Options) ->
set_security(DbName, SecObj, Options0) ->
Options = case lists:keyfind(io_priority, 1, Options0) of
Copy link
Contributor

Choose a reason for hiding this comment

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

use lists:keystore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rnewson lists:keystore will overwrite the supplied default. Could do Options = lists:keymerge(1, Options0, [{io_priority, thing}]), but that'd require sorting Options0. Or just could leave as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

ooh. let's at least have this function written once then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By "supplied default" I mean the io_priority which is possibly set in Options0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whatcha mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get rid of fabric_rpc2:set_security since it isn't used in the codebase?

Copy link
Contributor

Choose a reason for hiding this comment

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

enh, never mind. it's more work to pull this duplicate code into one place, +1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Squashing, amending commit message, and merging. Squamerging?

@rnewson
Copy link
Contributor

rnewson commented Mar 13, 2014

+1 after addressing lists:keystore and commit msg update.

Prior to this commit, fabric:set_security would default to interactive
IO priority. This would cause all nodes to set the security header
except shards on any nodes which were in MM. Subsequent calls to
fabric:get_security would cause inconsistent security properties to be
applied to the request. This patch sets a non-interactive default for
fabric:set_security, which will cause security updates to be applied to
all nodes regardless of MM by default.

BugzID: 28847
@sagelywizard
Copy link
Contributor Author

That was the squamend. Merging.

sagelywizard added a commit that referenced this pull request Mar 13, 2014
Set non-interactive default for set_security
@sagelywizard sagelywizard merged commit 15737a5 into master Mar 13, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants