Skip to content

Geo: Add function to call /api/v4/internal/geo_proxy in Workhorse

What does this MR do?

When GEO_SECONDARY_PROXY=1, Workhorse will make a request to /api/v4/geo/proxy within every request received by Workhorse.

For now, we only log the result of the request. We don't use it.

Example gdk tail gitlab-workhorse output on visiting /help on a Geo secondary site

Before

2021-06-18_00:13:56.52870 gitlab-workhorse      : {"content_type":"text/html; charset=utf-8","correlation_id":"01F8E7F486SE9TN8TBBJGSTB6Q","duration_ms":682,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:51049","remote_ip":"127.0.0.1","route":"","status":200,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":681,"uri":"/help","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":157276}
2021-06-18_00:13:56.56453 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F4YGBKKZYR4R1ES1184G","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51049","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":4,"uri":"/assets/webpack/runtime.bundle.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.57246 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F4YGBKKZYR4R1GRC1Q5F","duration_ms":12,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51066","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":12,"uri":"/assets/webpack/main.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.57328 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F4YGBKKZYR4R1MG243TP","duration_ms":12,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51053","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":12,"uri":"/assets/webpack/pages.help.index.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.57412 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F4YGBKKZYR4R1PD9AV30","duration_ms":13,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51054","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":13,"uri":"/assets/webpack/performance_bar.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.79240 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F55GA64CSS9SA5M4GTSD","duration_ms":7,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51066","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":7,"uri":"/assets/webpack/48.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.79547 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F55GA64CSS9SA6ZJQQXS","duration_ms":10,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51054","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":10,"uri":"/assets/webpack/55.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.88255 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F4ZMM2ZRENT6CFHPN681","duration_ms":285,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51049","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":285,"uri":"/assets/icons-1b2dadc4c3d49797908ba67b8f10da5d63dd15d859bde28d66fb60bbb97a4dd5.svg","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.93301 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5A0P5V2PHZ5XXWY4E9N","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51049","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":4,"uri":"/assets/webpack/vendors-ide_runtime-shortcutsBundle.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.93378 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5A0P5V2PHZ5Y3RTTHJD","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51054","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":4,"uri":"/assets/webpack/shortcutsBundle.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:56.93424 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5A0P5V2PHZ5Y0SM38S6","duration_ms":5,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51066","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:56-07:00","ttfb_ms":5,"uri":"/assets/webpack/commons-ide_runtime-pages.groups.boards-pages.groups.details-pages.groups.epic_boards-pages.groups.e-6e693280.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:57.05452 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5DTTAJVPRG5DR3F1VJJ","duration_ms":3,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51049","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:57-07:00","ttfb_ms":3,"uri":"/assets/webpack/25.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:57.05496 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5DTTAJVPRG5DVK881YH","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51054","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:57-07:00","ttfb_ms":4,"uri":"/assets/webpack/34.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:57.05836 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5DTTAJVPRG5DXJS9BW9","duration_ms":7,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51055","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:57-07:00","ttfb_ms":7,"uri":"/assets/webpack/top_nav.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:57.05931 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7F5DTTAJVPRG5DS5593Q6","duration_ms":8,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51066","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:13:57-07:00","ttfb_ms":8,"uri":"/assets/webpack/vendors-top_nav.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:13:57.07043 gitlab-workhorse      : {"content_type":"application/json; charset=utf-8","correlation_id":"01F8E7F55K6VZW83PKPWF698AC","duration_ms":282,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51053","remote_ip":"127.0.0.1","route":"^/-/","status":200,"system":"http","time":"2021-06-17T17:13:57-07:00","ttfb_ms":282,"uri":"/-/peek/results?request_id=01F8E7F486SE9TN8TBBJGSTB6Q","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":19475}

After

Notice all the "msg":"Geo Proxy: Set route according to Geo Proxy logic." logs. That's the code location where we will later branch into either "Proxy to primary" or "Serve locally".

2021-06-18_00:15:45.30799 gitlab-workhorse      : {"correlation_id":"01F8E7JERP9SNC1F2JAZA2T719","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:45-07:00","uri":"/help"}
2021-06-18_00:15:45.97310 gitlab-workhorse      : {"content_type":"text/html; charset=utf-8","correlation_id":"01F8E7JERP9SNC1F2JAZA2T719","duration_ms":664,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:51096","remote_ip":"127.0.0.1","route":"","status":200,"system":"http","time":"2021-06-17T17:15:45-07:00","ttfb_ms":664,"uri":"/help","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":157276}
2021-06-18_00:15:46.58207 gitlab-workhorse      : {"correlation_id":"01F8E7JFW9R0FSC4JNP420A1C2","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:46-07:00","uri":"/assets/icons-1b2dadc4c3d49797908ba67b8f10da5d63dd15d859bde28d66fb60bbb97a4dd5.svg"}
2021-06-18_00:15:46.60991 gitlab-workhorse      : {"correlation_id":"01F8E7JFWB9C9J3YRPTNE23HPA","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:46-07:00","uri":"/assets/webpack/runtime.bundle.js"}
2021-06-18_00:15:46.61516 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JFWB9C9J3YRPTNE23HPA","duration_ms":5,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51098","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:46-07:00","ttfb_ms":4,"uri":"/assets/webpack/runtime.bundle.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":42318}
2021-06-18_00:15:46.61948 gitlab-workhorse      : {"correlation_id":"01F8E7JFWB9C9J3YRPTHH6FF48","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:46-07:00","uri":"/assets/webpack/performance_bar.chunk.js"}
2021-06-18_00:15:46.62246 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JFWB9C9J3YRPTHH6FF48","duration_ms":2,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51099","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:46-07:00","ttfb_ms":2,"uri":"/assets/webpack/performance_bar.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":47043}
2021-06-18_00:15:46.69573 gitlab-workhorse      : {"correlation_id":"01F8E7JFWC1KBTECF6MRACBRJ3","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:46-07:00","uri":"/assets/webpack/pages.help.index.chunk.js"}
2021-06-18_00:15:46.69887 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JFWC1KBTECF6MRACBRJ3","duration_ms":3,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51100","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:46-07:00","ttfb_ms":2,"uri":"/assets/webpack/pages.help.index.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":38134}
2021-06-18_00:15:46.77547 gitlab-workhorse      : {"correlation_id":"01F8E7JFWD56G5SQMM51BFAEFT","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:46-07:00","uri":"/assets/webpack/main.chunk.js"}
2021-06-18_00:15:46.78525 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JFWD56G5SQMM51BFAEFT","duration_ms":9,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51101","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:46-07:00","ttfb_ms":9,"uri":"/assets/webpack/main.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:46.96915 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JFW9R0FSC4JNP420A1C2","duration_ms":386,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51096","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:46-07:00","ttfb_ms":386,"uri":"/assets/icons-1b2dadc4c3d49797908ba67b8f10da5d63dd15d859bde28d66fb60bbb97a4dd5.svg","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:47.36029 gitlab-workhorse      : {"correlation_id":"01F8E7JGSAE9VPQDMWQRWT51C2","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:47-07:00","uri":"/assets/webpack/48.chunk.js"}
2021-06-18_00:15:47.36864 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JGSAE9VPQDMWQRWT51C2","duration_ms":8,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51096","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:47-07:00","ttfb_ms":8,"uri":"/assets/webpack/48.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:47.50998 gitlab-workhorse      : {"correlation_id":"01F8E7JGXQ6ZQH81EH0TFGDKKB","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:47-07:00","uri":"/assets/webpack/vendors-ide_runtime-shortcutsBundle.chunk.js"}
2021-06-18_00:15:47.51377 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JGXQ6ZQH81EH0TFGDKKB","duration_ms":3,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51100","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:47-07:00","ttfb_ms":3,"uri":"/assets/webpack/vendors-ide_runtime-shortcutsBundle.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":34512}
2021-06-18_00:15:47.73735 gitlab-workhorse      : {"correlation_id":"01F8E7JGSAE9VPQDMWQS57YNQY","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:47-07:00","uri":"/assets/webpack/55.chunk.js"}
2021-06-18_00:15:47.74189 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JGSAE9VPQDMWQS57YNQY","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51099","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:47-07:00","ttfb_ms":4,"uri":"/assets/webpack/55.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:47.85760 gitlab-workhorse      : {"correlation_id":"01F8E7JGSHE2GXN0GKDP81M69P","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:47-07:00","uri":"/-/peek/results?request_id=01F8E7JERP9SNC1F2JAZA2T719"}
2021-06-18_00:15:47.98018 gitlab-workhorse      : {"correlation_id":"01F8E7JGXQ6ZQH81EH0WDVGT2V","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:47-07:00","uri":"/assets/webpack/commons-ide_runtime-pages.groups.boards-pages.groups.details-pages.groups.epic_boards-pages.groups.e-6e693280.chunk.js"}
2021-06-18_00:15:47.98735 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JGXQ6ZQH81EH0WDVGT2V","duration_ms":7,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51101","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:47-07:00","ttfb_ms":5,"uri":"/assets/webpack/commons-ide_runtime-pages.groups.boards-pages.groups.details-pages.groups.epic_boards-pages.groups.e-6e693280.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":37433}
2021-06-18_00:15:48.07366 gitlab-workhorse      : {"correlation_id":"01F8E7JH77DEGJFWS44KTBEQ4Z","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:48-07:00","uri":"/assets/webpack/25.chunk.js"}
2021-06-18_00:15:48.07808 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JH77DEGJFWS44KTBEQ4Z","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51096","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":4,"uri":"/assets/webpack/25.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:48.08903 gitlab-workhorse      : {"correlation_id":"01F8E7JGXRYYXZW64NZ3J3EHNQ","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:48-07:00","uri":"/assets/webpack/shortcutsBundle.chunk.js"}
2021-06-18_00:15:48.09319 gitlab-workhorse      : {"content_type":"application/javascript; charset=UTF-8","correlation_id":"01F8E7JGXRYYXZW64NZ3J3EHNQ","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51107","remote_ip":"127.0.0.1","route":"^/assets/","status":200,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":3,"uri":"/assets/webpack/shortcutsBundle.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":25397}
2021-06-18_00:15:48.16972 gitlab-workhorse      : {"correlation_id":"01F8E7JH9TDAABP3EEWA9A62CA","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:48-07:00","uri":"/assets/webpack/vendors-top_nav.chunk.js"}
2021-06-18_00:15:48.17410 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JH9TDAABP3EEWA9A62CA","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51100","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":4,"uri":"/assets/webpack/vendors-top_nav.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:48.32984 gitlab-workhorse      : {"correlation_id":"01F8E7JHGYX8E0QMV93S5YAFDS","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:48-07:00","uri":"/assets/webpack/34.chunk.js"}
2021-06-18_00:15:48.33417 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JHGYX8E0QMV93S5YAFDS","duration_ms":4,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51099","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":4,"uri":"/assets/webpack/34.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}
2021-06-18_00:15:48.35589 gitlab-workhorse      : {"content_type":"application/json; charset=utf-8","correlation_id":"01F8E7JGSHE2GXN0GKDP81M69P","duration_ms":498,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51098","remote_ip":"127.0.0.1","route":"^/-/","status":200,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":497,"uri":"/-/peek/results?request_id=01F8E7JERP9SNC1F2JAZA2T719","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":24322}
2021-06-18_00:15:48.40580 gitlab-workhorse      : {"correlation_id":"01F8E7JHRK9NAKBS0X9WNPC4RZ","level":"info","method":"GET","msg":"Geo Proxy: Set route according to Geo Proxy logic.","time":"2021-06-17T17:15:48-07:00","uri":"/assets/webpack/top_nav.chunk.js"}
2021-06-18_00:15:48.40838 gitlab-workhorse      : {"content_type":"","correlation_id":"01F8E7JHRK9NAKBS0X9WNPC4RZ","duration_ms":2,"host":"gdk.test:3001","level":"info","method":"GET","msg":"access","proto":"HTTP/1.1","referrer":"http://gdk.test:3001/help","remote_addr":"127.0.0.1:51101","remote_ip":"127.0.0.1","route":"^/assets/","status":304,"system":"http","time":"2021-06-17T17:15:48-07:00","ttfb_ms":2,"uri":"/assets/webpack/top_nav.chunk.js","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0","written_bytes":0}

What happens on non-Geo deployments and Geo primary sites?

They do not output Geo Proxy: Set route according to Geo Proxy logic. because when Workhorse asks /api/v4/geo/proxy "Am I a Geo Proxy?", the response is empty, meaning "No". Instead, they output like:

2021-06-22_23:06:21.85911 gitlab-workhorse      : {"correlation_id":"01F8TZJZK0F97DC086HX0A2VCK","error":"GetGeoProxyURL: No URL received, therefore this is not a Geo secondary site.","level":"error","method":"GET","msg":"Geo Proxy: Falling back to normal routing.","time":"2021-06-22T16:06:21-07:00","uri":"/assets/icon_anchor-297aa9b0225eff3d6d0da74ce042a0ed5575b92aa66b7109a5e060a795b42e36.svg"}

Related issues

Resolves #329670 (closed)

Where does this fit in the epic?

Description Issue
Add endpoint /api/v4/geo/proxy !63343 (merged)
Determine if this is a Geo Proxy by calling /api/v4/geo/proxy #329670 (closed) !60769 (merged) You are here
If this is a Geo Proxy, then use the Geo Proxy routing table #329672 (closed) !63321 (merged)
Before we can remove the environment variable, we must add caching of the result of the request #329671 (closed)

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

How to test this change locally on MacOS

  • Change directory to your Geo secondary GDK (This feature should have no effect on a Geo primary or non-Geo instance, though even in those cases, Workhorse will begin to make new internal API calls): cd /path/to/your/gdk-geo
  • Build workhorse: make gitlab-workhorse-update

After Workhorse is built, then you need to run Workhorse with an environment variable set GEO_SECONDARY_PROXY=1. I don't know why this is so hard, but you have two options:

Option 1: Set GEO_SECONDARY_PROXY=1 in Procfile

  • Edit your Geo GDK's Procfile
  • Add GEO_SECONDARY_PROXY=1 to the Workhorse line gitlab-workhorse: exec /usr/bin/env so it looks like gitlab-workhorse: exec /usr/bin/env GEO_SECONDARY_PROXY=1 (you only have to do this once until the next reconfigure)
  • gdk restart gitlab-workhorse

Option 2: Run gitlab-workhorse bin manually so it can see your shell's environment variables

  • Note the command that GDK runs to run workhorse: ps aux | grep gitlab-workhorse
  • Stop GDK-managed workhorse since you need to run it with an environment variable, which sounds like a pain to set system-wide on MacOS: gdk stop gitlab-workhorse
  • Set the environment variable and run Workhorse manually. This is what I run: GEO_SECONDARY_PROXY=1 ./gitlab/workhorse/gitlab-workhorse -authSocket /Users/mkozonogitlab/Developer/gdk-geo/gitlab.socket -cableSocket /Users/mkozonogitlab/Developer/gdk-geo/gitlab.socket -listenAddr gdk.test:3001 -documentRoot /Users/mkozonogitlab/Developer/gdk-geo/gitlab/public -developmentMode -secretPath /Users/mkozonogitlab/Developer/gdk-geo/gitlab/.gitlab_workhorse_secret -config /Users/mkozonogitlab/Developer/gdk-geo/gitlab/workhorse/config.toml -logFormat json

When running Workhorse with the environment variable set, you should see Workhorse log output like Geo Proxy: Set route according to Geo Proxy logic..

Edited by Michael Kozono

Merge request reports