Skip to content

Commit 5079b7e

Browse files
Add info to deployment/service/handler (#3923)
* Add `info` field to deployment/service/handler. This is meant to propagate some configuration errors/warnings, such as when values are clamped or ignored.
1 parent e746523 commit 5079b7e

File tree

12 files changed

+312
-38
lines changed

12 files changed

+312
-38
lines changed

crates/admin-rest-model/src/deployments.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use restate_serde_util::SerdeableHeaderHashMap;
1313
use restate_types::identifiers::ServiceRevision;
1414
use restate_types::identifiers::{DeploymentId, LambdaARN};
1515
use restate_types::schema::deployment::{EndpointLambdaCompression, ProtocolType};
16+
use restate_types::schema::info::Info;
1617
use restate_types::schema::service::ServiceMetadata;
1718
use serde::{Deserialize, Serialize};
1819
use serde_with::serde_as;
@@ -186,6 +187,12 @@ pub struct RegisterDeploymentResponse {
186187
#[serde(skip_serializing_if = "Option::is_none")]
187188
#[serde(default)]
188189
pub sdk_version: Option<String>,
190+
191+
/// # Info
192+
///
193+
/// List of configuration/deprecation information related to this deployment.
194+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
195+
pub info: Vec<Info>,
189196
}
190197

191198
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
@@ -266,6 +273,12 @@ pub enum DeploymentResponse {
266273
///
267274
/// List of services exposed by this deployment.
268275
services: Vec<ServiceNameRevPair>,
276+
277+
/// # Info
278+
///
279+
/// List of configuration/deprecation information related to this deployment.
280+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
281+
info: Vec<Info>,
269282
},
270283
#[cfg_attr(
271284
feature = "schema",
@@ -331,6 +344,12 @@ pub enum DeploymentResponse {
331344
///
332345
/// List of services exposed by this deployment.
333346
services: Vec<ServiceNameRevPair>,
347+
348+
/// # Info
349+
///
350+
/// List of configuration/deprecation information related to this deployment.
351+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
352+
info: Vec<Info>,
334353
},
335354
}
336355

@@ -413,6 +432,12 @@ pub enum DetailedDeploymentResponse {
413432
///
414433
/// List of services exposed by this deployment.
415434
services: Vec<ServiceMetadata>,
435+
436+
/// # Info
437+
///
438+
/// List of configuration/deprecation information related to this deployment.
439+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
440+
info: Vec<Info>,
416441
},
417442
#[cfg_attr(
418443
feature = "schema",
@@ -479,6 +504,12 @@ pub enum DetailedDeploymentResponse {
479504
///
480505
/// List of services exposed by this deployment.
481506
services: Vec<ServiceMetadata>,
507+
508+
/// # Info
509+
///
510+
/// List of configuration/deprecation information related to this deployment.
511+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
512+
info: Vec<Info>,
482513
},
483514
}
484515

crates/admin/src/rest_api/deployments.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ fn to_register_response(
426426
id,
427427
supported_protocol_versions,
428428
sdk_version,
429+
info,
429430
..
430431
}: Deployment,
431432
services: Vec<ServiceMetadata>,
@@ -436,6 +437,7 @@ fn to_register_response(
436437
min_protocol_version: *supported_protocol_versions.start(),
437438
max_protocol_version: *supported_protocol_versions.end(),
438439
sdk_version,
440+
info,
439441
}
440442
}
441443

@@ -448,6 +450,7 @@ fn to_deployment_response(
448450
sdk_version,
449451
created_at,
450452
metadata,
453+
info,
451454
..
452455
}: Deployment,
453456
services: Vec<(String, ServiceRevision)>,
@@ -472,6 +475,7 @@ fn to_deployment_response(
472475
.into_iter()
473476
.map(|(name, revision)| ServiceNameRevPair { name, revision })
474477
.collect(),
478+
info,
475479
},
476480
DeploymentType::Lambda {
477481
arn,
@@ -492,6 +496,7 @@ fn to_deployment_response(
492496
.into_iter()
493497
.map(|(name, revision)| ServiceNameRevPair { name, revision })
494498
.collect(),
499+
info,
495500
},
496501
}
497502
}
@@ -505,6 +510,7 @@ fn to_detailed_deployment_response(
505510
sdk_version,
506511
created_at,
507512
metadata,
513+
info,
508514
..
509515
}: Deployment,
510516
services: Vec<ServiceMetadata>,
@@ -526,6 +532,7 @@ fn to_detailed_deployment_response(
526532
max_protocol_version: *supported_protocol_versions.end(),
527533
sdk_version,
528534
services,
535+
info,
529536
},
530537
DeploymentType::Lambda {
531538
arn,
@@ -543,6 +550,7 @@ fn to_detailed_deployment_response(
543550
max_protocol_version: *supported_protocol_versions.end(),
544551
sdk_version,
545552
services,
553+
info,
546554
},
547555
}
548556
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## RT0021
2+
3+
The `inactivity_timeout` option is ignored when the deployment serving the services/handlers is using Request/Response mode, such as when deploying on Lambda or using HTTP/1.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## RT0022
2+
3+
The configured `journal_retention` valued was clamped, because it's higher than the maximum value configured for the server.

