Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/airflow] (ISSUE 20568) implemented feature to remove default connections #21018

Closed
wants to merge 1 commit into from
Closed

Conversation

javamonkey79
Copy link
Contributor

Signed-off-by: Shaun Elliott javamonkey79@gmail.com

What this PR does / why we need it:

  • implements the feature, to remove the default connections on startup

Which issue this PR fixes

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • DCO signed
  • Chart Version bumped
  • Variables are documented in the README.md
  • Title of the PR starts with chart name (e.g. [stable/mychartname])

Signed-off-by: Shaun Elliott <javamonkey79@gmail.com>
@helm-bot helm-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 26, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @javamonkey79. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 26, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: javamonkey79
To complete the pull request process, please assign maver1ck
You can assign the PR to them by writing /assign @maver1ck in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@javamonkey79
Copy link
Contributor Author

/assign @maver1ck

@gsemet
Copy link
Contributor

gsemet commented Feb 26, 2020

I would accept this one. @nbartelot, what do you think ?

@NBardelot
Copy link
Contributor

NBardelot commented Feb 26, 2020

After thinking about it a little bit more I now doubt that it is the chart's job to manage the default connections. Here, it hardcodes the list of default connections in a script that's not maintained at the same level they are added/removed from the Airflow project.

I see several ways to fix this:

  1. Make Airflow avoid creating the connections altogether with some new Core config.

Pro : this is the nicest way to do things.
Con : it has to be done in the Airflow project.

  1. Make the script in this commit compute the list of default connections

Pro : this is the least effort compared to the current commit.
Con : there is a risk of removing legit connections that the user named "*_default" (OK that's a bad idea, but there will be someone to do just that inevitably).

  1. As was proposed in the other issue by @javamonkey79, use the same kind of approach but for generic startup scripts provided in a configmap and mounted as a folder containing all the script (something like airflow.init.d)

Pro : that would help for other tasks, like creating users, and the user could choose exactly what to do with the default connections.
Con : everyone will need to write their own script to do the cleaning.

I'd go with 1 for being the nicest and cleanest. But 3 is also very appealing, and I'm in need of such a feature so I could make the PR anyway.

@gsemet
Copy link
Contributor

gsemet commented Feb 26, 2020

Why not keeping this hard coded list and when 1) is implemented we can remove it ? Can you open a jira ticket on airflow project about this point?

@NBardelot
Copy link
Contributor

NBardelot commented Feb 26, 2020

@gsemet it creates a hard link between the chart and the Airflow docker image version. As-is, the script would break if an attempt is made to remove the default connection while it does not exist.

Imagine you use Airflow 1.10.4 that uses a default connection named mock_default. And then in Airflow 1.11.0 this connection does not exist anymone. One should not be forced to wait for the Helm chart to be upgraded in order to use the new Airflow version (i.e. the new docker images for that version), instead of just changing the image's version in the chart's values.

Please see my PR #21047 for an implementation of idea number 3.

Note :

If you want to keep the idea of the current PR, I think the script should be reworked in order to make it resilient to errors (like the connection not existing anymore). In fact, it will need to be idempotent in any case because it will be executed when the pod restarts.

@gsemet
Copy link
Contributor

gsemet commented Feb 26, 2020

I agree with the script rework, in case upstream change we should be resilient.

@javamonkey79
Copy link
Contributor Author

@gsemet @NBardelot I explored option 2; it's not promising since the output of the airflow connections list is difficult to parse and in some cases, the data is not available (for example, see 'azure_contai...ances_default' :

