From f2e79a733d26f1cf578d1f49f995aea14376a246 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Mar 2023 17:33:52 -0300 Subject: [PATCH 1/9] fix: no fallar si hay errores remotos closes #10467 closes #10506 closes #10509 --- app/models/deploy_distributed_press.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 41054b99..09410201 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -118,7 +118,9 @@ class DeployDistributedPress < Deploy self.remote_info['njalla']['a'] = njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h end - + rescue DistributedPress::V1::Error, HTTParty::Error => e + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + ensure nil end From 0c674d6ca12fc0f98645a922e18efd13de85cd09 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Mar 2023 17:37:48 -0300 Subject: [PATCH 2/9] fix: crear el sitio remoto si no se pudo crear antes --- app/models/deploy_distributed_press.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 09410201..bd80dca4 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -27,6 +27,11 @@ class DeployDistributedPress < Deploy time_start + if remote_site_id.blank? || remote_info['njalla'].blank? + create_remote_site! + save + end + site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| until io.eof? From 698b3a0bf6bbbaf6b84a8c0c961de081e2c1989b Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Mar 2023 17:39:41 -0300 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20separar=20la=20creaci=C3=B3n=20de?= =?UTF-8?q?=20DP=20de=20njalla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/deploy_distributed_press.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index bd80dca4..9afc6a5d 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -15,7 +15,7 @@ require 'njalla/v1' class DeployDistributedPress < Deploy store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON - before_create :create_remote_site! + before_create :create_remote_site!, :create_njalla_records! # Actualiza la información y luego envía los cambios # @@ -27,10 +27,9 @@ class DeployDistributedPress < Deploy time_start - if remote_site_id.blank? || remote_info['njalla'].blank? - create_remote_site! - save - end + create_remote_site! if remote_site_id.blank? + create_njalla_records! if remote_info['njalla'].blank? + save site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| @@ -115,7 +114,16 @@ class DeployDistributedPress < Deploy self.remote_site_id = created_site[:id] self.remote_info = created_site.to_h + rescue DistributedPress::V1::Error + ExceptionNotifier.notify_exception(e, data: { site: site.name }) + ensure + nil + end + # Crea los registros en Njalla + # + # @return [nil] + def create_njalla_records! # XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay # que eliminarlo. unless site.name.end_with? '.' @@ -123,7 +131,7 @@ class DeployDistributedPress < Deploy self.remote_info['njalla']['a'] = njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h self.remote_info['njalla']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h end - rescue DistributedPress::V1::Error, HTTParty::Error => e + rescue HTTParty::Error => e ExceptionNotifier.notify_exception(e, data: { site: site.name }) ensure nil From b297800933ae0556845f1e710ce181a6d4e158cb Mon Sep 17 00:00:00 2001 From: f Date: Fri, 17 Mar 2023 17:44:13 -0300 Subject: [PATCH 4/9] fix: volver a fallar si al hacer deploy todavia estan caidos los servicios --- app/models/deploy_distributed_press.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 9afc6a5d..e8d8b095 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -31,6 +31,10 @@ class DeployDistributedPress < Deploy create_njalla_records! if remote_info['njalla'].blank? save + if remote_site_id.blank? || remote_info['njalla'].blank? + raise DeployJob::DeployException, '' + end + site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| until io.eof? @@ -133,6 +137,7 @@ class DeployDistributedPress < Deploy end rescue HTTParty::Error => e ExceptionNotifier.notify_exception(e, data: { site: site.name }) + self.remote_info['njalla'] = nil ensure nil end From 729284953d66b47aca891f8aaf89a9d724ea0643 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Mar 2023 16:40:17 -0300 Subject: [PATCH 5/9] fix: agregar dependencias a distributed press --- app/models/deploy_distributed_press.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index e8d8b095..7f663a0b 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -17,6 +17,8 @@ class DeployDistributedPress < Deploy before_create :create_remote_site!, :create_njalla_records! + DEPENDENCIES = %i[deploy_local] + # Actualiza la información y luego envía los cambios # # @param :output [Bool] From 7359d4f6c197c304c915afdaf5859f6977c8b5e7 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Mar 2023 16:41:32 -0300 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20todav=C3=ADa=20no=20hay=20interfaz?= =?UTF-8?q?=20para=20estos=20deploys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/deploys/_deploy_full_rsync.haml | 1 + app/views/deploys/_deploy_localized_domain.haml | 1 + 2 files changed, 2 insertions(+) create mode 100644 app/views/deploys/_deploy_full_rsync.haml create mode 100644 app/views/deploys/_deploy_localized_domain.haml diff --git a/app/views/deploys/_deploy_full_rsync.haml b/app/views/deploys/_deploy_full_rsync.haml new file mode 100644 index 00000000..0aab9802 --- /dev/null +++ b/app/views/deploys/_deploy_full_rsync.haml @@ -0,0 +1 @@ +-# nada diff --git a/app/views/deploys/_deploy_localized_domain.haml b/app/views/deploys/_deploy_localized_domain.haml new file mode 100644 index 00000000..0aab9802 --- /dev/null +++ b/app/views/deploys/_deploy_localized_domain.haml @@ -0,0 +1 @@ +-# nada From d109eb76dbcc26d143e81344a736e0a1658a9ab4 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Mar 2023 16:48:32 -0300 Subject: [PATCH 7/9] feat: darle url a deploy rsync --- app/models/deploy_rsync.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/deploy_rsync.rb b/app/models/deploy_rsync.rb index 6a96a274..ac9f19ec 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -3,7 +3,7 @@ # Sincroniza sitios a servidores remotos usando Rsync. El servidor # remoto tiene que tener rsync instalado. class DeployRsync < Deploy - store :values, accessors: %i[destination host_keys], coder: JSON + store :values, accessors: %i[hostname destination host_keys], coder: JSON DEPENDENCIES = %i[deploy_local] @@ -25,6 +25,11 @@ class DeployRsync < Deploy end end + # @return [String] + def url + "https://#{hostname}/" + end + private # Verificar la conexión SSH implementando Trust On First Use From 0e70aed88cc61b09fd49d162e07574edb68ac2f0 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Mar 2023 16:52:36 -0300 Subject: [PATCH 8/9] feat: darle url a full rsync --- app/models/deploy_full_rsync.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/deploy_full_rsync.rb b/app/models/deploy_full_rsync.rb index c0ff84c6..8f1d306e 100644 --- a/app/models/deploy_full_rsync.rb +++ b/app/models/deploy_full_rsync.rb @@ -19,4 +19,8 @@ class DeployFullRsync < DeployRsync end end.flatten.all? end + + def url + "https://#{user_host.last}/" + end end From fcb68b683da41921d6c3fd41bbcdcb125b9d0138 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Mar 2023 16:53:56 -0300 Subject: [PATCH 9/9] fix: traducir metodos de publicacion #10030 --- config/locales/en.yml | 8 ++++++++ config/locales/es.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/config/locales/en.yml b/config/locales/en.yml index 15ed8a78..43b80983 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,10 +105,18 @@ en: title: Alternative domain name success: Success! error: Error + deploy_localized_domain: + title: Localized domain + success: Success! + error: Error deploy_rsync: title: Synchronize to backup server success: Success! error: Error + deploy_full_rsync: + title: Synchronize to another Sutty node + success: Success! + error: Error deploy_distributed_press: title: Distributed Web success: Success! diff --git a/config/locales/es.yml b/config/locales/es.yml index a190b143..a6201bce 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -105,10 +105,18 @@ es: title: Dominio alternativo success: ¡Éxito! error: Hubo un error + deploy_localized_domain: + title: Dominio por idioma + success: ¡Éxito! + error: Hubo un error deploy_rsync: title: Sincronizar al servidor alternativo success: ¡Éxito! error: Hubo un error + deploy_full_rsync: + title: Sincronizar a otro nodo de Sutty + success: ¡Éxito! + error: Hubo un error deploy_distributed_press: title: Web distribuida success: ¡Éxito!