Skip to content
Snippets Groups Projects
Commit c78654f1 authored by Doug Barrett's avatar Doug Barrett :two:
Browse files

Merge branch 'main' into 2152-make-doctor-diagnostics-optionally-correctable

parents 34a078f9 025667b6
No related branches found
No related tags found
Loading
Showing
with 71 additions and 87 deletions
......@@ -54,7 +54,7 @@ to `$GDK_ROOT` with the directory GDK is located):
(cd $GDK_ROOT && gdk reconfigure && gdk update)
```
1. (Optional) [Uninstall asdf](https://asdf-vm.com/manage/core.html#uninstall).
1. [Uninstall asdf](https://asdf-vm.com/manage/core.html#uninstall) if you're not using it outside of GDK.
## Troubleshooting
......
......@@ -303,6 +303,8 @@ nginx:
http2:
enabled: false
listen_address: 127.0.0.1
sendfile:
enabled: false
ssl:
certificate: localhost.crt
key: localhost.key
......
......@@ -27,7 +27,7 @@ module GDK
Rake::Task[name].invoke(**args)
true
rescue RuntimeError => e
out.error(e.message)
out.error(e.message, e)
false
end
......
......@@ -79,22 +79,6 @@ module GDK
Shellout.new(%w[git rev-parse HEAD], chdir: config.gdk_root).run
end
def run_rake_reconfigure
Rake::Task[:reconfigure].invoke
true
rescue RuntimeError => e
GDK::Output.error(e.message)
false
end
def run_rake_update
Rake::Task[:update].invoke
true
rescue RuntimeError => e
GDK::Output.error(e.message)
false
end
def check_gdk_available
return if Utils.executable_exist_via_tooling_manager?('gdk')
......
......@@ -828,6 +828,10 @@ module GDK
'\.git/info/lfs/objects/batch$'
]
end
settings(:sendfile) do
bool(:enabled) { !GDK::Machine.macos? }
end
end
settings :postgresql do
......
......@@ -5,7 +5,7 @@ require 'pathname'
module GDK
module Services
class GitlabHttpRouter < Base
BASE_COMMAND = "support/exec-cd gitlab-http-router npm run dev -- -c wrangler.gdk.toml"
BASE_COMMAND = 'support/exec-cd gitlab-http-router npm run dev -- -c wrangler.toml --ip %{ip} --port %{port} --var GITLAB_PROXY_HOST:%{proxy_host} --var GITLAB_RULES_CONFIG:%{rules_config}'
TOPOLOGY_SERVICE_COMMAND = ' --var GITLAB_TOPOLOGY_SERVICE_URL:http://localhost:%{port}'
HTTPS_COMMAND = ' --local-protocol https --https-key-path %{key_path} --https-cert-path %{certificate_path}'
......@@ -14,7 +14,12 @@ module GDK
end
def command
base_command = BASE_COMMAND.dup
base_command = format(BASE_COMMAND, {
ip: config.hostname,
port: config.gitlab_http_router.use_distinct_port? ? config.gitlab_http_router.port : config.port,
proxy_host: config.nginx? ? config.nginx.__listen_address : config.workhorse.__listen_address,
rules_config: config.gitlab_http_router.gitlab_rules_config
})
if config.gitlab_topology_service.enabled?
base_command << format(TOPOLOGY_SERVICE_COMMAND,
......
......@@ -88,7 +88,6 @@ module GDK
end
tasks.add_template(name: 'gitlab-topology-service/config.toml', no_op_condition: 'gitlab_topology_service_enabled')
tasks.add_template(name: 'gitlab-http-router/wrangler.gdk.toml', no_op_condition: 'gitlab_http_router_enabled')
tasks.add_template(name: 'gitlab/config/vite.gdk.json')
tasks.add_template(name: 'gitlab/workhorse/config.toml')
tasks.add_template(name: 'gitlab-k8s-agent-config.yml')
......
......@@ -26,7 +26,13 @@ module GDK
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
send_telemetry(result, command, {
send_telemetry(result, command, duration: duration)
result
end
def self.send_telemetry(success, command, duration:)
payload = {
duration: duration,
environment: environment,
platform: GDK::Machine.platform,
......@@ -34,12 +40,8 @@ module GDK
version_manager: version_manager,
team_member: team_member?,
session_id: session_id
})
result
end
}
def self.send_telemetry(success, command, payload = {})
# This is tightly coupled to GDK commands and returns false when the system call exits with a non-zero status.
status = success ? 'Finish' : 'Failed'
......@@ -131,7 +133,7 @@ module GDK
# This should only be used for telemetry and NEVER for authentication.
def self.team_member?
Shellout.new(%w[git config --get user.email], chdir: GDK.config.gdk_root)
.run.include?('@gitlab.com')
.run.include?('@gitlab.com')
end
def self.update_settings(username)
......
......@@ -25,7 +25,7 @@ module Support
return unless GDK::Telemetry.telemetry_enabled?
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - @telemetry_start
GDK::Telemetry.send_telemetry(success, telemetry_name, { duration: duration, environment: GDK::Telemetry.environment, platform: GDK::Machine.platform, architecture: GDK::Machine.architecture })
GDK::Telemetry.send_telemetry(success, telemetry_name, duration: duration)
end
end
end
......
......@@ -27,6 +27,7 @@ class AsdfToMise
def remove_asdf_from_shell_configs
GDK::Output.info('Removing "source" commands for asdf from shell config files...')
GDK::Output.puts
shell_configs = {
'~/.bashrc' => 'asdf.sh',
......@@ -36,13 +37,16 @@ class AsdfToMise
'~/.config/nushell/config.nu' => 'asdf.nu'
}
@asdf_sourced_shell_configs = []
shell_configs.each do |path, asdf_script|
full_path = File.expand_path(path)
next unless File.file?(full_path)
content = File.read(full_path)
original = content.dup
@asdf_sourced_shell_configs << full_path if content.match?(/source.*asdf/)
original = content.dup
content.gsub!(%r{\n# Added by GDK bootstrap\nsource .*?/\.asdf/#{Regexp.escape(asdf_script)}$\n}, '')
next if content == original
......@@ -82,12 +86,29 @@ class AsdfToMise
def display_success_message
GDK::Output.success('Migration from asdf to mise is almost complete!')
GDK::Output.puts
GDK::Output.notice('If you\'re using a shell other than Bash or Zsh, please follow https://mise.jdx.dev/getting-started.html#_2-activate-mise to activate mise.')
GDK::Output.notice('Next steps:')
GDK::Output.puts
GDK::Output.notice(
'Please restart your terminal now. Afterward, run the following commands:
gdk reconfigure && gdk update'
)
step = 1
return if @asdf_sourced_shell_configs.empty?
unless @asdf_sourced_shell_configs.empty?
GDK::Output.notice(<<~MESSAGE)
#{step}. Found asdf configuration in:
- #{@asdf_sourced_shell_configs.join("\n - ")}
If you only use asdf for GDK: You can remove the asdf source lines from these files
If you use asdf for other projects: Keep these lines but this might conflict with GDK using mise to manage versions
MESSAGE
GDK::Output.puts
step += 1
end
GDK::Output.notice("#{step}. If you're using a shell other than Bash or Zsh, please follow https://mise.jdx.dev/getting-started.html#_2-activate-mise to activate mise.")
GDK::Output.puts
GDK::Output.notice("#{step + 1}. Please restart your terminal. Afterward, run this command:")
GDK::Output.puts(' gdk reconfigure && gdk update')
end
def run_command(command, error_message)
......
......@@ -74,8 +74,8 @@ task :setup_ai_gateway do
end
end
env_runit_contents.include?('export AI_GATEWAY_URL=http://0.0.0.0:5052') ||
(new_content << 'export AI_GATEWAY_URL=http://0.0.0.0:5052')
env_runit_contents.include?('export AI_GATEWAY_URL=http://127.0.0.1:5052') ||
(new_content << 'export AI_GATEWAY_URL=http://127.0.0.1:5052')
f.write("#{new_content.join("\n")}\n")
GDK::Output.puts "Updated env.runit file with #{new_content}"
......
......@@ -9,7 +9,8 @@ RSpec.describe GDK::Services::GitlabHttpRouter do
let(:gdk_basepath) { GDK.config.gdk_root }
let(:key_path) { gdk_basepath.join('localhost.key') }
let(:cert_path) { gdk_basepath.join('localhost.crt') }
let(:base_command) { described_class::BASE_COMMAND }
let(:proxy_host) { GDK.config.workhorse.__listen_address }
let(:base_command) { format(described_class::BASE_COMMAND, { ip: GDK.config.hostname, port: GDK.config.port, proxy_host: proxy_host, rules_config: GDK.config.gitlab_http_router.gitlab_rules_config }) }
let(:https_args) { "--local-protocol https --https-key-path #{key_path} --https-cert-path #{cert_path}" }
let(:topology_service_args) { format(described_class::TOPOLOGY_SERVICE_COMMAND, { port: GDK.config.gitlab_topology_service.rest_port }) }
let(:full_command) { "#{base_command}#{topology_service_args}" }
......@@ -36,6 +37,7 @@ RSpec.describe GDK::Services::GitlabHttpRouter do
context 'with absolute paths for SSL' do
let(:key_path) { Pathname.new('/gdk/localhost.key').expand_path }
let(:cert_path) { Pathname.new('/gdk/localhost.crt').expand_path }
let(:proxy_host) { GDK.config.nginx.__listen_address }
before do
config = {
......
......@@ -11,7 +11,10 @@ RSpec.describe Support::Rake::TaskWithTelemetry do
let(:telemetry) { false }
before do
allow(GDK::Telemetry).to receive(:telemetry_enabled?).and_return(telemetry)
allow(GDK::Telemetry).to receive_messages(
telemetry_enabled?: telemetry,
team_member?: true
)
end
it 'does not send telemetry' do
......@@ -29,12 +32,7 @@ RSpec.describe Support::Rake::TaskWithTelemetry do
it 'sends telemetry' do
task = new_task
expect(GDK::Telemetry).to receive(:send_telemetry).with(true, 'rake test-task', hash_including(
:duration,
environment: GDK::Telemetry.environment,
platform: GDK::Machine.platform,
architecture: GDK::Machine.architecture
))
expect(GDK::Telemetry).to receive(:send_telemetry).with(true, 'rake test-task', hash_including(:duration))
task.invoke
end
......@@ -45,12 +43,7 @@ RSpec.describe Support::Rake::TaskWithTelemetry do
raise StandardError
end
expect(GDK::Telemetry).to receive(:send_telemetry).with(false, 'rake test-task', hash_including(
:duration,
environment: GDK::Telemetry.environment,
platform: GDK::Machine.platform,
architecture: GDK::Machine.architecture
))
expect(GDK::Telemetry).to receive(:send_telemetry).with(false, 'rake test-task', hash_including(:duration))
expect { task.invoke }.to raise_error(StandardError)
end
......
......@@ -44,7 +44,8 @@ class SetupWorkspace
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
configure_gdk
success = GDK::Shellout.new('support/gitlab-remote-development/remote-development-gdk-bootstrap.sh', chdir: ROOT_DIR).execute
success = GDK::Shellout.new('support/gitlab-remote-development/remote-development-gdk-bootstrap.sh',
chdir: ROOT_DIR).execute
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
[success, duration]
......@@ -78,7 +79,7 @@ class SetupWorkspace
end
def send_telemetry(success, duration)
GDK::Telemetry.send_telemetry(success, 'setup-workspace', { duration: duration, environment: 'remote-development', platform: GDK::Machine.platform, architecture: GDK::Machine.architecture })
GDK::Telemetry.send_telemetry(success, 'setup-workspace', duration: duration)
GDK::Telemetry.flush_events
end
......
......@@ -76,14 +76,6 @@ else
@true
endif
.PHONY: gitlab-http-router/wrangler.gdk.toml
gitlab-http-router/wrangler.gdk.toml:
ifeq ($(gitlab_http_router_enabled),true)
$(Q)rake gitlab-http-router/wrangler.gdk.toml
else
@true
endif
.PHONY: gitlab/config/vite.gdk.json
gitlab/config/vite.gdk.json:
$(Q)rake gitlab/config/vite.gdk.json
......
......@@ -2,7 +2,7 @@ gitlab_http_router_dir = ${gitlab_development_root}/gitlab-http-router
.PHONY: gitlab-http-router-setup
ifeq ($(gitlab_http_router_enabled),true)
gitlab-http-router-setup: gitlab-http-router-setup-timed gitlab-http-router/wrangler.gdk.toml
gitlab-http-router-setup: gitlab-http-router-setup-timed
else
gitlab-http-router-setup:
@true
......@@ -12,11 +12,10 @@ endif
gitlab-http-router-setup-run: gitlab-http-router/.git gitlab-http-router-common-setup
gitlab-http-router/.git:
$(Q)rm -fr gitlab_http_router/wrangler.gdk.toml
$(Q)support/component-git-clone ${git_params} ${gitlab_http_router_repo} gitlab-http-router
.PHONY: gitlab-http-router-common-setup
gitlab-http-router-common-setup: touch-examples gitlab-http-router/wrangler.gdk.toml gitlab-http-router-npm-install
gitlab-http-router-common-setup: touch-examples gitlab-http-router-npm-install
.PHONY: gitlab-http-router-npm-install
gitlab-http-router-npm-install: gitlab-http-router-asdf-install
......@@ -64,7 +63,7 @@ ensure-gitlab-http-router-stopped:
$(Q)gdk stop gitlab-http-router
.PHONY: gitlab-http-router-update-run
gitlab-http-router-update-run: ensure-gitlab-http-router-stopped gitlab-http-router/.git/pull gitlab-http-router-common-setup gitlab-http-router/wrangler.gdk.toml
gitlab-http-router-update-run: ensure-gitlab-http-router-stopped gitlab-http-router/.git/pull gitlab-http-router-common-setup
$(Q)gdk restart gitlab-http-router
.PHONY: gitlab-http-router/.git/pull
......
name = "http-router"
main = "src/index.ts"
compatibility_date = "2024-12-05"
compatibility_flags = ["nodejs_compat"]
workers_dev = false
send_metrics = false
vars = { }
[dev]
ip = "<%= config.hostname %>"
port = <%= config.gitlab_http_router.use_distinct_port? ? config.gitlab_http_router.port : config.port %>
[env.dev]
name = "dev-cells-http-router"
vars = { GITLAB_PROXY_HOST = "<%= config.nginx? ? config.nginx.__listen_address : config.workhorse.__listen_address %>", GITLAB_RULES_CONFIG = "<%= config.gitlab_http_router.gitlab_rules_config %>" }
[env.pre]
name = "pre-gitlab-com-cells-http-router"
vars = { GITLAB_PROXY_HOST = "", GITLAB_RULES_CONFIG = "session_prefix" }
<%- if config.gitlab.topology_service.enabled -%>
[[cells]]
id = <%= config.gitlab.cell.id %>
name = "<%= config.gitlab.cell.name %>"
address = "<%= config.nginx? ? config.nginx.__listen_address : config.workhorse.__listen_address %>"
session_prefix = "<%= config.gitlab.rails.session_store.session_cookie_token_prefix %>"
sequence_range = [1, <%= config.cells.global_sequence_range %>]
......@@ -12,7 +11,6 @@ sequence_range = [1, <%= config.cells.global_sequence_range %>]
<%- cell_config = cell_manager.get_config_for(instance.fetch('name')) -%>
[[cells]]
id = <%= instance.id %>
name = "<%= instance.name %>"
address = "<%= cell_config.nginx? ? cell_config.nginx.__listen_address : cell_config.workhorse.__listen_address %>"
session_prefix = "<%= cell_config.gitlab.rails.session_store.session_cookie_token_prefix %>"
sequence_range = [<%= instance.sequence_range[0] %>, <%= instance.sequence_range[1] %>]
......
......@@ -852,7 +852,6 @@ production: &base
cell:
id: <%= config.gitlab.cell.id %>
name: <%= config.gitlab.cell.name %>
skip_sequence_alteration: <%= config.gitlab.cell.skip_sequence_alteration %>
<%- end -%>
......
......@@ -13,7 +13,9 @@ http {
access_log logs/access.log;
<%- if config.nginx.sendfile? -%>
sendfile on;
<%- end -%>
#tcp_nopush on;
#keepalive_timeout 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment