Skip to content

Commit 5b772cc

Browse files
committed
wip: get logging tests to work post-merge
1 parent 31e8c23 commit 5b772cc

13 files changed

Lines changed: 83 additions & 48 deletions

rust/operator-binary/src/airflow_controller.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ fn build_server_rolegroup_statefulset(
981981
authentication_config,
982982
authorization_config,
983983
git_sync_resources,
984+
&rolegroup_ref.role_group,
984985
)
985986
.context(BuildStatefulsetEnvVarsSnafu)?,
986987
);
@@ -1171,7 +1172,10 @@ fn build_server_rolegroup_statefulset(
11711172
match_labels: Some(statefulset_match_labels.into()),
11721173
..LabelSelector::default()
11731174
},
1174-
service_name: Some(rolegroup_ref.object_name()),
1175+
service_name: Some(format!(
1176+
"{name}-metrics",
1177+
name = rolegroup_ref.object_name()
1178+
)),
11751179
template: pod_template,
11761180
volume_claim_templates: pvcs,
11771181
..StatefulSetSpec::default()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ impl AirflowRole {
568568
command.extend(vec![
569569
"prepare_signal_handlers".to_string(),
570570
format!("containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &"),
571-
"airflow db migrate".to_string(),
572571
"airflow api-server &".to_string(),
573572
]);
574573
}

