From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB8B914884C for ; Mon, 8 Apr 2024 22:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712615119; cv=none; b=G+5uCsTzv+domAVvrbYzdKQG80bOtDg9KsY26biY2zj5GZb9zZ3xqch1DmMGdkzWQ7KmOoJjLggIvlP5lUjDsdkwgnhoeYAwTVOFbmBKPC5AkNNVfF3570rZZSdyQazWDu+8URIWRg5zqKZIiwcubCVrCeyBVRQa8dEf0+VRKlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712615119; c=relaxed/simple; bh=N9GrAd3LHO8ik4OwjqBKD8IACVHgnjOnzEdghpakHoI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MMn13K0dKy3a9k4bk0PX+NbtBWOAkdXr4XVt+AEEf77RJ8EaHtiK4mKBVf5yIxPbhCtLb6Lo4UJxTszFrx1hVnEe2tjdqk9IiYNnn4F4CF1bTSKuNTeQJDl6pxvEiIbJfz3+ro6H002Uv7YnOAPkW/ju41ocxXcGCH91bxS67Nc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=lgNw25tT; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lgNw25tT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=HKBJ8Ea7fNvGeVca0kr+fEAn+1L5Cy6fr+f7uDbNNl8=; b=lgNw25tTj8Pc/kkm+I5dRWAV2D u9JbydIBUmjgwOM9MxR7QV/Dfsg6nPRigU2uX3rGQn9SPsSsCqfWgUWLMn1im27mVkX6hauZ6vGBm W7Bgcx4faH+QIk2BpFrrUbz5It8/a34iwAgMyyht462jl6A23wPPwPoATmYLsaSGFumTmsEPZ0la+ GNmR38ec/FkaVKZuXxAqLty0OJlwBBP1RetqcVO9zCVYjAFRk2ioXhdx5MXzIEIHeFCeZ2BDJXOa0 KLtHFdzQ50vyJTXF9ecLo7T8yLYYdLJ5W5xlQbK8pI+l9XaQc4osnWRjWwND8GL8cUZKdryx2lPr0 92DIktRg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtxQS-0000000H114-1Mzm; Mon, 08 Apr 2024 22:25:16 +0000 From: Luis Chamberlain To: kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH] devconfig: fix setting node timezone Date: Mon, 8 Apr 2024 15:25:15 -0700 Message-ID: <20240408222515.4055475-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain It turns out that just relying on the clock offset being set won't ensure we have the right time set on the nodes, so when timectl is enabled for NTP, we still need to set the timezone on the nodes based on the hypervisor to be very sure we get the right time. Below is an example where the clock offset XML settings were set on guests with guestfs and yet the timezone on the nodes was set to Eastern. To fix this we must keep a kconfig option which matches the hypervisor, and use that value on the nodes to set the timezone. mcgrof@some-hypervisor-01 /xfs1/base/kdevops (git::main)$ grep "clock offset" guestfs/base-xfs-nocrc/base-xfs-nocrc.xml mcgrof@some-hypervisor-01 /xfs1/base/kdevops (git::main)$ ssh base-xfs-reflink timedatectl Local time: Mon 2024-04-08 17:32:38 EDT Universal time: Mon 2024-04-08 21:32:38 UTC RTC time: Mon 2024-04-08 21:32:38 Time zone: US/Eastern (EDT, -0400) System clock synchronized: yes NTP service: active RTC in local TZ: no mcgrof@some-hypervisor-01 /xfs1/base/kdevops (git::main)$ timedatectl Local time: Mon 2024-04-08 21:32:42 UTC Universal time: Mon 2024-04-08 21:32:42 UTC RTC time: Mon 2024-04-08 21:32:42 Time zone: UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no Fixes: de233a386941 ("devconfig: Remove DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_TIMEZONE" Signed-off-by: Luis Chamberlain --- Makefile.min_deps | 1 + kconfigs/Kconfig.ansible_provisioning | 4 ++++ playbooks/roles/devconfig/defaults/main.yml | 1 + playbooks/roles/devconfig/tasks/main.yml | 9 +++++++++ scripts/systemd-timesync.Makefile | 1 + 5 files changed, 16 insertions(+) diff --git a/Makefile.min_deps b/Makefile.min_deps index 9d8f205799c4..ce0a82595074 100644 --- a/Makefile.min_deps +++ b/Makefile.min_deps @@ -10,6 +10,7 @@ BINARY_DEPS += sudo BINARY_DEPS += make BINARY_DEPS += nc BINARY_DEPS += ansible-playbook +BINARY_DEPS += timedatectl BINARY_DEPS_VCHECKS := $(subst $(TOPDIR)/,,$(wildcard $(TOPDIR)/scripts/version_check/*)) diff --git a/kconfigs/Kconfig.ansible_provisioning b/kconfigs/Kconfig.ansible_provisioning index 82a6f822c3f5..347992e24ab2 100644 --- a/kconfigs/Kconfig.ansible_provisioning +++ b/kconfigs/Kconfig.ansible_provisioning @@ -217,6 +217,10 @@ config DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD if DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD +config DEVCONFIG_SYSTEMD_TIMESYNCD_TIMEZONE + string + default $(shell, timedatectl show -p Timezone --value) + config DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_NTP bool "Enable systemd-timesyncd NTP" default y diff --git a/playbooks/roles/devconfig/defaults/main.yml b/playbooks/roles/devconfig/defaults/main.yml index b48b4cce8e00..3fe2605c87e8 100644 --- a/playbooks/roles/devconfig/defaults/main.yml +++ b/playbooks/roles/devconfig/defaults/main.yml @@ -50,6 +50,7 @@ devconfig_systemd_journal_remote_url: "http://192.168.124.1" devconfig_systemd_journal_remote_path: "/var/log/journal/remote/" devconfig_enable_systemd_timesyncd: False +devconfig_systemd_timesyncd_timezone: "UTC" devconfig_enable_systemd_timesyncd_ntp: False devconfig_enable_systemd_timesyncd_ntp_google: False devconfig_enable_systemd_timesyncd_ntp_debian: False diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml index fec6ea3b5939..a76106b2a997 100644 --- a/playbooks/roles/devconfig/tasks/main.yml +++ b/playbooks/roles/devconfig/tasks/main.yml @@ -526,6 +526,15 @@ when: - devconfig_enable_systemd_timesyncd_ntp|bool +- name: Override timezone on nodes + tags: [ 'timesyncd' ] + become: yes + become_flags: 'su - -c' + become_method: sudo + command: "timedatectl set-timezone {{ devconfig_systemd_timesyncd_timezone }}" + when: + - devconfig_enable_systemd_timesyncd_ntp|bool + - name: Restart systemd-timesyncd.service on the client become: yes become_flags: 'su - -c' diff --git a/scripts/systemd-timesync.Makefile b/scripts/systemd-timesync.Makefile index 11950cd9e598..d11d135113d8 100644 --- a/scripts/systemd-timesync.Makefile +++ b/scripts/systemd-timesync.Makefile @@ -2,6 +2,7 @@ ifeq (y,$(CONFIG_DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD)) ANSIBLE_EXTRA_ARGS += devconfig_enable_systemd_timesyncd='True' +ANSIBLE_EXTRA_ARGS_DIRECT += devconfig_systemd_timesyncd_timezone='$(subst ",,$(CONFIG_DEVCONFIG_SYSTEMD_TIMESYNCD_TIMEZONE))' ifeq (y,$(CONFIG_DEVCONFIG_ENABLE_SYSTEMD_TIMESYNCD_NTP)) ANSIBLE_EXTRA_ARGS += devconfig_enable_systemd_timesyncd_ntp='True' -- 2.43.0