@@ -813,6 +813,104 @@ your local sources to the ``/opt/airflow`` location of the sources within the co
813
813
:align: center
814
814
:alt: Source code mapping
815
815
816
+ Remote Debugging on Travis CI
817
+ =============================
818
+
819
+ You can also connect IDE to Travis CI. To do this, you must pass a public IP address in the ``pydevd.set_trace ``
820
+ method. If you do not have a public IP address then you can start the virtual machine at the cloud service
821
+ provider for the time of debugging. You also need to install the appropriate debugger in Travis CI. You
822
+ need to modify the ``scripts/ci/in_container/entrypoint.sh `` file to add an pip install command
823
+ after the license header.
824
+
825
+ Setup VM on GCP with SSH forwarding
826
+ -----------------------------------
827
+
828
+ Below are the steps you need to take to set up your virtual machine in the Google Cloud Platform.
829
+
830
+ 1. The next steps will assume that you have configured environment variables with the name of the network and
831
+ virtual machine, project ID and the zone where the virtual machine will be created
832
+
833
+ .. code-block :: bash
834
+
835
+ PROJECT_ID=" <PROJECT_ID>"
836
+ GCP_ZONE=" europe-west3-a"
837
+ GCP_NETWORK_NAME=" airflow-debugging"
838
+ GCP_INSTANCE_NAME=" airflow-debugging-ci"
839
+
840
+ 2. It is necessary to configure the network and firewall for your machine.
841
+ The firewall must have unblocked access to port 22 for SSH traffic and any other port for the debugger.
842
+ In the example for the debugger we will use port 5555.
843
+
844
+ .. code-block :: bash
845
+
846
+ gcloud compute --project=" ${PROJECT_ID} " networks create " ${GCP_NETWORK_NAME} " \
847
+ --subnet-mode=auto
848
+
849
+ gcloud compute --project=" ${PROJECT_ID} " firewall-rules create " ${GCP_NETWORK_NAME} -allow-ssh" \
850
+ --network " ${GCP_NETWORK_NAME} " \
851
+ --allow tcp:22 \
852
+ --source-ranges 0.0.0.0/0
853
+
854
+ gcloud compute --project=" ${PROJECT_ID} " firewall-rules create " ${GCP_NETWORK_NAME} -allow-debugger" \
855
+ --network " ${GCP_NETWORK_NAME} " \
856
+ --allow tcp:5555 \
857
+ --source-ranges 0.0.0.0/0
858
+
859
+ 3. If you have a network, you can create a virtual machine. To save costs, you can create a `Preemptible
860
+ virtual machine <https://cloud.google.com/preemptible-vms> ` that is automatically deleted for up
861
+ to 24 hours.
862
+
863
+ .. code-block :: bash
864
+
865
+ gcloud beta compute --project=" ${PROJECT_ID} " instances create " ${GCP_INSTANCE_NAME} " \
866
+ --zone=" ${GCP_ZONE} " \
867
+ --machine-type=f1-micro \
868
+ --subnet=" ${GCP_NETWORK_NAME} " \
869
+ --image=debian-10-buster-v20200210 \
870
+ --image-project=debian-cloud \
871
+ --preemptible
872
+
873
+ To check the public IP address of the machine, you can run the command
874
+
875
+ .. code-block :: bash
876
+
877
+ gcloud compute --project=" ${PROJECT_ID} " instances describe " ${GCP_INSTANCE_NAME} " \
878
+ --zone=" ${GCP_ZONE} " \
879
+ --format=' value(networkInterfaces[].accessConfigs[0].natIP.notnull().list())'
880
+
881
+ 4. The SSH Deamon's default configuration does not allow traffic forwarding to public addresses.
882
+ To change it, modify the ``GatewayPorts `` options in the ``/etc/ssh/sshd_config `` file to ``Yes ``
883
+ and restart the SSH deamon.
884
+
885
+ .. code-block :: bash
886
+
887
+ gcloud beta compute --project=" ${PROJECT_ID} " ssh " ${GCP_INSTANCE_NAME} " \
888
+ --zone=" ${GCP_ZONE} " -- \
889
+ sudo sed -i " s/#\?\s*GatewayPorts no/GatewayPorts Yes/" /etc/ssh/sshd_config
890
+
891
+ gcloud beta compute --project=" ${PROJECT_ID} " ssh " ${GCP_INSTANCE_NAME} " \
892
+ --zone=" ${GCP_ZONE} " -- \
893
+ sudo service sshd restart
894
+
895
+ 5. To start port forwarding, run the following command:
896
+
897
+ .. code-block :: bash
898
+
899
+ gcloud beta compute --project=" ${PROJECT_ID} " ssh " ${GCP_INSTANCE_NAME} " \
900
+ --zone=" ${GCP_ZONE} " -- \
901
+ -N \
902
+ -R 0.0.0.0:5555:localhost:5555 \
903
+ -v
904
+
905
+ If you have finished using the virtual machine, remember to delete it.
906
+
907
+ .. code-block :: bash
908
+
909
+ gcloud beta compute --project=" ${PROJECT_ID} " instances delete " ${GCP_INSTANCE_NAME} " \
910
+ --zone=" ${GCP_ZONE} "
911
+
912
+ You can use the GCP service for free, if you use the `Free Tier <https://cloud.google.com/free >`__.
913
+
816
914
DAG Testing
817
915
===========
818
916
0 commit comments