From 79fd1b7fbbc6e7fcc92c143e775a3490adde187d Mon Sep 17 00:00:00 2001 From: f Date: Fri, 21 Apr 2023 15:24:40 -0300 Subject: [PATCH 1/9] BREAKING CHANGE: usar rsyncd en lugar de ssh #13171 --- app/services/site_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 5d28bf91..d9c7783e 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -215,7 +215,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do # Crea los deploys necesarios para sincronizar a otros nodos de Sutty def sync_nodes Rails.application.nodes.each do |node| - site.deploys.build(type: 'DeployFullRsync', destination: "sutty@#{node}:") + site.deploys.build(type: 'DeployFullRsync', destination: "rsync://#{node}/deploys/") end end From a6bba8c3cbb84051fd709fb45be3eb6ae7e3ce14 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 21 Apr 2023 15:42:16 -0300 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20cambiar=20las=20direcciones=20de=20s?= =?UTF-8?q?incronizaci=C3=B3n=20a=20rsyncd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...421182627_change_full_rsync_destination.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/migrate/20230421182627_change_full_rsync_destination.rb diff --git a/db/migrate/20230421182627_change_full_rsync_destination.rb b/db/migrate/20230421182627_change_full_rsync_destination.rb new file mode 100644 index 00000000..47352139 --- /dev/null +++ b/db/migrate/20230421182627_change_full_rsync_destination.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +# Envía los cambios a través de rsyncd +class ChangeFullRsyncDestination < ActiveRecord::Migration[6.1] + def up + DeployFullRsync.find_each do |deploy| + Rails.application.nodes.each do |node| + deploy.destination = "rsync://#{node}/deploys/" + deploy.save + end + end + end + + def down + DeployFullRsync.find_each do |deploy| + Rails.application.nodes.each do |node| + deploy.destination = "sutty@#{node}:" + deploy.save + end + end + end +end From 79398d0448bd707906c2a15e719fc76acb72db98 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 21 Apr 2023 15:44:22 -0300 Subject: [PATCH 3/9] =?UTF-8?q?fixup!=20fix:=20cambiar=20las=20direcciones?= =?UTF-8?q?=20de=20sincronizaci=C3=B3n=20a=20rsyncd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20230421182627_change_full_rsync_destination.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20230421182627_change_full_rsync_destination.rb b/db/migrate/20230421182627_change_full_rsync_destination.rb index 47352139..3a22aea6 100644 --- a/db/migrate/20230421182627_change_full_rsync_destination.rb +++ b/db/migrate/20230421182627_change_full_rsync_destination.rb @@ -5,7 +5,7 @@ class ChangeFullRsyncDestination < ActiveRecord::Migration[6.1] def up DeployFullRsync.find_each do |deploy| Rails.application.nodes.each do |node| - deploy.destination = "rsync://#{node}/deploys/" + deploy.destination = "rsync://rsyncd.#{node}/deploys/" deploy.save end end From 4f74c6f6cad3e62d2841e3811e9f31add3f8b566 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 21 Apr 2023 15:48:09 -0300 Subject: [PATCH 4/9] fix: no configurar ssh para rsyncd --- app/models/deploy_rsync.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/deploy_rsync.rb b/app/models/deploy_rsync.rb index 1dff2d99..fcc5a65d 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -38,6 +38,7 @@ class DeployRsync < Deploy # # @return [Boolean] def ssh? + return true if destination.start_with? 'rsync://' user, host = user_host ssh_available = false From f1e53c04db1a59d8f15f46e6d839eb21d586d946 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 22 Apr 2023 18:18:30 -0300 Subject: [PATCH 5/9] fix: ir al contenedor de rsyncd --- app/services/site_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index d9c7783e..5a2b7dde 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -215,7 +215,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do # Crea los deploys necesarios para sincronizar a otros nodos de Sutty def sync_nodes Rails.application.nodes.each do |node| - site.deploys.build(type: 'DeployFullRsync', destination: "rsync://#{node}/deploys/") + site.deploys.build(type: 'DeployFullRsync', destination: "rsync://rsyncd.#{node}/deploys/") end end From b78dd1661ad1a98be8fdbd535a157d6d16a61eb5 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 24 Apr 2023 14:41:45 -0300 Subject: [PATCH 6/9] fix: guardar el hostname --- app/services/site_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 5a2b7dde..696acd57 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -215,7 +215,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do # Crea los deploys necesarios para sincronizar a otros nodos de Sutty def sync_nodes Rails.application.nodes.each do |node| - site.deploys.build(type: 'DeployFullRsync', destination: "rsync://rsyncd.#{node}/deploys/") + site.deploys.build(type: 'DeployFullRsync', destination: "rsync://rsyncd.#{node}/deploys/", hostname: node) end end From 3a99e1a8677e3a3ec13212394eac6d7418846efe Mon Sep 17 00:00:00 2001 From: f Date: Mon, 24 Apr 2023 14:42:02 -0300 Subject: [PATCH 7/9] fix: usar el hostname como url --- app/models/deploy_full_rsync.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/models/deploy_full_rsync.rb b/app/models/deploy_full_rsync.rb index b8c48eab..b417470a 100644 --- a/app/models/deploy_full_rsync.rb +++ b/app/models/deploy_full_rsync.rb @@ -27,8 +27,4 @@ class DeployFullRsync < DeployRsync result.present? && result.all? end - - def url - "https://#{user_host.last}/" - end end From 47969cc410c42fe912e5cd0634db54b0f58b26b7 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 24 Apr 2023 14:46:56 -0300 Subject: [PATCH 8/9] fix: no sincronizar los sitios de testeo --- app/services/site_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/site_service.rb b/app/services/site_service.rb index 696acd57..2c29538c 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -15,7 +15,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do add_role temporal: false, rol: 'usuarie' site.deploys.build type: 'DeployLocal' - sync_nodes + # Los sitios de testing no se sincronizan + sync_nodes unless site.name.end_with? '.testing' I18n.with_locale(usuarie.lang.to_sym || I18n.default_locale) do # No se puede llamar a site.config antes de save porque el sitio From 61bc23babec3e4b6ec4f265eccada5e8bd77a4a6 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 24 Apr 2023 14:55:46 -0300 Subject: [PATCH 9/9] feat: agregar nodo en los logs --- db/migrate/20230424174544_add_node_to_access_logs.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20230424174544_add_node_to_access_logs.rb diff --git a/db/migrate/20230424174544_add_node_to_access_logs.rb b/db/migrate/20230424174544_add_node_to_access_logs.rb new file mode 100644 index 00000000..805fbc27 --- /dev/null +++ b/db/migrate/20230424174544_add_node_to_access_logs.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# Agrega la columna de nodo a los logs +class AddNodeToAccessLogs < ActiveRecord::Migration[6.1] + def change + add_column :access_logs, :node, :string, index: true + end +end