From b866783989d7df5e4a3e5dc91d3d23754811db56 Mon Sep 17 00:00:00 2001 From: Alexandre MERLIN <alexandre.merlin@inria.fr> Date: Thu, 10 Apr 2025 09:28:47 +0200 Subject: [PATCH] Attempt to fix message and default value for dont_trust conf --- lib/kadeploy3/common/environment.rb | 2 +- lib/kadeploy3/server/stepdeploy.rb | 2 +- lib/kadeploy3/server/workflow.rb | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/kadeploy3/common/environment.rb b/lib/kadeploy3/common/environment.rb index e7d5b6e5..6d8ec6aa 100644 --- a/lib/kadeploy3/common/environment.rb +++ b/lib/kadeploy3/common/environment.rb @@ -336,7 +336,7 @@ class Environment ) end @options['kexec'] = cp.value('kexec', [TrueClass, FalseClass], true) - @options['trust_env'] = cp.value('trust_previous_env', [TrueClass, FalseClass, nil], nil) + @options['trust_env'] = cp.value('trust_previous_env', String, 'default', ['default','always','never']) end end diff --git a/lib/kadeploy3/server/stepdeploy.rb b/lib/kadeploy3/server/stepdeploy.rb index baebb8e1..173f0805 100644 --- a/lib/kadeploy3/server/stepdeploy.rb +++ b/lib/kadeploy3/server/stepdeploy.rb @@ -242,7 +242,7 @@ module Macrostep end class DeployBootNewEnvClassical < DeployBootNewEnv - DESC = "Reboot to the deployed environment without kexec. Used when a cluster does not support kexec." + DESC = "Reboot to the deployed environment without kexec." def steps() [ [:switch_pxe, "deploy_to_deployed_env"], diff --git a/lib/kadeploy3/server/workflow.rb b/lib/kadeploy3/server/workflow.rb index 049553d2..1915b7b2 100644 --- a/lib/kadeploy3/server/workflow.rb +++ b/lib/kadeploy3/server/workflow.rb @@ -431,7 +431,7 @@ module Workflow end def last_deploy_is_trusted?() - return true if context[:execution].always_trust_env || context[:execution].environment.options['trust_env'] + return true if context[:execution].always_trust_env || context[:execution].environment.options['trust_env'] == 'always' nodes_state_before_start = Nodes::get_states(context[:database], @nodes.set.map(&:hostname)) @nodes.set.all? do |n| node_state = nodes_state_before_start[n.hostname] || {} @@ -474,13 +474,13 @@ module Workflow end # SetDeploymentMiniOS step macrosteps[0].to_a.each do |instance| - if (context[:execution].dont_trust_env || context[:execution].environment.options['trust_env'] == false || !last_deploy_is_trusted?) && instance[0] == 'SetDeploymentMiniOSTrusted' + if (context[:execution].dont_trust_env || context[:execution].environment.options['trust_env'] == 'never' || !last_deploy_is_trusted?) && instance[0] == 'SetDeploymentMiniOSTrusted' instance[0] = 'SetDeploymentMiniOSUntrusted' instance[1] = 0 instance[2] = eval("(#{context[:cluster].timeout_reboot_classical})+200").to_i debug_message_reason = if context[:execution].dont_trust_env "trusting the last deployment is disabled for this deployment" - elsif context[:execution].environment.options['trust_env'] == false + elsif context[:execution].environment.options['trust_env'] == 'never' "trusting the last deployment is disabled for this environment" elsif !last_deploy_is_trusted? "the last deployment is not trusted" @@ -519,10 +519,15 @@ module Workflow instance, "Using classical reboot instead of kexec since the filesystem is not supported by the deployment environment (#{macrosteps[2].name})" ) - elsif context[:execution].disable_kexec || context[:execution].environment.options['kexec'] == false + elsif context[:execution].disable_kexec setclassical.call( instance, - "Using classical reboot instead of kexec (#{macrosteps[2].name})" + "Using classical reboot instead of kexec as requested by the deployment (#{macrosteps[2].name})" + ) + elsif context[:execution].environment.options['kexec'] == false + setclassical.call( + instance, + "Using classical reboot instead of kexec as requested by the environment description (#{macrosteps[2].name})" ) end -- GitLab