Skip to content

Commit 9ecfc8c

Browse files
authored
chore(socket source): Remove deprecated max_length setting from tcp and unix modes. (vectordotdev#17162)
1 parent 854d71e commit 9ecfc8c

File tree

8 files changed

+86
-97
lines changed

8 files changed

+86
-97
lines changed

lib/codecs/src/decoding/framing/newline_delimited.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct NewlineDelimitedDecoderOptions {
3434
/// consider setting the maximum length to a reasonably large value as a safety net. This
3535
/// ensures that processing is not actually unbounded.
3636
#[serde(skip_serializing_if = "vector_core::serde::skip_serializing_if_default")]
37-
max_length: Option<usize>,
37+
pub max_length: Option<usize>,
3838
}
3939

4040
impl NewlineDelimitedDecoderOptions {

lib/codecs/src/decoding/framing/octet_counting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl OctetCountingDecoderConfig {
3838
pub struct OctetCountingDecoderOptions {
3939
/// The maximum length of the byte buffer.
4040
#[serde(skip_serializing_if = "vector_core::serde::skip_serializing_if_default")]
41-
max_length: Option<usize>,
41+
pub max_length: Option<usize>,
4242
}
4343

4444
/// Codec using the `Octet Counting` format as specified in

src/sources/socket/mod.rs

+25-47
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub mod udp;
33
#[cfg(unix)]
44
mod unix;
55

6-
use codecs::{decoding::DeserializerConfig, NewlineDelimitedDecoderConfig};
6+
use codecs::decoding::DeserializerConfig;
77
use lookup::{lookup_v2::OptionalValuePath, owned_value_path};
88
use value::{kind::Collection, Kind};
99
use vector_config::configurable_component;
@@ -113,26 +113,18 @@ impl SourceConfig for SocketConfig {
113113
async fn build(&self, cx: SourceContext) -> crate::Result<super::Source> {
114114
match self.mode.clone() {
115115
Mode::Tcp(config) => {
116-
let decoding = config.decoding().clone();
117-
// TODO: in v0.30.0 , remove the `max_length` setting from
118-
// the UnixConfig, and all of the below mess and replace
119-
// it with the configured framing /
120-
// decoding.default_stream_framing().
121-
let framing = match (config.framing().clone(), config.max_length()) {
122-
(Some(framing), Some(_)) => {
123-
warn!(message = "DEPRECATION: The `max_length` setting is deprecated and will be removed in an upcoming release. Since a `framing` setting was provided, the `max_length` setting has no effect.");
124-
framing
125-
}
126-
(Some(framing), None) => framing,
127-
(None, Some(max_length)) => {
128-
warn!(message = "DEPRECATION: The `max_length` setting is deprecated and will be removed in an upcoming release. Please configure the `max_length` from the `framing` setting instead.");
129-
NewlineDelimitedDecoderConfig::new_with_max_length(max_length).into()
130-
}
131-
(None, None) => decoding.default_stream_framing(),
132-
};
133-
134116
let log_namespace = cx.log_namespace(config.log_namespace);
135-
let decoder = DecodingConfig::new(framing, decoding, log_namespace).build();
117+
118+
let decoding = config.decoding().clone();
119+
let decoder = DecodingConfig::new(
120+
config
121+
.framing
122+
.clone()
123+
.unwrap_or_else(|| decoding.default_stream_framing()),
124+
decoding,
125+
log_namespace,
126+
)
127+
.build();
136128

137129
let tcp = tcp::RawTcpSource::new(config.clone(), decoder, log_namespace);
138130
let tls_config = config.tls().as_ref().map(|tls| tls.tls_config.clone());
@@ -190,27 +182,18 @@ impl SourceConfig for SocketConfig {
190182
}
191183
#[cfg(unix)]
192184
Mode::UnixStream(config) => {
193-
let decoding = config.decoding.clone();
194-
195-
// TODO: in v0.30.0 , remove the `max_length` setting from
196-
// the UnixConfig, and all of the below mess and replace
197-
// it with the configured framing /
198-
// decoding.default_stream_framing().
199-
let framing = match (config.framing.clone(), config.max_length) {
200-
(Some(framing), Some(_)) => {
201-
warn!(message = "DEPRECATION: The `max_length` setting is deprecated and will be removed in an upcoming release. Since a `framing` setting was provided, the `max_length` setting has no effect.");
202-
framing
203-
}
204-
(Some(framing), None) => framing,
205-
(None, Some(max_length)) => {
206-
warn!(message = "DEPRECATION: The `max_length` setting is deprecated and will be removed in an upcoming release. Please configure the `max_length` from the `framing` setting instead.");
207-
NewlineDelimitedDecoderConfig::new_with_max_length(max_length).into()
208-
}
209-
(None, None) => decoding.default_stream_framing(),
210-
};
211-
212185
let log_namespace = cx.log_namespace(config.log_namespace);
213-
let decoder = DecodingConfig::new(framing, decoding, log_namespace).build();
186+
187+
let decoding = config.decoding().clone();
188+
let decoder = DecodingConfig::new(
189+
config
190+
.framing
191+
.clone()
192+
.unwrap_or_else(|| decoding.default_stream_framing()),
193+
decoding,
194+
log_namespace,
195+
)
196+
.build();
214197

215198
unix::unix_stream(config, decoder, cx.shutdown, cx.out, log_namespace)
216199
}
@@ -333,10 +316,6 @@ pub(crate) fn default_host_key() -> OptionalValuePath {
333316
OptionalValuePath::from(owned_value_path!(log_schema().host_key()))
334317
}
335318

336-
fn default_max_length() -> Option<usize> {
337-
Some(crate::serde::default_max_length())
338-
}
339-
340319
#[cfg(test)]
341320
mod test {
342321
use approx::assert_relative_eq;
@@ -527,7 +506,6 @@ mod test {
527506
let addr = next_addr();
528507

529508
let mut config = TcpConfig::from_address(addr.into());
530-
config.set_max_length(None);
531509
config.set_framing(Some(
532510
NewlineDelimitedDecoderConfig::new_with_max_length(10).into(),
533511
));
@@ -1024,7 +1002,7 @@ mod test {
10241002
let (tx, rx) = SourceSender::new_test();
10251003
let address = next_addr();
10261004
let mut config = UdpConfig::from_address(address.into());
1027-
config.max_length = Some(11);
1005+
config.max_length = 11;
10281006
let address = init_udp_with_config(tx, config).await;
10291007

10301008
send_lines_udp(
@@ -1060,7 +1038,7 @@ mod test {
10601038
let (tx, rx) = SourceSender::new_test();
10611039
let address = next_addr();
10621040
let mut config = UdpConfig::from_address(address.into());
1063-
config.max_length = Some(10);
1041+
config.max_length = 10;
10641042
config.framing = CharacterDelimitedDecoderConfig {
10651043
character_delimited: CharacterDelimitedDecoderOptions::new(b',', None),
10661044
}

src/sources/socket/tcp.rs

+3-23
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
tls::TlsSourceConfig,
1818
};
1919

20-
use super::{default_host_key, default_max_length, SocketConfig};
20+
use super::{default_host_key, SocketConfig};
2121

2222
/// TCP configuration for the `socket` source.
2323
#[serde_as]
@@ -30,16 +30,6 @@ pub struct TcpConfig {
3030
#[configurable(derived)]
3131
keepalive: Option<TcpKeepaliveConfig>,
3232

33-
/// The maximum buffer size of incoming messages.
34-
///
35-
/// Messages larger than this are truncated.
36-
// TODO: communicated as deprecated in v0.29.0, can be removed in v0.30.0
37-
#[configurable(
38-
deprecated = "This option has been deprecated. Configure `max_length` on the framing config instead."
39-
)]
40-
#[configurable(metadata(docs::type_unit = "bytes"))]
41-
max_length: Option<usize>,
42-
4333
/// The timeout before a connection is forcefully closed during shutdown.
4434
#[serde(default = "default_shutdown_timeout_secs")]
4535
#[serde_as(as = "serde_with::DurationSeconds<u64>")]
@@ -85,11 +75,11 @@ pub struct TcpConfig {
8575
pub connection_limit: Option<u32>,
8676

8777
#[configurable(derived)]
88-
framing: Option<FramingConfig>,
78+
pub(super) framing: Option<FramingConfig>,
8979

9080
#[configurable(derived)]
9181
#[serde(default = "default_decoding")]
92-
decoding: DeserializerConfig,
82+
pub(super) decoding: DeserializerConfig,
9383

9484
/// The namespace to use for logs. This overrides the global setting.
9585
#[serde(default)]
@@ -110,7 +100,6 @@ impl TcpConfig {
110100
Self {
111101
address,
112102
keepalive: None,
113-
max_length: default_max_length(),
114103
shutdown_timeout_secs: default_shutdown_timeout_secs(),
115104
host_key: default_host_key(),
116105
port_key: default_port_key(),
@@ -152,10 +141,6 @@ impl TcpConfig {
152141
self.keepalive
153142
}
154143

155-
pub const fn max_length(&self) -> Option<usize> {
156-
self.max_length
157-
}
158-
159144
pub const fn shutdown_timeout_secs(&self) -> Duration {
160145
self.shutdown_timeout_secs
161146
}
@@ -173,11 +158,6 @@ impl TcpConfig {
173158
self
174159
}
175160

176-
pub fn set_max_length(&mut self, val: Option<usize>) -> &mut Self {
177-
self.max_length = val;
178-
self
179-
}
180-
181161
pub fn set_shutdown_timeout_secs(&mut self, val: u64) -> &mut Self {
182162
self.shutdown_timeout_secs = Duration::from_secs(val);
183163
self

src/sources/socket/udp.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub struct UdpConfig {
4545
/// Messages larger than this are truncated.
4646
#[serde(default = "default_max_length")]
4747
#[configurable(metadata(docs::type_unit = "bytes"))]
48-
pub(super) max_length: Option<usize>,
48+
pub(super) max_length: usize,
4949

5050
/// Overrides the name of the log field used to add the peer host to each event.
5151
///
@@ -95,8 +95,8 @@ fn default_port_key() -> OptionalValuePath {
9595
OptionalValuePath::from(owned_value_path!("port"))
9696
}
9797

98-
fn default_max_length() -> Option<usize> {
99-
Some(crate::serde::default_max_length())
98+
fn default_max_length() -> usize {
99+
crate::serde::default_max_length()
100100
}
101101

102102
impl UdpConfig {
@@ -163,9 +163,7 @@ pub(super) fn udp(
163163
}
164164
}
165165

166-
let mut max_length = config
167-
.max_length
168-
.unwrap_or_else(|| default_max_length().unwrap());
166+
let mut max_length = config.max_length;
169167

170168
if let Some(receive_buffer_bytes) = config.receive_buffer_bytes {
171169
max_length = std::cmp::min(max_length, receive_buffer_bytes);

src/sources/socket/unix.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
SourceSender,
2020
};
2121

22-
use super::{default_host_key, default_max_length, SocketConfig};
22+
use super::{default_host_key, SocketConfig};
2323

2424
/// Unix domain socket configuration for the `socket` source.
2525
#[configurable_component]
@@ -41,16 +41,6 @@ pub struct UnixConfig {
4141
#[configurable(metadata(docs::examples = 508))]
4242
pub socket_file_mode: Option<u32>,
4343

44-
/// The maximum buffer size of incoming messages.
45-
///
46-
/// Messages larger than this are truncated.
47-
// TODO: communicated as deprecated in v0.29.0, can be removed in v0.30.0
48-
#[configurable(
49-
deprecated = "This option has been deprecated. Configure `max_length` on the framing config instead."
50-
)]
51-
#[configurable(metadata(docs::type_unit = "bytes"))]
52-
pub max_length: Option<usize>,
53-
5444
/// Overrides the name of the log field used to add the peer host to each event.
5545
///
5646
/// The value will be the peer host's address, including the port i.e. `1.2.3.4:9000`.
@@ -82,7 +72,6 @@ impl UnixConfig {
8272
Self {
8373
path,
8474
socket_file_mode: None,
85-
max_length: default_max_length(),
8675
host_key: default_host_key(),
8776
framing: None,
8877
decoding: default_decoding(),
@@ -135,12 +124,22 @@ pub(super) fn unix_datagram(
135124
out: SourceSender,
136125
log_namespace: LogNamespace,
137126
) -> crate::Result<Source> {
127+
let max_length = config
128+
.framing
129+
.and_then(|framing| match framing {
130+
FramingConfig::CharacterDelimited {
131+
character_delimited,
132+
} => character_delimited.max_length,
133+
FramingConfig::NewlineDelimited { newline_delimited } => newline_delimited.max_length,
134+
FramingConfig::OctetCounting { octet_counting } => octet_counting.max_length,
135+
_ => None,
136+
})
137+
.unwrap_or_else(crate::serde::default_max_length);
138+
138139
build_unix_datagram_source(
139140
config.path,
140141
config.socket_file_mode,
141-
config
142-
.max_length
143-
.unwrap_or_else(crate::serde::default_max_length),
142+
max_length,
144143
decoder,
145144
move |events, received_from| {
146145
handle_events(events, &config.host_key, received_from, log_namespace)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
date: "2023-05-23"
3+
title: "0.30 Upgrade Guide"
4+
description: "An upgrade guide that addresses breaking changes in 0.30.0"
5+
authors: ["neuronull"]
6+
release: "0.30.0"
7+
hide_on_release_notes: false
8+
badges:
9+
type: breaking change
10+
---
11+
12+
Vector's 0.30.0 release includes **breaking changes**:
13+
14+
1. [Removal of the `socket` source's `tcp` and `unix` mode `max_length` setting](#socket-source-max-length)
15+
16+
We cover them below to help you upgrade quickly:
17+
18+
## Upgrade guide
19+
20+
### Breaking changes
21+
22+
#### Removal of the `socket` source's `tcp` and `unix` mode `max_length` setting {#socket-source-max-length}
23+
24+
In v0.29.0 the `max_length` setting, used by the `tcp` and `unix` modes
25+
of the `socket` source, was marked as deprecated.
26+
27+
That setting was replaced by the `max_length` setting within the `framing`
28+
setting.
29+
30+
Any explicit usages of `max_length` for those modes of the `socket`
31+
source will no longer work and configurations will need to instead use
32+
a `framing` setting in order to set a maximum length.

website/cue/reference/components/sources/base/socket.cue

+6-4
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,17 @@ base: components: sources: socket: configuration: {
191191
type: uint: unit: "seconds"
192192
}
193193
max_length: {
194-
deprecated: true
195-
deprecated_message: "This option has been deprecated. Configure `max_length` on the framing config instead."
196194
description: """
197195
The maximum buffer size of incoming messages.
198196
199197
Messages larger than this are truncated.
200198
"""
201-
required: false
202-
type: uint: unit: "bytes"
199+
relevant_when: "mode = \"udp\""
200+
required: false
201+
type: uint: {
202+
default: 102400
203+
unit: "bytes"
204+
}
203205
}
204206
mode: {
205207
description: "The type of socket to use."

0 commit comments

Comments
 (0)