mirror of
https://github.com/facebook/sapling.git
synced 2024-10-04 22:07:44 +03:00
Changing the config to make the land service client work
Summary: It (1) adds the repo in the Land Service, (2) includes Remote Land Service and remote land service with local fallback, (2) get the address from tier or host and calls the client in the unbundle processing The Static analysis failed in the FBTHRIFTCOMPAT1 because i added a new field in the land_changesets method in the impl LandService (land_service_impl.rs). It does not break anything since we do not have the server in production. I mean, changing the id does not influence on previous versions of the server since there is no land service server in production. Reviewed By: yancouto Differential Revision: D39553570 fbshipit-source-id: bb1f09c2ab2c111734b9026109fc39e14c514516
This commit is contained in:
parent
83de9cf049
commit
dfc568ff36
@ -1,4 +1,4 @@
|
|||||||
// @generated SignedSource<<9a296dd7297d049023a0bac9d0c54f8a>>
|
// @generated SignedSource<<a89c66cbf8ba16f5a0c2dc5851b8b078>>
|
||||||
// DO NOT EDIT THIS FILE MANUALLY!
|
// DO NOT EDIT THIS FILE MANUALLY!
|
||||||
// This file is a mechanical copy of the version in the configerator repo. To
|
// This file is a mechanical copy of the version in the configerator repo. To
|
||||||
// modify it, edit the copy in the configerator repo instead and copy it over by
|
// modify it, edit the copy in the configerator repo instead and copy it over by
|
||||||
@ -445,6 +445,8 @@ union RawPushrebaseRemoteMode {
|
|||||||
1: RawPushrebaseRemoteModeLocal local;
|
1: RawPushrebaseRemoteModeLocal local;
|
||||||
2: RawPushrebaseRemoteModeRemote remote_scs;
|
2: RawPushrebaseRemoteModeRemote remote_scs;
|
||||||
3: RawPushrebaseRemoteModeRemote remote_scs_local_fallback;
|
3: RawPushrebaseRemoteModeRemote remote_scs_local_fallback;
|
||||||
|
4: RawPushrebaseRemoteModeRemote remote_land_service;
|
||||||
|
5: RawPushrebaseRemoteModeRemote remote_land_service_local_fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RawPushrebaseParams {
|
struct RawPushrebaseParams {
|
||||||
|
@ -38,6 +38,9 @@ struct LandChangesetRequest {
|
|||||||
|
|
||||||
/// What kind of bookmark can be pushed.
|
/// What kind of bookmark can be pushed.
|
||||||
5: BookmarkKindRestrictions bookmark_restrictions = BookmarkKindRestrictions.ANY_KIND;
|
5: BookmarkKindRestrictions bookmark_restrictions = BookmarkKindRestrictions.ANY_KIND;
|
||||||
|
|
||||||
|
/// The name of the repository.
|
||||||
|
6: string repo_name;
|
||||||
} (rust.exhaustive)
|
} (rust.exhaustive)
|
||||||
|
|
||||||
struct BonsaiHashPairs {
|
struct BonsaiHashPairs {
|
||||||
|
@ -806,7 +806,7 @@ mod test {
|
|||||||
casefolding_check = false
|
casefolding_check = false
|
||||||
emit_obsmarkers = false
|
emit_obsmarkers = false
|
||||||
allow_change_xrepo_mapping_extra = true
|
allow_change_xrepo_mapping_extra = true
|
||||||
|
|
||||||
[pushrebase.remote_mode]
|
[pushrebase.remote_mode]
|
||||||
remote_scs = { tier = "my-tier" }
|
remote_scs = { tier = "my-tier" }
|
||||||
|
|
||||||
|
@ -257,6 +257,12 @@ impl Convert for RawPushrebaseRemoteMode {
|
|||||||
Self::remote_scs_local_fallback(addr) => Ok(
|
Self::remote_scs_local_fallback(addr) => Ok(
|
||||||
PushrebaseRemoteMode::RemoteScsWithLocalFallback(addr.convert()?),
|
PushrebaseRemoteMode::RemoteScsWithLocalFallback(addr.convert()?),
|
||||||
),
|
),
|
||||||
|
Self::remote_land_service(addr) => {
|
||||||
|
Ok(PushrebaseRemoteMode::RemoteLandService(addr.convert()?))
|
||||||
|
}
|
||||||
|
Self::remote_land_service_local_fallback(addr) => Ok(
|
||||||
|
PushrebaseRemoteMode::RemoteLandServiceWithLocalFallback(addr.convert()?),
|
||||||
|
),
|
||||||
Self::UnknownField(e) => anyhow::bail!("Unknown field: {}", e),
|
Self::UnknownField(e) => anyhow::bail!("Unknown field: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -654,16 +654,10 @@ pub enum PushrebaseRemoteMode {
|
|||||||
RemoteScs(Address),
|
RemoteScs(Address),
|
||||||
/// Call SCS and do pushrebase remotely, retrying errors locally
|
/// Call SCS and do pushrebase remotely, retrying errors locally
|
||||||
RemoteScsWithLocalFallback(Address),
|
RemoteScsWithLocalFallback(Address),
|
||||||
}
|
/// Call LandService and do pushrebase remotely, forwarding errors
|
||||||
|
RemoteLandService(Address),
|
||||||
impl PushrebaseRemoteMode {
|
/// Call LandService and do pushrebase remotely, retrying errors locally
|
||||||
/// SCS address used for pushrebase, if any
|
RemoteLandServiceWithLocalFallback(Address),
|
||||||
pub fn scs_address(&self) -> Option<&Address> {
|
|
||||||
match self {
|
|
||||||
Self::RemoteScs(address) | Self::RemoteScsWithLocalFallback(address) => Some(address),
|
|
||||||
Self::Local => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pushrebase configuration options
|
/// Pushrebase configuration options
|
||||||
|
@ -17,6 +17,8 @@ use bookmarks_movement::BookmarkMovementError;
|
|||||||
use bookmarks_types::BookmarkName;
|
use bookmarks_types::BookmarkName;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
#[cfg(fbcode_build)]
|
#[cfg(fbcode_build)]
|
||||||
|
pub use facebook::land_service::LandServicePushrebaseClient;
|
||||||
|
#[cfg(fbcode_build)]
|
||||||
pub use facebook::scs::override_certificate_paths;
|
pub use facebook::scs::override_certificate_paths;
|
||||||
#[cfg(fbcode_build)]
|
#[cfg(fbcode_build)]
|
||||||
pub use facebook::scs::ScsPushrebaseClient;
|
pub use facebook::scs::ScsPushrebaseClient;
|
||||||
@ -28,7 +30,7 @@ use pushrebase::PushrebaseOutcome;
|
|||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
/// This trait provides an abstraction for pushrebase, which can be used to allow
|
/// This trait provides an abstraction for pushrebase, which can be used to allow
|
||||||
/// pushrebase to happen remotely.
|
/// pushrebase to happen remotely.
|
||||||
pub trait PushrebaseClient {
|
pub trait PushrebaseClient: Sync + Send {
|
||||||
/// Pushrebase the given changesets to the given bookmark.
|
/// Pushrebase the given changesets to the given bookmark.
|
||||||
async fn pushrebase(
|
async fn pushrebase(
|
||||||
&self,
|
&self,
|
||||||
|
@ -25,6 +25,7 @@ use bytes::Bytes;
|
|||||||
use context::CoreContext;
|
use context::CoreContext;
|
||||||
use hooks::HookManager;
|
use hooks::HookManager;
|
||||||
use mercurial_mutation::HgMutationStoreRef;
|
use mercurial_mutation::HgMutationStoreRef;
|
||||||
|
use metaconfig_types::Address;
|
||||||
use metaconfig_types::InfinitepushParams;
|
use metaconfig_types::InfinitepushParams;
|
||||||
use metaconfig_types::PushParams;
|
use metaconfig_types::PushParams;
|
||||||
use metaconfig_types::PushrebaseParams;
|
use metaconfig_types::PushrebaseParams;
|
||||||
@ -32,6 +33,8 @@ use metaconfig_types::PushrebaseRemoteMode;
|
|||||||
use mononoke_types::BonsaiChangeset;
|
use mononoke_types::BonsaiChangeset;
|
||||||
use mononoke_types::ChangesetId;
|
use mononoke_types::ChangesetId;
|
||||||
use pushrebase::PushrebaseError;
|
use pushrebase::PushrebaseError;
|
||||||
|
#[cfg(fbcode_build)]
|
||||||
|
use pushrebase_client::LandServicePushrebaseClient;
|
||||||
use pushrebase_client::LocalPushrebaseClient;
|
use pushrebase_client::LocalPushrebaseClient;
|
||||||
use pushrebase_client::PushrebaseClient;
|
use pushrebase_client::PushrebaseClient;
|
||||||
#[cfg(fbcode_build)]
|
#[cfg(fbcode_build)]
|
||||||
@ -497,6 +500,70 @@ async fn convert_bookmark_movement_err(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn maybe_client_from_address<'a>(
|
||||||
|
remote_mode: &'a PushrebaseRemoteMode,
|
||||||
|
ctx: &'a CoreContext,
|
||||||
|
repo: &'a impl Repo,
|
||||||
|
) -> Option<Box<dyn PushrebaseClient + 'a>> {
|
||||||
|
match remote_mode {
|
||||||
|
PushrebaseRemoteMode::RemoteScs(address)
|
||||||
|
| PushrebaseRemoteMode::RemoteScsWithLocalFallback(address) => {
|
||||||
|
address_from_scs(address, ctx, repo)
|
||||||
|
}
|
||||||
|
PushrebaseRemoteMode::RemoteLandService(address)
|
||||||
|
| PushrebaseRemoteMode::RemoteLandServiceWithLocalFallback(address) => {
|
||||||
|
address_from_land_service(address, ctx, repo)
|
||||||
|
}
|
||||||
|
PushrebaseRemoteMode::Local => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn address_from_scs<'a>(
|
||||||
|
address: &'a Address,
|
||||||
|
ctx: &'a CoreContext,
|
||||||
|
repo: &'a impl Repo,
|
||||||
|
) -> Option<Box<dyn PushrebaseClient + 'a>> {
|
||||||
|
#[cfg(fbcode_build)]
|
||||||
|
{
|
||||||
|
match address {
|
||||||
|
metaconfig_types::Address::Tier(tier) => Some(Box::new(
|
||||||
|
ScsPushrebaseClient::from_tier(ctx, tier.clone(), repo).ok()?,
|
||||||
|
)),
|
||||||
|
metaconfig_types::Address::HostPort(host_port) => Some(Box::new(
|
||||||
|
ScsPushrebaseClient::from_host_port(ctx, host_port.clone(), repo).ok()?,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(fbcode_build))]
|
||||||
|
{
|
||||||
|
let _ = (address, ctx, repo);
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn address_from_land_service<'a>(
|
||||||
|
address: &'a Address,
|
||||||
|
ctx: &'a CoreContext,
|
||||||
|
repo: &'a impl Repo,
|
||||||
|
) -> Option<Box<dyn PushrebaseClient + 'a>> {
|
||||||
|
#[cfg(fbcode_build)]
|
||||||
|
{
|
||||||
|
match address {
|
||||||
|
metaconfig_types::Address::Tier(tier) => Some(Box::new(
|
||||||
|
LandServicePushrebaseClient::from_tier(ctx, tier.clone(), repo).ok()?,
|
||||||
|
)),
|
||||||
|
metaconfig_types::Address::HostPort(host_port) => Some(Box::new(
|
||||||
|
LandServicePushrebaseClient::from_host_port(ctx, host_port.clone(), repo).ok()?,
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(fbcode_build))]
|
||||||
|
{
|
||||||
|
let _ = (address, ctx, repo);
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn normal_pushrebase<'a>(
|
async fn normal_pushrebase<'a>(
|
||||||
ctx: &'a CoreContext,
|
ctx: &'a CoreContext,
|
||||||
repo: &'a impl Repo,
|
repo: &'a impl Repo,
|
||||||
@ -516,18 +583,12 @@ async fn normal_pushrebase<'a>(
|
|||||||
} else {
|
} else {
|
||||||
&pushrebase_params.remote_mode
|
&pushrebase_params.remote_mode
|
||||||
};
|
};
|
||||||
let maybe_fallback_scuba: Option<(MononokeScubaSampleBuilder, BookmarkMovementError)> =
|
let maybe_fallback_scuba: Option<(MononokeScubaSampleBuilder, BookmarkMovementError)> = {
|
||||||
if let Some(address) = remote_mode.scs_address() {
|
let maybe_client: Option<Box<dyn PushrebaseClient>> =
|
||||||
#[cfg(fbcode_build)]
|
maybe_client_from_address(&pushrebase_params.remote_mode, ctx, repo);
|
||||||
{
|
|
||||||
let result = match address {
|
if let Some(client) = maybe_client {
|
||||||
metaconfig_types::Address::Tier(tier) => {
|
let result = client
|
||||||
ScsPushrebaseClient::from_tier(ctx, tier.clone(), repo)?
|
|
||||||
}
|
|
||||||
metaconfig_types::Address::HostPort(host_port) => {
|
|
||||||
ScsPushrebaseClient::from_host_port(ctx, host_port.clone(), repo)?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.pushrebase(
|
.pushrebase(
|
||||||
bookmark,
|
bookmark,
|
||||||
changesets.clone(),
|
changesets.clone(),
|
||||||
@ -536,43 +597,40 @@ async fn normal_pushrebase<'a>(
|
|||||||
bookmark_restriction,
|
bookmark_restriction,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
match (result, remote_mode) {
|
match (result, remote_mode) {
|
||||||
(Ok(outcome), _) => {
|
(Ok(outcome), _) => {
|
||||||
return Ok((outcome.head, outcome.rebased_changesets));
|
return Ok((outcome.head, outcome.rebased_changesets));
|
||||||
}
|
}
|
||||||
// No fallback, propagate error
|
// No fallback, propagate error
|
||||||
(Err(err), metaconfig_types::PushrebaseRemoteMode::RemoteScs(..)) => {
|
(
|
||||||
return Err(
|
Err(err),
|
||||||
convert_bookmark_movement_err(err, hook_rejection_remapper).await?
|
metaconfig_types::PushrebaseRemoteMode::RemoteScs(..)
|
||||||
);
|
| metaconfig_types::PushrebaseRemoteMode::RemoteLandService(..),
|
||||||
}
|
) => {
|
||||||
(Err(err), _) => {
|
return Err(convert_bookmark_movement_err(err, hook_rejection_remapper).await?);
|
||||||
slog::warn!(
|
}
|
||||||
ctx.logger(),
|
(Err(err), _) => {
|
||||||
"Failed to pushrebase remotely, falling back to local. Error: {}",
|
slog::warn!(
|
||||||
err
|
ctx.logger(),
|
||||||
);
|
"Failed to pushrebase remotely, falling back to local. Error: {}",
|
||||||
let mut scuba = ctx.scuba().clone();
|
err
|
||||||
scuba.add("bookmark_name", bookmark.as_str());
|
);
|
||||||
scuba.add(
|
let mut scuba = ctx.scuba().clone();
|
||||||
"changeset_id",
|
scuba.add("bookmark_name", bookmark.as_str());
|
||||||
changesets
|
scuba.add(
|
||||||
.iter()
|
"changeset_id",
|
||||||
.next()
|
changesets
|
||||||
.map(|b| b.get_changeset_id().to_string()),
|
.iter()
|
||||||
);
|
.next()
|
||||||
Some((scuba, err))
|
.map(|b| b.get_changeset_id().to_string()),
|
||||||
}
|
);
|
||||||
|
Some((scuba, err))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#[cfg(not(fbcode_build))]
|
|
||||||
{
|
|
||||||
let _ignore_only_this_unused_variable = address;
|
|
||||||
unreachable!()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
}
|
||||||
|
};
|
||||||
let authz = AuthorizationContext::new(ctx);
|
let authz = AuthorizationContext::new(ctx);
|
||||||
let result = LocalPushrebaseClient {
|
let result = LocalPushrebaseClient {
|
||||||
ctx,
|
ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user