$ airflow connections -l
[2020-02-26 19:22:28,971] {{settings.py:213}} INFO - settings.configure_orm(): Using pool settings. pool_size=100, max_overflow=10, pool_recycle=1800, pid=16089
[2020-02-26 19:22:29,182] {{__init__.py:51}} INFO - Using executor CeleryExecutor
╒════════════════════════════════╤═════════════════════════════╤════════════════════════════════╤════════╤════════════════╤══════════════════════╤════════════════════════════════╕
│ Conn Id                        │ Conn Type                   │ Host                           │ Port   │ Is Encrypted   │ Is Extra Encrypted   │ Extra                          │
╞════════════════════════════════╪═════════════════════════════╪════════════════════════════════╪════════╪════════════════╪══════════════════════╪════════════════════════════════╡
│ 'airflow_db'                   │ 'mysql'                     │ 'mysql'                        │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'beeline_default'              │ 'beeline'                   │ 'localhost'                    │ 10000  │ False          │ True                 │ 'gAAAAABeRGcQ...AeMF7tl8YCShC' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'bigquery_default'             │ 'google_cloud_platform'     │ None                           │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'local_mysql'                  │ 'mysql'                     │ 'localhost'                    │ None   │ True           │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'presto_default'               │ 'presto'                    │ 'localhost'                    │ 3400   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'google_cloud_default'         │ 'google_cloud_platform'     │ None                           │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'hive_cli_default'             │ 'hive_cli'                  │ None                           │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'pig_cli_default'              │ 'pig_cli'                   │ None                           │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'hiveserver2_default'          │ 'hiveserver2'               │ 'localhost'                    │ 10000  │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'metastore_default'            │ 'hive_metastore'            │ 'localhost'                    │ 9083   │ False          │ True                 │ 'gAAAAABeRGcQ...P8WRoEwZlRD4=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'mongo_default'                │ 'mongo'                     │ 'mongo'                        │ 27017  │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'mysql_default'                │ 'mysql'                     │ 'mysql'                        │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'postgres_default'             │ 'postgres'                  │ 'postgres'                     │ None   │ True           │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'sqlite_default'               │ 'sqlite'                    │ '/tmp/sqlite_default.db'       │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'http_default'                 │ 'http'                      │ 'https://www.google.com/'      │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'mssql_default'                │ 'mssql'                     │ 'localhost'                    │ 1433   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'vertica_default'              │ 'vertica'                   │ 'localhost'                    │ 5433   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'wasb_default'                 │ 'wasb'                      │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcQ...fSrcqCeRK73k=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'webhdfs_default'              │ 'hdfs'                      │ 'localhost'                    │ 50070  │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'ssh_default'                  │ 'ssh'                       │ 'localhost'                    │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'sftp_default'                 │ 'sftp'                      │ 'localhost'                    │ 22     │ False          │ True                 │ 'gAAAAABeRGcQ...bFborvKVKlNah' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'fs_default'                   │ 'fs'                        │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcQ...vDWAxIEqK_Q==' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'aws_default'                  │ 'aws'                       │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcQ...ZSc5Yp4gI5XE=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'spark_default'                │ 'spark'                     │ 'yarn'                         │ None   │ False          │ True                 │ 'gAAAAABeRGcR...PiC2tPV1l8O8=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'druid_broker_default'         │ 'druid'                     │ 'druid-broker'                 │ 8082   │ False          │ True                 │ 'gAAAAABeRGcR...AUXMEMRlblFc=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'druid_ingest_default'         │ 'druid'                     │ 'druid-overlord'               │ 8081   │ False          │ True                 │ 'gAAAAABeRGcR...zXyBnq-fx-yJp' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'redis_default'                │ 'redis'                     │ 'redis'                        │ 6379   │ False          │ True                 │ 'gAAAAABeRGcR...6_91h2h_mLw==' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'sqoop_default'                │ 'sqoop'                     │ 'rmdbs'                        │ None   │ False          │ False                │ ''                             │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'emr_default'                  │ 'emr'                       │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcR...MWFqqfeBu3FM=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'qubole_default'               │ 'qubole'                    │ 'localhost'                    │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'segment_default'              │ 'segment'                   │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcR...Umr-b_hQmimEM' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'azure_data_lake_default'      │ 'azure_data_lake'           │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcR...BHOYKrX2DWg==' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'azure_cosmos_default'         │ 'azure_cosmos'              │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcR..._tLEecrIID-w=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'azure_contai...ances_default' │ 'azure_container_instances' │ None                           │ None   │ False          │ True                 │ 'gAAAAABeRGcR...sDc7JIQbnYFM=' │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'cassandra_default'            │ 'cassandra'                 │ 'cassandra'                    │ 9042   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'dingding_default'             │ 'http'                      │ ''                             │ None   │ False          │ False                │ None                           │
├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┼────────┼────────────────┼──────────────────────┼────────────────────────────────┤
│ 'opsgenie_default'             │ 'http'                      │ ''                             │ None   │ False          │ False                │ None                           │
╘════════════════════════════════╧═════════════════════════════╧════════════════════════════════╧════════╧════════════════╧══════════════════════╧════════════════════════════════╛

If we feel strongly enough that the hardcoding of default values approach will not work, I can close my PR and just opt to use @NBardelot (and my former) approach of extra startup scripts.

wdyt?

@zanhsieh
Copy link
Collaborator

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 27, 2020
@NBardelot
Copy link
Contributor

@stale
Copy link

stale bot commented Apr 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

@stale stale bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 4, 2020
@stale
Copy link

stale bot commented Apr 18, 2020

This issue is being automatically closed due to inactivity.

@stale stale bot closed this Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[stable/airflow] allow default connections to be removed
7 participants