mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
fix(mwaa): match real MWAA's Airflow/Python pairing for the emulated image tag (#3445)
Real Amazon MWAA runs every Airflow version through 2.10.x on Python 3.11, and only 2.11.0 onward (and every 3.x release) on Python 3.12. Floci hardcoded apache/airflow:<version>-python3.12 for every supported version, so a requirements.txt built the way AWS documents (a --constraint file matching the real Airflow/Python pairing, e.g. constraints-3.11.txt for 2.9.x) resolves dependencies for the wrong Python minor version. Fixes #3438
This commit is contained in:
1 parent
924e35cefe
commit
473a26aad9
4 files changed
+34
-4
No files matched your search
@@ -2520,7 +2520,9 @@ public interface EmulatorConfig {
|
||||
String defaultPostgresImage();
|
||||
|
||||
/** Airflow versions environments may request. Combined with the image tag
|
||||
* {@code apache/airflow:<version>-python3.12}. */
|
||||
* {@code apache/airflow:<version>-<pythonTag>}, where the Python tag matches the
|
||||
* version real Amazon MWAA runs for that Airflow version: see
|
||||
* {@code MwaaEnvironmentManager.pythonTagFor}. */
|
||||
@WithDefault("2.10.5,2.9.3,2.8.4")
|
||||
List<String> supportedVersions();
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ public class MwaaEnvironmentManager {
|
||||
lifecycleManager.ensureVolume(dagsVolume);
|
||||
lifecycleManager.ensureVolume(logsVolume);
|
||||
|
||||
String image = "apache/airflow:%s-python3.12".formatted(airflowVersion);
|
||||
String image = "apache/airflow:%s-%s".formatted(airflowVersion, pythonTagFor(airflowVersion));
|
||||
String adminUser = "admin";
|
||||
String adminPassword = generateSecret(24);
|
||||
String sqlAlchemyConn = "postgresql+psycopg2://airflow:" + dbPassword + "@" + dbIp + ":" + POSTGRES_PORT + "/airflow";
|
||||
@@ -365,6 +365,20 @@ public class MwaaEnvironmentManager {
|
||||
return AwsArnUtils.regionOrDefault(environment.getArn(), "us-east-1");
|
||||
}
|
||||
|
||||
/**
|
||||
* The Python minor version tag real Amazon MWAA runs for a given {@code AirflowVersion}, so
|
||||
* the emulated image matches the same Airflow/Python pairing a requirements.txt built the way
|
||||
* AWS documents (a constraint file pinned to that pairing) expects. Per AWS's own Airflow
|
||||
* versions table, every version through 2.10.x runs Python 3.11, and 2.11.0 onward (including
|
||||
* every 3.x release) runs Python 3.12.
|
||||
*/
|
||||
static String pythonTagFor(String airflowVersion) {
|
||||
String[] parts = airflowVersion.split("\\.", 3);
|
||||
int major = Integer.parseInt(parts[0]);
|
||||
int minor = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
|
||||
return (major > 2 || (major == 2 && minor >= 11)) ? "python3.12" : "python3.11";
|
||||
}
|
||||
|
||||
/**
|
||||
* Environment variables a startup script must not be able to permanently override — mirrors
|
||||
* real MWAA's documented "reserved environment variables" (which AWS silently restores after a
|
||||
|
||||
Reference in new issue
Block a user