crates/errors/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ mod helper;
3636

3737
declare_restate_error_codes!(
3838
RT0001, RT0002, RT0003, RT0004, RT0005, RT0006, RT0007, RT0009, RT0010, RT0011, RT0012, RT0013,
39-
RT0014, RT0015, RT0016, RT0017, RT0018, RT0019, RT0020, META0003, META0004, META0005, META0006,
40-
META0009, META0010, META0011, META0012, META0013, META0014, META0015, META0016, META0017
39+
RT0014, RT0015, RT0016, RT0017, RT0018, RT0019, RT0020, RT0021, RT0022, META0003, META0004,
40+
META0005, META0006, META0009, META0010, META0011, META0012, META0013, META0014, META0015,
41+
META0016, META0017
4142
);
4243

4344
// -- Some commonly used errors

crates/ingress-http/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ mod mocks {
174174
input_json_schema: None,
175175
output_json_schema: None,
176176
retry_policy: Default::default(),
177+
info: vec![],
177178
},
178179
)]),
179180
ty: invocation_target_metadata.target_ty.into(),
@@ -189,6 +190,7 @@ mod mocks {
189190
abort_timeout: DEFAULT_ABORT_TIMEOUT,
190191
enable_lazy_state: false,
191192
retry_policy: Default::default(),
193+
info: vec![],
192194
});
193195
self.1.add(
194196
service_name,

crates/types/src/schema/deployment.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::deployment::{
1818
DeploymentAddress, Headers, HttpDeploymentAddress, LambdaDeploymentAddress,
1919
};
2020
use crate::identifiers::{DeploymentId, LambdaARN, ServiceRevision};
21+
use crate::schema::info::Info;
2122
use crate::schema::service::ServiceMetadata;
2223
use crate::time::MillisSinceEpoch;
2324
use bytestring::ByteString;
@@ -47,6 +48,10 @@ pub struct Deployment {
4748
pub created_at: MillisSinceEpoch,
4849
/// User provided metadata during registration
4950
pub metadata: HashMap<String, String>,
51+
/// # Info
52+
///
53+
/// List of configuration/deprecation information related to this deployment.
54+
pub info: Vec<Info>,
5055
}
5156

5257
impl Deployment {
@@ -358,6 +363,7 @@ pub mod test_util {
358363
created_at: MillisSinceEpoch::now(),
359364
metadata: Default::default(),
360365
additional_headers: Default::default(),
366+
info: vec![],
361367
}
362368
}
363369

@@ -377,6 +383,7 @@ pub mod test_util {
377383
created_at: MillisSinceEpoch::now(),
378384
metadata: Default::default(),
379385
additional_headers: Default::default(),
386+
info: vec![],
380387
}
381388
}
382389
}

crates/types/src/schema/info.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) 2023 - 2025 Restate Software, Inc., Restate GmbH.
2+
// All rights reserved.
3+
//
4+
// Use of this software is governed by the Business Source License
5+
// included in the LICENSE file.
6+
//
7+
// As of the Change Date specified in that file, in accordance with
8+
// the Business Source License, use of this software will be governed
9+
// by the Apache License, Version 2.0.
10+
11+
use codederror::Code;
12+
use serde::{Deserialize, Serialize};
13+
14+
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
15+
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
16+
pub struct Info {
17+
#[serde(default, skip_serializing_if = "Option::is_none")]
18+
code: Option<String>,
19+
message: String,
20+
}
21+
22+
impl Info {
23+
pub fn new(message: impl ToString) -> Self {
24+
Self {
25+
code: None,
26+
message: message.to_string(),
27+
}
28+
}
29+
30+
pub fn new_with_code(code: &'static Code, message: impl ToString) -> Self {
31+
Self {
32+
code: Some(code.code().to_string()),
33+
message: message.to_string(),
34+
}
35+
}
36+
37+
pub fn message(&self) -> &str {
38+
&self.message
39+
}
40+
}

0 commit comments

Comments
 (0)