Skip to content

Commit 1c08e86

Browse files
committed
Merge remote-tracking branch 'moz/master' into syncstorage-sqlite
2 parents 0b5fa19 + be23e39 commit 1c08e86

File tree

19 files changed

+454
-393
lines changed

19 files changed

+454
-393
lines changed

Cargo.lock

Lines changed: 381 additions & 335 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# NOTE: Ensure builder's Rust version matches CI's in .circleci/config.yml
2-
FROM docker.io/lukemathwalker/cargo-chef:0.1.67-rust-1.78-bullseye as chef
1+
# NOTE: Ensure builder's Rust version matches CI's in .circleci/config.yml # RUST_VER
2+
FROM docker.io/lukemathwalker/cargo-chef:0.1.67-rust-1.78-bookworm as chef
33
WORKDIR /app
44

55
FROM chef AS planner
@@ -14,7 +14,7 @@ RUN \
1414
# Fetch and load the MySQL public key. We need to install libmysqlclient-dev to build syncstorage-rs
1515
# which wants the mariadb
1616
wget -qO- https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 > /etc/apt/trusted.gpg.d/mysql.asc && \
17-
echo "deb https://repo.mysql.com/apt/debian/ bullseye mysql-8.0" >> /etc/apt/sources.list && \
17+
echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
1818
apt-get -q update && \
1919
apt-get -q install -y --no-install-recommends libmysqlclient-dev cmake
2020

