Skip to content

Commit b85328a

Browse files
committed
refactor!: remove ResolvedOpenLineageAppName struct
1 parent ed2c33e commit b85328a

3 files changed

Lines changed: 14 additions & 93 deletions

File tree

rust/operator-binary/src/crd/mod.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl v1alpha1::SparkApplication {
800800
// Stable job name — fixes the intermittent `unknown` bug (see the usage guide).
801801
submit_conf.insert(
802802
"spark.openlineage.appName".to_string(),
803-
self.resolved_openlineage_app_name()?.name,
803+
self.resolved_openlineage_app_name()?,
804804
);
805805
}
806806

@@ -1898,8 +1898,7 @@ spec:
18981898
sparkConf:
18991899
spark.app.name: spark-conf-name
19001900
"#},
1901-
"explicit-name",
1902-
false
1901+
"explicit-name"
19031902
)]
19041903
#[case::spark_app_name(
19051904
indoc! {r#"
@@ -1922,8 +1921,7 @@ spec:
19221921
sparkConf:
19231922
spark.app.name: spark-conf-name
19241923
"#},
1925-
"spark-conf-name",
1926-
false
1924+
"spark-conf-name"
19271925
)]
19281926
#[case::metadata_name_fallback(
19291927
indoc! {r#"
@@ -1944,21 +1942,15 @@ spec:
19441942
host: marquez
19451943
port: 5000
19461944
"#},
1947-
"metadata-name",
1948-
true
1945+
"metadata-name"
19491946
)]
1950-
fn test_openlineage_app_name_resolution(
1951-
#[case] yaml: &str,
1952-
#[case] expected_name: &str,
1953-
#[case] expected_from_metadata_name: bool,
1954-
) {
1947+
fn test_openlineage_app_name_resolution(#[case] yaml: &str, #[case] expected_name: &str) {
19551948
let deserializer = serde_yaml::Deserializer::from_str(yaml);
19561949
let spark_application: v1alpha1::SparkApplication =
19571950
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
19581951
let resolved = spark_application.resolved_openlineage_app_name().unwrap();
19591952

1960-
assert_eq!(resolved.name, expected_name);
1961-
assert_eq!(resolved.from_metadata_name, expected_from_metadata_name);
1953+
assert_eq!(resolved, expected_name);
19621954
}
19631955

19641956
impl RoundtripTestData for v1alpha1::SparkApplicationSpec {

rust/operator-binary/src/openlineage.rs

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ use snafu::OptionExt;
1313

1414
use crate::crd::{Error, ObjectHasNoNameSnafu, v1alpha1};
1515

16-
/// The resolved OpenLineage job/app name and where it came from.
17-
/// See [`v1alpha1::SparkApplication::resolved_openlineage_app_name`].
18-
#[derive(Clone, Debug, PartialEq)]
19-
pub struct ResolvedOpenLineageAppName {
20-
/// The resolved, non-blank name written to `spark.openlineage.appName`.
21-
pub name: String,
22-
/// `true` when the name fell back to `metadata.name`; the controller then emits a warning event
23-
/// because a per-run-unique name (e.g. an orchestrator-generated `-<timestamp>` suffix) fragments
24-
/// backend run history.
25-
pub from_metadata_name: bool,
26-
}
27-
2816
/// Appends `value` to a comma-separated `--conf` value in `submit_conf`, preserving any existing
2917
/// (e.g. user-supplied) entries and skipping `value` if it is already present. Used for the
3018
/// OpenLineage keys that must accumulate rather than clobber (`spark.extraListeners`, `spark.jars`).
@@ -43,36 +31,26 @@ pub(crate) fn append_conf_csv(submit_conf: &mut BTreeMap<String, String>, key: &
4331
}
4432

4533
impl v1alpha1::SparkApplication {
46-
/// Resolves the stable OpenLineage job/app name and its provenance (MVP §5), in priority order:
34+
/// Resolves the stable OpenLineage job/app name (MVP §5), in priority order:
4735
/// 1. `spec.openLineage.appName`, else
4836
/// 2. `spark.app.name` from `sparkConf`, else
49-
/// 3. `metadata.name` (a fallback the controller flags with a warning event, because a
50-
/// per-run-unique name would fragment backend run history).
37+
/// 3. `metadata.name`.
5138
///
5239
/// Always yields a non-blank name — which is exactly what fixes the intermittent `unknown` bug.
53-
pub fn resolved_openlineage_app_name(&self) -> Result<ResolvedOpenLineageAppName, Error> {
40+
pub fn resolved_openlineage_app_name(&self) -> Result<String, Error> {
5441
if let Some(app_name) = self
5542
.spec
5643
.open_lineage
5744
.as_ref()
5845
.and_then(|open_lineage| open_lineage.app_name.clone())
5946
{
60-
return Ok(ResolvedOpenLineageAppName {
61-
name: app_name,
62-
from_metadata_name: false,
63-
});
47+
return Ok(app_name);
6448
}
6549

6650
if let Some(app_name) = self.spec.spark_conf.get("spark.app.name") {
67-
return Ok(ResolvedOpenLineageAppName {
68-
name: app_name.clone(),
69-
from_metadata_name: false,
70-
});
51+
return Ok(app_name.clone());
7152
}
7253

73-
Ok(ResolvedOpenLineageAppName {
74-
name: self.metadata.name.clone().context(ObjectHasNoNameSnafu)?,
75-
from_metadata_name: true,
76-
})
54+
self.metadata.name.clone().context(ObjectHasNoNameSnafu)
7755
}
7856
}

rust/operator-binary/src/spark_k8s_controller.rs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ use snafu::{ResultExt, Snafu};
44
use stackable_operator::{
55
builder::{self},
66
kube::{
7-
Resource, ResourceExt,
7+
ResourceExt,
88
core::{DeserializeGuard, error_boundary},
9-
runtime::{
10-
controller::Action,
11-
events::{Event, EventType, Recorder},
12-
},
9+
runtime::controller::Action,
1310
},
1411
logging::controller::ReconcilerError,
1512
shared::time::Duration,
@@ -227,17 +224,6 @@ pub async fn reconcile(
227224
.await
228225
.context(ApplyApplicationSnafu)?;
229226

230-
// Warn if the OpenLineage job name falls back to `metadata.name` — only matters when
231-
// OpenLineage is enabled.
232-
if spark_application.spec.open_lineage.is_some()
233-
&& spark_application
234-
.resolved_openlineage_app_name()
235-
.context(BuildCommandSnafu)?
236-
.from_metadata_name
237-
{
238-
publish_openlineage_app_name_warning(&ctx.event_recorder, spark_application).await;
239-
}
240-
241227
let job_commands = spark_application
242228
.build_command(
243229
opt_s3conn,
@@ -312,38 +298,3 @@ pub fn error_policy(
312298
_ => Action::requeue(*Duration::from_secs(5)),
313299
}
314300
}
315-
316-
/// Emits a Kubernetes warning event that the OpenLineage job name fell back to `metadata.name`,
317-
/// which fragments backend run history when that name is unique per run. Event-publishing failures
318-
/// are logged, not propagated — they must not fail reconciliation.
319-
async fn publish_openlineage_app_name_warning(
320-
event_recorder: &Recorder,
321-
spark_application: &v1alpha1::SparkApplication,
322-
) {
323-
let name = spark_application.name_any();
324-
let publish_result = event_recorder
325-
.publish(
326-
&Event {
327-
type_: EventType::Warning,
328-
reason: "OpenLineageAppNameFallback".into(),
329-
note: Some(format!(
330-
"OpenLineage job name falls back to metadata.name ({name:?}) because neither \
331-
spec.openLineage.appName nor spark.app.name is set. If metadata.name is unique \
332-
per run (e.g. an orchestrator-generated -<timestamp> suffix), backend run \
333-
history will be fragmented into a new job per run. Set \
334-
spec.openLineage.appName to a stable value to avoid this."
335-
)),
336-
action: "ResolveOpenLineageAppName".into(),
337-
secondary: None,
338-
},
339-
&spark_application.object_ref(&()),
340-
)
341-
.await;
342-
343-
if let Err(error) = publish_result {
344-
tracing::warn!(
345-
?error,
346-
"failed to publish OpenLineage app-name fallback warning event"
347-
);
348-
}
349-
}

0 commit comments

Comments
 (0)