rust/operator-binary/src/env_vars.rs

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub enum Error {
7575
/// Return environment variables to be applied to the statefulsets for the scheduler, webserver (and worker,
7676
/// for clusters utilizing `celeryExecutor`: for clusters using `kubernetesExecutor` a different set will be
7777
/// used which is defined in [`build_airflow_template_envs`]).
78+
#[allow(clippy::too_many_arguments)]
7879
pub fn build_airflow_statefulset_envs(
7980
airflow: &v1alpha1::AirflowCluster,
8081
airflow_role: &AirflowRole,
@@ -83,11 +84,12 @@ pub fn build_airflow_statefulset_envs(
8384
auth_config: &AirflowClientAuthenticationDetailsResolved,
8485
authorization_config: &AirflowAuthorizationResolved,
8586
git_sync_resources: &git_sync::v1alpha1::GitSyncResources,
87+
rolegroup: &String,
8688
) -> Result<Vec<EnvVar>, Error> {
8789
let mut env: BTreeMap<String, EnvVar> = BTreeMap::new();
8890

8991
env.extend(static_envs(git_sync_resources));
90-
env.extend(execution_server_env_vars(airflow));
92+
env.extend(execution_server_env_vars(airflow, rolegroup));
9193

9294
// environment variables
9395
let env_vars = rolegroup_config.get(&PropertyNameKind::Env);
@@ -312,6 +314,8 @@ fn static_envs(
312314
..Default::default()
313315
});
314316

317+
// Basic auth is only relevant to 2.x and can be removed once
318+
// that version is no longer supported.
315319
env.insert(AIRFLOW_API_AUTH_BACKENDS.into(), EnvVar {
316320
name: AIRFLOW_API_AUTH_BACKENDS.into(),
317321
value: Some("airflow.api.auth.backend.basic_auth, airflow.api.auth.backend.session".into()),
@@ -374,7 +378,16 @@ pub fn build_airflow_template_envs(
374378
});
375379

376380
env.extend(static_envs(git_sync_resources));
377-
env.extend(execution_server_env_vars(airflow));
381+
382+
// It does not appear to be possible for kubernetesExecutors to work with
383+
// multiple webserver rolegroups. For the celery case, each executor sets
384+
// the execution server from the associated rolegroup, but for kubernetes
385+
// workers this is not possible.
386+
if let Some(webserver_role) = airflow.spec.webservers.as_ref() {
387+
if let Some(rolegroup) = webserver_role.role_groups.iter().next() {
388+
env.extend(execution_server_env_vars(airflow, rolegroup.0));
389+
}
390+
}
378391

379392
// _STACKABLE_POST_HOOK will contain a command to create a shutdown hook that will be
380393
// evaluated in the wrapper for each stackable spark container: this is necessary for pods
@@ -453,31 +466,28 @@ fn authorization_env_vars(authorization_config: &AirflowAuthorizationResolved) -
453466
env
454467
}
455468

456-
fn execution_server_env_vars(airflow: &v1alpha1::AirflowCluster) -> BTreeMap<String, EnvVar> {
469+
fn execution_server_env_vars(
470+
airflow: &v1alpha1::AirflowCluster,
471+
rolegroup: &String,
472+
) -> BTreeMap<String, EnvVar> {
457473
let mut env: BTreeMap<String, EnvVar> = BTreeMap::new();
458474

459-
if let Some(webserver_role) = airflow.spec.webservers.as_ref() {
460-
if let Some(rolegroup) = webserver_role.role_groups.iter().next() {
461-
if let Some(name) = airflow.metadata.name.as_ref() {
462-
let webserver = format!(
463-
"{name}-webserver-{rolegroup}",
464-
name = name,
465-
rolegroup = rolegroup.0
466-
);
467-
tracing::info!("Webserver set [{webserver}]");
468-
469-
env.insert("AIRFLOW__CORE__EXECUTION_API_SERVER_URL".into(), EnvVar {
470-
name: "AIRFLOW__CORE__EXECUTION_API_SERVER_URL".into(),
471-
value: Some(format!("http://{webserver}:8080/execution/")),
472-
..Default::default()
473-
});
474-
env.insert("AIRFLOW__CORE__BASE_URL".into(), EnvVar {
475-
name: "AIRFLOW__CORE__BASE_URL".into(),
476-
value: Some(format!("http://{webserver}:8080/")),
477-
..Default::default()
478-
});
479-
}
480-
}
475+
if let Some(name) = airflow.metadata.name.as_ref() {
476+
let webserver = format!("{name}-webserver-{rolegroup}-metrics",);
477+
tracing::debug!("Webserver set [{webserver}]");
478+
479+
// These settings are new in 3.x and will have no affect with earlier versions.
480+
env.insert("AIRFLOW__CORE__EXECUTION_API_SERVER_URL".into(), EnvVar {
481+
name: "AIRFLOW__CORE__EXECUTION_API_SERVER_URL".into(),
482+
value: Some(format!("http://{webserver}:8080/execution/")),
483+
..Default::default()
484+
});
485+
env.insert("AIRFLOW__CORE__BASE_URL".into(), EnvVar {
486+
name: "AIRFLOW__CORE__BASE_URL".into(),
487+
value: Some(format!("http://{webserver}:8080/")),
488+
..Default::default()
489+
});
481490
}
491+
482492
env
483493
}

tests/templates/kuttl/external-access/40-assert.yaml renamed to tests/templates/kuttl/external-access/40-assert.yaml.j2

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ status:
4343
---
4444
apiVersion: apps/v1
4545
kind: StatefulSet
46-
metadata:
47-
name: airflow-worker-default
48-
spec:
49-
template:
50-
spec:
51-
terminationGracePeriodSeconds: 300
52-
status:
53-
readyReplicas: 2
54-
replicas: 2
55-
---
56-
apiVersion: apps/v1
57-
kind: StatefulSet
5846
metadata:
5947
name: airflow-scheduler-default
6048
spec:
@@ -76,15 +64,6 @@ status:
7664
---
7765
apiVersion: policy/v1
7866
kind: PodDisruptionBudget
79-
metadata:
80-
name: airflow-worker
81-
status:
82-
expectedPods: 2
83-
currentHealthy: 2
84-
disruptionsAllowed: 1
85-
---
86-
apiVersion: policy/v1
87-
kind: PodDisruptionBudget
8867
metadata:
8968
name: airflow-scheduler
9069
status:
@@ -112,3 +91,27 @@ metadata:
11291
name: airflow-webserver-external-unstable
11392
spec:
11493
type: NodePort # external-unstable
94+
95+
{% if test_scenario['values']['executor'] == 'celery' %}
96+
---
97+
apiVersion: apps/v1
98+
kind: StatefulSet
99+
metadata:
100+
name: airflow-worker-default
101+
spec:
102+
template:
103+
spec:
104+
terminationGracePeriodSeconds: 300
105+
status:
106+
readyReplicas: 2
107+
replicas: 2
108+
---
109+
apiVersion: policy/v1
110+
kind: PodDisruptionBudget
111+
metadata:
112+
name: airflow-worker
113+
status:
114+
expectedPods: 2
115+
currentHealthy: 2
116+
disruptionsAllowed: 1
117+
{% endif %}

tests/templates/kuttl/external-access/install-airflow-cluster.yaml.j2

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,21 @@ spec:
4545
replicas: 1
4646
config:
4747
listenerClass: test-cluster-internal-$NAMESPACE
48+
{% if test_scenario['values']['executor'] == 'celery' %}
4849
celeryExecutors:
4950
roleGroups:
5051
default:
5152
replicas: 2
53+
{% elif test_scenario['values']['executor'] == 'kubernetes' %}
54+
kubernetesExecutors:
55+
config:
56+
resources:
57+
cpu:
58+
min: 100m
59+
max: 500m
60+
memory:
61+
limit: 1Gi
62+
{% endif %}
5263
schedulers:
5364
roleGroups:
5465
default:

tests/templates/kuttl/ldap/70-install-airflow-python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ spec:
1818
containers:
1919
- name: test-airflow-python
2020
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
21+
imagePullPolicy: IfNotPresent
2122
stdin: true
2223
tty: true

tests/templates/kuttl/logging/50-install-airflow-python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ spec:
1818
containers:
1919
- name: test-airflow-python
2020
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
21+
imagePullPolicy: IfNotPresent
2122
stdin: true
2223
tty: true

tests/templates/kuttl/mount-dags-configmap/40-install-airflow-python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ spec:
1818
containers:
1919
- name: test-airflow-python
2020
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
21+
imagePullPolicy: IfNotPresent
2122
stdin: true
2223
tty: true

tests/templates/kuttl/mount-dags-gitsync/40-install-airflow-python.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ spec:
1818
containers:
1919
- name: test-airflow-python
2020
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
21+
imagePullPolicy: IfNotPresent
2122
stdin: true
2223
tty: true

tests/templates/kuttl/oidc/50-install-test-container.yaml.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ spec:
5656
containers:
5757
- name: python
5858
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev
59+
imagePullPolicy: IfNotPresent
5960
stdin: true
6061
tty: true
6162
resources:

0 commit comments

Comments
 (0)