@@ -31,14 +31,14 @@ COPY --from=cacher $CARGO_HOME /app/$CARGO_HOME
3131
RUN \
3232
# Fetch and load the MySQL public key
3333
wget -qO- https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 > /etc/apt/trusted.gpg.d/mysql.asc && \
34-
echo "deb https://repo.mysql.com/apt/debian/ bullseye mysql-8.0" >> /etc/apt/sources.list && \
34+
echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
3535
# mysql_pubkey.asc from:
3636
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
3737
# related:
3838
# https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#repo-qg-apt-repo-manual-setup
3939
apt-get -q update && \
40-
apt-get -q install -y --no-install-recommends libmysqlclient-dev cmake golang-go python3-dev python3-pip python3-setuptools python3-wheel && \
41-
pip3 install -r requirements.txt && \
40+
apt-get -q install -y --no-install-recommends libmysqlclient-dev cmake golang-go pkg-config python3-dev python3-pip python3-setuptools python3-wheel && \
41+
pip3 install --break-system-packages -r /app/requirements.txt && \
4242
rm -rf /var/lib/apt/lists/*
4343

4444
ENV PATH=$PATH:/root/.cargo/bin
@@ -49,7 +49,7 @@ RUN \
4949
cargo install --path ./syncserver --no-default-features --features=$DATABASE_BACKEND,py_verifier --locked --root /app && \
5050
if [ "$DATABASE_BACKEND" = "spanner" ] ; then cargo install --path ./syncstorage-spanner --locked --root /app --bin purge_ttl ; fi
5151

52-
FROM docker.io/library/debian:bullseye-slim
52+
FROM docker.io/library/debian:bookworm-slim
5353
WORKDIR /app
5454
COPY --from=builder /app/requirements.txt /app
5555
# Due to a build error that occurs with the Python cryptography package, we
@@ -69,17 +69,17 @@ RUN \
6969
apt-get -q update && \
7070
# and ca-certificates needed for https://repo.mysql.com
7171
apt-get install -y gnupg ca-certificates wget && \
72+
echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
7273
# Fetch and load the MySQL public key
73-
echo "deb https://repo.mysql.com/apt/debian/ bullseye mysql-8.0" >> /etc/apt/sources.list && \
7474
wget -qO- https://repo.mysql.com/RPM-GPG-KEY-mysql-2023 > /etc/apt/trusted.gpg.d/mysql.asc && \
7575
# update again now that we trust repo.mysql.com
7676
apt-get -q update && \
77-
apt-get -q install -y build-essential libmysqlclient-dev libssl-dev libffi-dev libcurl4 python3-dev python3-pip python3-setuptools python3-wheel cargo curl jq && \
77+
apt-get -q install -y build-essential libmysqlclient-dev libssl-dev libffi-dev libcurl4 pkg-config python3-dev python3-pip python3-setuptools python3-wheel cargo curl jq && \
7878
# The python3-cryptography debian package installs version 2.6.1, but we
7979
# we want to use the version specified in requirements.txt. To do this,
8080
# we have to remove the python3-cryptography package here.
8181
apt-get -q remove -y python3-cryptography && \
82-
pip3 install -r /app/requirements.txt && \
82+
pip3 install --break-system-packages -r /app/requirements.txt && \
8383
rm -rf /var/lib/apt/lists/*
8484

8585
COPY --from=builder /app/bin /app/bin
@@ -92,8 +92,10 @@ COPY --from=builder /app/scripts/start_mock_fxa_server.sh /app/scripts/start_moc
9292
COPY --from=builder /app/syncstorage-spanner/src/schema.ddl /app/schema.ddl
9393

9494
RUN chmod +x /app/scripts/prepare-spanner.sh
95-
RUN pip3 install -r /app/tools/integration_tests/requirements.txt
96-
RUN pip3 install -r /app/tools/tokenserver/requirements.txt
95+
RUN \
96+
pip3 install --break-system-packages -r /app/tools/integration_tests/requirements.txt
97+
RUN \
98+
pip3 install --break-system-packages -r /app/tools/tokenserver/requirements.txt
9799

98100
USER app:app
99101

syncserver-common/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ authors.workspace = true
66
edition.workspace = true
77

88
[dependencies]
9+
actix-web.workspace = true
910
backtrace.workspace = true
1011
cadence.workspace = true
1112
futures.workspace = true
13+
futures-util.workspace = true
1214
sha2.workspace = true
15+
sentry.workspace = true
16+
sentry-backtrace.workspace = true
1317
serde.workspace = true
1418
serde_json.workspace = true
1519
slog.workspace = true
1620
slog-scope.workspace = true
17-
actix-web.workspace = true
1821
hkdf.workspace = true

syncserver-common/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
extern crate slog_scope;
33

44
mod metrics;
5+
pub mod middleware;
6+
mod tags;
57

68
use std::{
79
fmt,
@@ -15,6 +17,7 @@ use serde_json::Value;
1517
use sha2::Sha256;
1618

1719
pub use metrics::{metrics_from_opts, MetricError, Metrics};
20+
pub use tags::Taggable;
1821

1922
// header statics must be lower case, numbers and symbols per the RFC spec. This reduces chance of error.
2023
pub static X_LAST_MODIFIED: &str = "x-last-modified";
@@ -60,7 +63,7 @@ macro_rules! impl_fmt_display {
6063
};
6164
}
6265

63-
pub trait ReportableError: std::fmt::Display {
66+
pub trait ReportableError: std::fmt::Display + std::fmt::Debug {
6467
/// Like [Error::source] but returns the source (if any) of this error as a
6568
/// [ReportableError] if it implements the trait. Otherwise callers of this
6669
/// method will likely subsequently call [Error::source] to return the
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod sentry;

syncserver/src/web/middleware/sentry.rs renamed to syncserver-common/src/middleware/sentry.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ use futures::{future::LocalBoxFuture, FutureExt};
99
use futures_util::future::{ok, Ready};
1010
use sentry::{protocol::Event, Hub};
1111

12-
use crate::server::tags::Taggable;
13-
use syncserver_common::ReportableError;
12+
use crate::{ReportableError, Taggable};
1413

1514
#[derive(Clone)]
1615
pub struct SentryWrapper<E> {
@@ -249,11 +248,11 @@ pub fn event_from_error(
249248
///
250249
/// Based moreso on sentry_failure's `exception_from_single_fail`. Includes a
251250
/// stacktrace if available.
252-
fn exception_from_reportable_error(err: &dyn ReportableError) -> sentry::protocol::Exception {
253-
let dbg = format!("{:?}", &err.to_string());
251+
pub fn exception_from_reportable_error(err: &dyn ReportableError) -> sentry::protocol::Exception {
252+
let dbg = format!("{:?}", &err);
254253
sentry::protocol::Exception {
255254
ty: sentry::parse_type_from_debug(&dbg).to_owned(),
256-
value: Some(dbg),
255+
value: Some(err.to_string()),
257256
stacktrace: err
258257
.backtrace()
259258
.map(sentry_backtrace::backtrace_to_stacktrace)
File renamed without changes.

syncserver/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ cadence.workspace = true
1414
chrono.workspace = true
1515
docopt.workspace = true
1616
futures.workspace = true
17-
futures-util.workspace = true
1817
hex.workspace = true
1918
hostname.workspace = true
2019
http.workspace = true
2120
lazy_static.workspace = true
2221
rand.workspace = true
2322
regex.workspace = true
2423
sentry.workspace = true
25-
sentry-backtrace.workspace = true
2624
serde.workspace = true
2725
serde_derive.workspace = true
2826
serde_json.workspace = true

syncserver/src/server/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ use actix_web::{
1313
};
1414
use cadence::{Gauged, StatsdClient};
1515
use futures::future::{self, Ready};
16-
use syncserver_common::{BlockingThreadpool, Metrics};
16+
use syncserver_common::{middleware::sentry::SentryWrapper, BlockingThreadpool, Metrics, Taggable};
1717
use syncserver_db_common::{GetPoolState, PoolState};
1818
use syncserver_settings::Settings;
1919
use syncstorage_db::{DbError, DbPool, DbPoolImpl};
2020
use syncstorage_settings::{Deadman, ServerLimits};
2121
use tokio::{sync::RwLock, time};
2222

2323
use crate::error::ApiError;
24-
use crate::server::tags::Taggable;
2524
use crate::tokenserver;
26-
use crate::web::middleware::sentry::SentryWrapper;
2725
use crate::web::{handlers, middleware};
2826

2927
pub const BSO_ID_REGEX: &str = r"[ -~]{1,64}";
@@ -33,7 +31,6 @@ pub const SYNC_DOCS_URL: &str =
3331
const MYSQL_UID_REGEX: &str = r"[0-9]{1,10}";
3432
const SYNC_VERSION_PATH: &str = "1.5";
3533

36-
pub mod tags;
3734
#[cfg(test)]
3835
mod test;
3936
pub mod user_agent;
@@ -197,7 +194,7 @@ macro_rules! build_app_without_syncstorage {
197194
// Middleware is applied LIFO
198195
// These will wrap all outbound responses with matching status codes.
199196
.wrap(ErrorHandlers::new().handler(StatusCode::NOT_FOUND, ApiError::render_404))
200-
.wrap(SentryWrapper::<ApiError>::new(
197+
.wrap(SentryWrapper::<tokenserver_common::TokenserverError>::new(
201198
$metrics.clone(),
202199
"api_error".to_owned(),
203200
))

syncserver/src/tokenserver/extractors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ use lazy_static::lazy_static;
2121
use regex::Regex;
2222
use serde::Deserialize;
2323
use sha2::Sha256;
24+
use syncserver_common::Taggable;
2425
use syncserver_settings::Secrets;
2526
use tokenserver_common::{ErrorLocation, NodeType, TokenserverError};
2627
use tokenserver_db::{params, results, Db, DbPool};
2728

2829
use super::{LogItemsMutator, ServerState, TokenserverMetrics};
29-
use crate::server::{tags::Taggable, MetricsWrapper};
30+
use crate::server::MetricsWrapper;
3031

3132
lazy_static! {
3233
static ref CLIENT_STATE_REGEX: Regex = Regex::new("^[a-zA-Z0-9._-]{1,32}$").unwrap();

0 commit comments

Comments
 (0)