Skip to content

Commit fd9726b

Browse files
committed
wip: airflow versioning
1 parent 9c284ad commit fd9726b

21 files changed

Lines changed: 5525 additions & 129 deletions

File tree

Cargo.lock

Lines changed: 449 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 1675 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = "https://github.com/stackabletech/airflow-operator"
1111

1212
[workspace.dependencies]
1313
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.8.0" }
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = ["telemetry", "versioned"], tag = "stackable-operator-0.100.3" }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = ["telemetry", "versioned", "webhook"], tag = "stackable-operator-0.100.3" }
1515

1616
anyhow = "1.0"
1717
base64 = "0.22"

crate-hashes.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deploy/helm/airflow-operator/crds/crds.yaml

Lines changed: 3185 additions & 1 deletion
Large diffs are not rendered by default.

deploy/helm/airflow-operator/templates/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ kind: Deployment
44
metadata:
55
name: {{ include "operator.fullname" . }}-deployment
66
labels:
7+
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
8+
webhook.stackable.tech/conversion: enabled
9+
{{- end }}
710
{{- include "operator.labels" . | nindent 4 }}
811
spec:
912
replicas: 1
@@ -79,6 +82,7 @@ spec:
7982
value: {{ .Values.kubernetesClusterDomain | quote }}
8083
{{- end }}
8184
{{- include "telemetry.envVars" . | nindent 12 }}
85+
{{- include "maintenance.envVars" . | nindent 12 }}
8286
volumes:
8387
- name: config-spec
8488
configMap:

deploy/helm/airflow-operator/templates/roles.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ rules:
9191
- customresourcedefinitions
9292
verbs:
9393
- get
94+
# Required to maintain the CRD. The operator needs to do this, as it needs to enter e.g. it's
95+
# generated certificate in the conversion webhook.
96+
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
97+
- create
98+
- patch
99+
{{- end }}
94100
- apiGroups:
95101
- listeners.stackable.tech
96102
resources:
@@ -111,6 +117,9 @@ rules:
111117
- list
112118
- patch
113119
- watch
120+
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
121+
- create
122+
{{- end }}
114123
- apiGroups:
115124
- {{ include "operator.name" . }}.stackable.tech
116125
resources:

deploy/helm/airflow-operator/templates/service.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
{{- if .Values.maintenance.customResourceDefinitions.maintain }}
22
---
33
apiVersion: v1
44
kind: Service
@@ -11,9 +11,11 @@ metadata:
1111
{{- include "operator.labels" . | nindent 4 }}
1212
spec:
1313
selector:
14+
webhook.stackable.tech/conversion: enabled
1415
{{- include "operator.selectorLabels" . | nindent 6 }}
1516
ports:
1617
- name: conversion-webhook
1718
protocol: TCP
1819
port: 8443
1920
targetPort: 8443
21+
{{- end }}

deploy/helm/airflow-operator/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ affinity: {}
4646
# See the https://docs.stackable.tech/home/stable/guides/kubernetes-cluster-domain guide for details.
4747
# kubernetesClusterDomain: my-cluster.local
4848

49+
maintenance:
50+
endOfSupportCheck:
51+
enabled: true
52+
# mode: offline
53+
# interval: 24h
54+
55+
customResourceDefinitions:
56+
maintain: true
57+
4958
# See all available options and detailed explanations about the concept here:
5059
# https://docs.stackable.tech/home/stable/concepts/telemetry/
5160
telemetry:

