Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

feat: fix asserts on client dis/connect and convert inc call to rust #1178

Merged
merged 1 commit into from
Apr 17, 2018

Conversation

bbangert
Copy link
Member

Removes the asserts when adding the uaid to the uaids hash, and issue
proper disconnect call to existing client. Ensure uaid removal removes
the right client indicated by a separate UUID per client object.

Convert IncrementStorage call to pure Rust async and remove Python
implementation.

Closes #1177

fn process_increment_storage(&mut self) -> ClientState {
// Let the variable copies begin, so that nothing is left dangling in the future
// we then assemble because Lifetimes.
let webpush = self.webpush.as_ref().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing that these unwraps are gets trapped up by client.transition()? Should we call these out as specific errors if they fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

Logically to get to the point where we can do state transitions, we need a webpush here, same with how the state machine guarantee's we'll have unacked by this point or we wouldn't need to increment storage.

@@ -338,9 +342,19 @@ impl Server {
} else {
ServiceChangeTracker::new(Vec::new())
};
let region = if env::var("AWS_PROFILE").unwrap_or("default".to_string()) == "test" {
Copy link
Member

Choose a reason for hiding this comment

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

use if cfg!(test) here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we set what ever that checks somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

cfg!() can be called at run time to see what configuration you happen to be in. It's the inline equivalent of "#[cfg(test)]".

It might be more useful than checking the AWS_PROFILE for a test configuration value.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, how do we flag in the environment that its in test mode? It's not running a Rust based test suite that would flag this afaik.

Copy link
Member

Choose a reason for hiding this comment

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

Right, the #cfg test toggle is via a compiler flag, so unfortunately we can't use it here.

The python code keys on AWS_LOCAL_DYNAMODB, so I'd rather this key on that as well. Then I don't think the changes to .travis.yml/boto.cfg/tox.ini are necessary (and local testing should continue to work as normal)

@codecov-io
Copy link

codecov-io commented Apr 16, 2018

Codecov Report

Merging #1178 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1178   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          60      60           
  Lines       10078   10078           
======================================
  Hits        10078   10078

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f1e98d2...a481959. Read the comment docs.

jrconlin
jrconlin previously approved these changes Apr 16, 2018
debug!("Disconnecting client!");
let mut uaids = self.uaids.borrow_mut();
uaids.remove(uaid).expect("uaid not registered");
let client_exists = if let Some(client) = uaids.get(uaid) {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: could go with a one liner: let client_exists = uaids.get(uaid).map(|client| client.uid == *uid).unwrap_or(false);

/// A bunch of macro helpers from rusoto_helpers code, which they pulled from crates.io because
/// they were waiting for rusuto to hit 1.0.0 or something. For sanity, they are instead accumulated
/// here for our use.
macro_rules! attributes {
Copy link
Member

Choose a reason for hiding this comment

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

these first 3 should have #[allow(unused_macros)] for now to quiet rustc warnings

@@ -338,9 +342,19 @@ impl Server {
} else {
ServiceChangeTracker::new(Vec::new())
};
let region = if env::var("AWS_PROFILE").unwrap_or("default".to_string()) == "test" {
Copy link
Member

Choose a reason for hiding this comment

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

Right, the #cfg test toggle is via a compiler flag, so unfortunately we can't use it here.

The python code keys on AWS_LOCAL_DYNAMODB, so I'd rather this key on that as well. Then I don't think the changes to .travis.yml/boto.cfg/tox.ini are necessary (and local testing should continue to work as normal)

name: "local_dynamodb".to_string(),
}
} else {
Region::UsEast1
Copy link
Member

Choose a reason for hiding this comment

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

don't hardcode, you want Region::default() so it's read from the AWS_DEFAULT_REGION env var

Removes the asserts when adding the uaid to the uaids hash, and issue
proper disconnect call to existing client. Ensure uaid removal removes
the right client indicated by a separate UUID per client object.

Convert IncrementStorage call to pure Rust async and remove Python
implementation.

Closes #1177
@@ -338,9 +342,17 @@ impl Server {
} else {
ServiceChangeTracker::new(Vec::new())
};
let region = env::var("AWS_LOCAL_DYNAMODB").map(|endpoint| {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: unwrap_or_else would be preferred here (don't care much because this is for tests)

Copy link
Member Author

Choose a reason for hiding this comment

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

But it needs to construct the Region object with the value?

Copy link
Member

Choose a reason for hiding this comment

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

for the fallback I mean (oops I annotated the wrong line). it's just the lazy version of unwrap_or

.unwrap_or_else(|| Region::default());

Copy link
Member

Choose a reason for hiding this comment

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

unwrap_or_else(Region::default) even!

@@ -28,7 +28,7 @@ install:
- pip install tox ${CODECOV:+codecov}
- if [ ${WITH_RUST:-true} != "false" ]; then curl https://sh.rustup.rs | sh -s -- -y || travis_terminate 1; fi
- export PATH=$PATH:$HOME/.cargo/bin
- export AWS_SHARED_CREDENTIALS_FILE=./automock/credentials.cfg
- export AWS_SHARED_CREDENTIALS_FILE=./automock/boto.cfg
Copy link
Member

@pjenvey pjenvey Apr 17, 2018

Choose a reason for hiding this comment

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

is this and the boto.cfg change still necessary? (boto.cfg should probably be killed at this point if anything)

Copy link
Member Author

@bbangert bbangert Apr 17, 2018

Choose a reason for hiding this comment

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

It is, because rusoto wants to find itself some aws access/secret keys, and if it can't find them in a file it expects, it starts issuing HTTP calls looking for IAM keys and such which messes things up. This is also why I added random access/secret keys to the boto.cfg. (There is no credentials.cfg)

Copy link
Member

Choose a reason for hiding this comment

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

but credentials.cfg has them

Copy link
Member Author

Choose a reason for hiding this comment

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

@bbangert bbangert merged commit b9cc703 into master Apr 17, 2018
@bbangert bbangert deleted the feat/issue-1177 branch April 17, 2018 02:08
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.

4 participants