rust/operator-binary/src/airflow_controller.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Ensures that `Pod`s are configured and running for each [`v1alpha1::AirflowCluster`]
1+
//! Ensures that `Pod`s are configured and running for each [`v1alpha2::AirflowCluster`]
22
use std::{
33
collections::{BTreeMap, BTreeSet, HashMap},
44
io::Write,
@@ -97,7 +97,7 @@ use crate::{
9797
FERNET_KEY_SECRET_KEY, INTERNAL_SECRET_SECRET_KEY, JWT_SECRET_SECRET_KEY,
9898
create_random_secret,
9999
},
100-
v1alpha1,
100+
v1alpha2,
101101
},
102102
env_vars::{self, build_airflow_template_envs},
103103
operations::{
@@ -137,19 +137,19 @@ pub enum Error {
137137
#[snafu(display("failed to apply Service for {rolegroup}"))]
138138
ApplyRoleGroupService {
139139
source: stackable_operator::cluster_resources::Error,
140-
rolegroup: RoleGroupRef<v1alpha1::AirflowCluster>,
140+
rolegroup: RoleGroupRef<v1alpha2::AirflowCluster>,
141141
},
142142

143143
#[snafu(display("failed to apply ConfigMap for {rolegroup}"))]
144144
ApplyRoleGroupConfig {
145145
source: stackable_operator::cluster_resources::Error,
146-
rolegroup: RoleGroupRef<v1alpha1::AirflowCluster>,
146+
rolegroup: RoleGroupRef<v1alpha2::AirflowCluster>,
147147
},
148148

149149
#[snafu(display("failed to apply StatefulSet for {rolegroup}"))]
150150
ApplyRoleGroupStatefulSet {
151151
source: stackable_operator::cluster_resources::Error,
152-
rolegroup: RoleGroupRef<v1alpha1::AirflowCluster>,
152+
rolegroup: RoleGroupRef<v1alpha2::AirflowCluster>,
153153
},
154154

155155
#[snafu(display("invalid product config"))]
@@ -200,13 +200,13 @@ pub enum Error {
200200
#[snafu(display("failed to build config file for {rolegroup}"))]
201201
BuildRoleGroupConfigFile {
202202
source: FlaskAppConfigWriterError,
203-
rolegroup: RoleGroupRef<v1alpha1::AirflowCluster>,
203+
rolegroup: RoleGroupRef<v1alpha2::AirflowCluster>,
204204
},
205205

206206
#[snafu(display("failed to build ConfigMap for {rolegroup}"))]
207207
BuildRoleGroupConfig {
208208
source: stackable_operator::builder::configmap::Error,
209-
rolegroup: RoleGroupRef<v1alpha1::AirflowCluster>,
209+
rolegroup: RoleGroupRef<v1alpha2::AirflowCluster>,
210210
},
211211

212212
#[snafu(display("failed to resolve and merge config for role and role group"))]
@@ -365,7 +365,7 @@ impl ReconcilerError for Error {
365365
}
366366

367367
pub async fn reconcile_airflow(
368-
airflow: Arc<DeserializeGuard<v1alpha1::AirflowCluster>>,
368+
airflow: Arc<DeserializeGuard<v1alpha2::AirflowCluster>>,
369369
ctx: Arc<Ctx>,
370370
) -> Result<Action> {
371371
tracing::info!("Starting reconcile");
@@ -682,7 +682,7 @@ pub async fn reconcile_airflow(
682682

683683
#[allow(clippy::too_many_arguments)]
684684
async fn build_executor_template(
685-
airflow: &v1alpha1::AirflowCluster,
685+
airflow: &v1alpha2::AirflowCluster,
686686
common_config: &CommonConfiguration<ExecutorConfigFragment, GenericProductSpecificCommonConfig>,
687687
resolved_product_image: &ResolvedProductImage,
688688
authentication_config: &AirflowClientAuthenticationDetailsResolved,
@@ -750,9 +750,9 @@ async fn build_executor_template(
750750
/// The rolegroup [`ConfigMap`] configures the rolegroup based on the configuration given by the administrator
751751
#[allow(clippy::too_many_arguments)]
752752
fn build_rolegroup_config_map(
753-
airflow: &v1alpha1::AirflowCluster,
753+
airflow: &v1alpha2::AirflowCluster,
754754
resolved_product_image: &ResolvedProductImage,
755-
rolegroup: &RoleGroupRef<v1alpha1::AirflowCluster>,
755+
rolegroup: &RoleGroupRef<v1alpha2::AirflowCluster>,
756756
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
757757
authentication_config: &AirflowClientAuthenticationDetailsResolved,
758758
authorization_config: &AirflowAuthorizationResolved,
@@ -863,9 +863,9 @@ fn build_rolegroup_config_map(
863863
}
864864

865865
fn build_rolegroup_metadata(
866-
airflow: &v1alpha1::AirflowCluster,
866+
airflow: &v1alpha2::AirflowCluster,
867867
resolved_product_image: &&ResolvedProductImage,
868-
rolegroup: &&RoleGroupRef<v1alpha1::AirflowCluster>,
868+
rolegroup: &&RoleGroupRef<v1alpha2::AirflowCluster>,
869869
prometheus_label: Label,
870870
name: String,
871871
) -> Result<ObjectMeta, Error> {
@@ -888,8 +888,8 @@ fn build_rolegroup_metadata(
888888
}
889889

890890
pub fn build_group_listener(
891-
airflow: &v1alpha1::AirflowCluster,
892-
object_labels: ObjectLabels<v1alpha1::AirflowCluster>,
891+
airflow: &v1alpha2::AirflowCluster,
892+
object_labels: ObjectLabels<v1alpha2::AirflowCluster>,
893893
listener_class: String,
894894
listener_group_name: String,
895895
) -> Result<listener::v1alpha1::Listener> {
@@ -924,10 +924,10 @@ fn listener_ports() -> Vec<listener::v1alpha1::ListenerPort> {
924924
/// The rolegroup [`StatefulSet`] runs the rolegroup, as configured by the administrator.
925925
#[allow(clippy::too_many_arguments)]
926926
fn build_server_rolegroup_statefulset(
927-
airflow: &v1alpha1::AirflowCluster,
927+
airflow: &v1alpha2::AirflowCluster,
928928
resolved_product_image: &ResolvedProductImage,
929929
airflow_role: &AirflowRole,
930-
rolegroup_ref: &RoleGroupRef<v1alpha1::AirflowCluster>,
930+
rolegroup_ref: &RoleGroupRef<v1alpha2::AirflowCluster>,
931931
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
932932
authentication_config: &AirflowClientAuthenticationDetailsResolved,
933933
authorization_config: &AirflowAuthorizationResolved,
@@ -1247,14 +1247,14 @@ fn build_logging_container(
12471247

12481248
#[allow(clippy::too_many_arguments)]
12491249
fn build_executor_template_config_map(
1250-
airflow: &v1alpha1::AirflowCluster,
1250+
airflow: &v1alpha2::AirflowCluster,
12511251
resolved_product_image: &ResolvedProductImage,
12521252
authentication_config: &AirflowClientAuthenticationDetailsResolved,
12531253
sa_name: &str,
12541254
merged_executor_config: &ExecutorConfig,
12551255
env_overrides: &HashMap<String, String>,
12561256
pod_overrides: &PodTemplateSpec,
1257-
rolegroup_ref: &RoleGroupRef<v1alpha1::AirflowCluster>,
1257+
rolegroup_ref: &RoleGroupRef<v1alpha2::AirflowCluster>,
12581258
git_sync_resources: &git_sync::v1alpha2::GitSyncResources,
12591259
) -> Result<ConfigMap> {
12601260
let mut pb = PodBuilder::new();
@@ -1386,7 +1386,7 @@ fn build_executor_template_config_map(
13861386
}
13871387

13881388
pub fn error_policy(
1389-
_obj: Arc<DeserializeGuard<v1alpha1::AirflowCluster>>,
1389+
_obj: Arc<DeserializeGuard<v1alpha2::AirflowCluster>>,
13901390
error: &Error,
13911391
_ctx: Arc<Ctx>,
13921392
) -> Action {

0 commit comments

Comments
 (0)