From ea7bb8e4254f10fff6e94937ad0e1d5e9a3f4efc Mon Sep 17 00:00:00 2001 From: Marek Czernek Date: Wed, 3 Jul 2024 14:02:07 +0200 Subject: [PATCH 1/2] Make inter-server-sync to export/import dates in UTC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pablo Suárez Hernández --- python/spacewalk/common/suseLib.py | 2 +- .../satellite_tools/diskImportLib.py | 1 + .../satellite_tools/disk_dumper/dumper.py | 34 +++++++++---------- .../satellite_tools/disk_dumper/iss.py | 12 +++---- .../satellite_tools/exporter/exportLib.py | 16 ++++----- python/spacewalk/satellite_tools/satsync.py | 16 ++++++--- python/spacewalk/satellite_tools/xmlSource.py | 4 +-- .../server/importlib/backendOracle.py | 8 +++++ python/spacewalk/server/repomd/mapper.py | 6 ++-- python/spacewalk/server/rhnChannel.py | 24 ++++++------- ...wip-inter-server-sync-in-with-dates-in-utc | 1 + python/uyuni/common/rhnLib.py | 3 +- ...wip-inter-server-sync-in-with-dates-in-utc | 1 + 13 files changed, 74 insertions(+), 54 deletions(-) create mode 100644 python/spacewalk/spacewalk-backend.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc create mode 100644 python/uyuni/uyuni-common-libs.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc diff --git a/python/spacewalk/common/suseLib.py b/python/spacewalk/common/suseLib.py index 95f76f133c42..fef1b05fb9ec 100644 --- a/python/spacewalk/common/suseLib.py +++ b/python/spacewalk/common/suseLib.py @@ -473,7 +473,7 @@ def channelForProduct(product, parent_id=None, org_id=None, user_id=None): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, -- If user_id is null, then the channel is subscribable rhn_channel.loose_user_role_check(c.id, :user_id, 'subscribe') subscribable FROM rhnChannel c diff --git a/python/spacewalk/satellite_tools/diskImportLib.py b/python/spacewalk/satellite_tools/diskImportLib.py index 05d72646384d..6f220c45d228 100644 --- a/python/spacewalk/satellite_tools/diskImportLib.py +++ b/python/spacewalk/satellite_tools/diskImportLib.py @@ -41,6 +41,7 @@ def get_backend(self): return self.__backend Backend.__backend = SQLBackend() + Backend.__backend.setSessionTimeZoneToUTC() return Backend.__backend diff --git a/python/spacewalk/satellite_tools/disk_dumper/dumper.py b/python/spacewalk/satellite_tools/disk_dumper/dumper.py index 7d96194b307e..ed8eefe87b75 100644 --- a/python/spacewalk/satellite_tools/disk_dumper/dumper.py +++ b/python/spacewalk/satellite_tools/disk_dumper/dumper.py @@ -123,7 +123,7 @@ def get_channels_statement(self): """ select c.id channel_id, c.label, ct.label as checksum_type, - TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c left outer join rhnChecksumType ct on c.checksum_type_id = ct.id, rhnChannelFamilyMembers cfm, (%s @@ -140,7 +140,7 @@ def get_packages_statement(self): # pylint: disable-next=consider-using-f-string """ select p.id package_id, - TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(p.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelPackage cp, rhnPackage p, rhnChannelFamilyMembers cfm, (%s @@ -159,7 +159,7 @@ def get_source_packages_statement(self): # pylint: disable-next=consider-using-f-string """ select ps.id package_id, - TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(ps.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelPackage cp, rhnPackage p, rhnPackageSource ps, rhnChannelFamilyMembers cfm, (%s @@ -181,7 +181,7 @@ def get_errata_statement(self): # pylint: disable-next=consider-using-f-string """ select e.id errata_id, - TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(e.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelErrata ce, rhnErrata e, rhnChannelFamilyMembers cfm, (%s @@ -402,7 +402,7 @@ def dump_channel_packages_short( _query_get_channel_packages = rhnSQL.Statement( """ select cp.package_id, - TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(p.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelPackage cp, rhnPackage p where cp.channel_id = :channel_id @@ -613,7 +613,7 @@ def _validate_channels(self, channel_labels=None): _query_validate_kickstarts = rhnSQL.Statement( """ select kt.label kickstart_label, - TO_CHAR(kt.modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(kt.modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnKickstartableTree kt where kt.channel_id = :channel_id and kt.org_id is null @@ -900,7 +900,7 @@ class ChannelsDumper(exportLib.ChannelsDumper): c.label, ca.label channel_arch, c.basedir, c.name, c.summary, c.description, c.gpg_key_url, c.update_tag, c.installer_updates, ct.label checksum_type, - TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, pc.label parent_channel, c.channel_access from rhnChannel c left outer join rhnChannel pc on c.parent_channel = pc.id left outer join rhnChecksumType ct on c.checksum_type_id = ct.id, rhnChannelArch ca @@ -953,7 +953,7 @@ class ChannelsDumperEx(CachedDumper, exportLib.ChannelsDumper): """ select c.id, c.label, ca.label channel_arch, c.basedir, c.name, c.summary, c.description, c.gpg_key_url, c.installer_updates, c.update_tag, c.org_id, - TO_CHAR(c.last_modified, 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, c.channel_product_id, pc.label parent_channel, cp.product channel_product, @@ -992,7 +992,7 @@ class ShortPackagesDumper(CachedDumper, exportLib.ShortPackagesDumper): c.checksum_type, c.checksum, p.package_size, - TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') as last_modified + TO_CHAR(p.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as last_modified from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe, rhnPackageArch pa, rhnChecksumView c where p.id = :package_id @@ -1027,7 +1027,7 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper): p.payload_size, p.installed_size, p.build_host, - TO_CHAR(p.build_time, 'YYYYMMDDHH24MISS') as build_time, + TO_CHAR(p.build_time at time zone 'UTC', 'YYYYMMDDHH24MISS') as build_time, sr.name as source_rpm, c.checksum_type, c.checksum, @@ -1039,7 +1039,7 @@ class PackagesDumper(CachedDumper, exportLib.PackagesDumper): p.header_end, p.copyright, p.cookie, - TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') as last_modified + TO_CHAR(p.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as last_modified from rhnPackage p, rhnPackageName pn, rhnPackageEVR pe, rhnPackageArch pa, rhnPackageGroup pg, rhnSourceRPM sr, rhnChecksumView c @@ -1068,7 +1068,7 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper): ps.rpm_version, ps.payload_size, ps.build_host, - TO_CHAR(ps.build_time, 'YYYYMMDDHH24MISS') build_time, + TO_CHAR(ps.build_time at time zone 'UTC', 'YYYYMMDDHH24MISS') build_time, sig.checksum sigchecksum, sig.checksum_type sigchecksum_type, ps.vendor, @@ -1076,7 +1076,7 @@ class SourcePackagesDumper(CachedDumper, exportLib.SourcePackagesDumper): ps.package_size, c.checksum_type, c.checksum, - TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(ps.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnPackageSource ps, rhnPackageGroup pg, rhnSourceRPM sr, rhnChecksumView c, rhnChecksumView sig where ps.id = :package_id @@ -1108,9 +1108,9 @@ class ErrataDumper(exportLib.ErrataDumper): e.synopsis, e.topic, e.solution, - TO_CHAR(e.issue_date, 'YYYYMMDDHH24MISS') issue_date, - TO_CHAR(e.update_date, 'YYYYMMDDHH24MISS') update_date, - TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(e.issue_date at time zone 'UTC', 'YYYYMMDDHH24MISS') issue_date, + TO_CHAR(e.update_date at time zone 'UTC', 'YYYYMMDDHH24MISS') update_date, + TO_CHAR(e.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, e.refers_to, e.notes, e.errata_from, @@ -1139,7 +1139,7 @@ class KickstartableTreesDumper(CachedDumper, exportLib.KickstartableTreesDumper) ktt.label "kstree-type-label", kit.name "install-type-name", kit.label "install-type-label", - TO_CHAR(kt.last_modified, 'YYYYMMDDHH24MISS') "last-modified" + TO_CHAR(kt.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') "last-modified" from rhnKickstartableTree kt, rhnKSTreeType ktt, rhnKSInstallType kit, diff --git a/python/spacewalk/satellite_tools/disk_dumper/iss.py b/python/spacewalk/satellite_tools/disk_dumper/iss.py index 08789cfb4313..6069771e48e5 100644 --- a/python/spacewalk/satellite_tools/disk_dumper/iss.py +++ b/python/spacewalk/satellite_tools/disk_dumper/iss.py @@ -312,7 +312,7 @@ def __init__( try: query = """ select ch.id channel_id, label, - TO_CHAR(last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel ch where ch.label = :label """ @@ -481,7 +481,7 @@ def __init__( if self.whole_errata and self.start_date: query = """ select rp.id package_id, - TO_CHAR(rp.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(rp.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelPackage rcp, rhnPackage rp left join rhnErrataPackage rep on rp.id = rep.package_id left join rhnErrata re on rep.errata_id = re.id @@ -491,7 +491,7 @@ def __init__( else: query = """ select rp.id package_id, - TO_CHAR(rp.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(rp.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnPackage rp, rhnChannelPackage rcp where rcp.channel_id = :channel_id and rcp.package_id = rp.id @@ -677,7 +677,7 @@ def __init__( try: query = """ select kt.id kstree_id, kt.label kickstart_label, - TO_CHAR(kt.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(kt.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnKickstartableTree kt where kt.channel_id = :channel_id """ @@ -724,10 +724,10 @@ def __init__( select rktf.relative_filename "relative-path", c.checksum_type "checksum-type", c.checksum, rktf.file_size "file-size", - TO_CHAR(rktf.last_modified, 'YYYYMMDDHH24MISS') "last-modified", + TO_CHAR(rktf.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') "last-modified", rkt.base_path "base-path", rkt.label "label", - TO_CHAR(rkt.modified, 'YYYYMMDDHH24MISS') "modified" + TO_CHAR(rkt.modified at time zone 'UTC', 'YYYYMMDDHH24MISS') "modified" from rhnKSTreeFile rktf, rhnKickstartableTree rkt, rhnChecksumView c where rktf.kstree_id = :kstree_id diff --git a/python/spacewalk/satellite_tools/exporter/exportLib.py b/python/spacewalk/satellite_tools/exporter/exportLib.py index f8295e8ca61d..7f48ec416c0c 100644 --- a/python/spacewalk/satellite_tools/exporter/exportLib.py +++ b/python/spacewalk/satellite_tools/exporter/exportLib.py @@ -554,7 +554,7 @@ def _get_ids(self, query_with_limit, query_with_rhnlimit, query_no_limits): _query_get_source_package_ids = rhnSQL.Statement( """ select distinct ps.id, sr.name source_rpm, - TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(ps.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelPackage cp, rhnPackage p, rhnPackageSource ps, rhnSourceRPM sr where cp.channel_id = :channel_id @@ -576,7 +576,7 @@ def _get_cursor_source_packages(self): _query__get_errata_ids = rhnSQL.Statement( """ select ce.errata_id as id, e.advisory_name, - TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(e.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelErrata ce, rhnErrata e where ce.channel_id = :channel_id and ce.errata_id = e.id @@ -680,7 +680,7 @@ def _get_channel_product_details(self): _query_channel_comps_last_modified = rhnSQL.Statement( """ - select to_char(last_modified, 'YYYYMMDDHH24MISS') as comps_last_modified + select TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as comps_last_modified from rhnChannelComps where channel_id = :channel_id and comps_type_id = 1 @@ -696,7 +696,7 @@ def _channel_comps_last_modified(self): _query_channel_modules_last_modified = rhnSQL.Statement( """ - select to_char(last_modified, 'YYYYMMDDHH24MISS') as modules_last_modified + select TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as modules_last_modified from rhnChannelComps where channel_id = :channel_id and comps_type_id = 2 @@ -1300,7 +1300,7 @@ def set_iterator(self): """ select name, text, - TO_CHAR(time, 'YYYYMMDDHH24MISS') as time + TO_CHAR(time at time zone 'UTC', 'YYYYMMDDHH24MISS') as time from rhnPackageChangeLog where package_id = :package_id """ @@ -1384,7 +1384,7 @@ def set_iterator(self): select pc.name, pf.device, pf.inode, pf.file_mode, pf.username, pf.groupname, pf.rdev, pf.file_size, - TO_CHAR(mtime, 'YYYYMMDDHH24MISS') mtime, + TO_CHAR(mtime at time zone 'UTC', 'YYYYMMDDHH24MISS') mtime, c.checksum_type as "checksum-type", c.checksum, pf.linkto, pf.flags, pf.verifyflags, pf.lang from rhnPackageFile pf @@ -2200,7 +2200,7 @@ def set_iterator(self): c.checksum_type, c.checksum, file_size, - TO_CHAR(last_modified, 'YYYYMMDDHH24MISS') "last-modified" + TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') "last-modified" from rhnKSTreeFile, rhnChecksumView c where kstree_id = :kstree_id and checksum_id = c.id @@ -2224,7 +2224,7 @@ class KickstartableTreesDumper(BaseSubelementDumper, BaseQueryDumper): ktt.label "kstree-type-label", kit.name "install-type-name", kit.label "install-type-label", - TO_CHAR(kt.last_modified, 'YYYYMMDDHH24MISS') "last-modified" + TO_CHAR(kt.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') "last-modified" from rhnKickstartableTree kt, rhnKSTreeType ktt, rhnKSInstallType kit, diff --git a/python/spacewalk/satellite_tools/satsync.py b/python/spacewalk/satellite_tools/satsync.py index d424b027d234..47fc1b2b09ce 100644 --- a/python/spacewalk/satellite_tools/satsync.py +++ b/python/spacewalk/satellite_tools/satsync.py @@ -20,6 +20,7 @@ # __lang. imports__ # pylint: disable=E0012, C0413 import datetime +import time import os import sys import stat @@ -1122,7 +1123,6 @@ def processShortPackages(self): if package_ids: lm = self._channel_collection.get_channel_timestamp(channel_label) channel_last_modified = int(rhnLib.timestamp(lm)) - stream_loader.set_args(channel_label, channel_last_modified) stream_loader.process(package_ids) @@ -1132,7 +1132,7 @@ def processShortPackages(self): _query_compare_packages = """ select p.id, c.checksum_type, c.checksum, p.path, p.package_size, - TO_CHAR(p.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(p.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnPackage p, rhnChecksumView c where p.name_id = lookup_package_name(:name) and p.evr_id = lookup_evr(:epoch, :version, :release, :package_type) @@ -1307,6 +1307,7 @@ def _process_package( db_checksum = row["checksum"] db_package_size = row["package_size"] db_path = row["path"] + log(3, "PKG Metadata values: {}, {}, {}, {}".format(checksum_type, checksum, package_size, l_timestamp)) if not ( l_timestamp <= db_timestamp @@ -1315,6 +1316,8 @@ def _process_package( ): # package doesn't match channel_package = package_id + log(3, "Package id {} has different checksum {} vs. {}, package size {} vs. {} or timestamp {} > {}".format( + channel_package, checksum, db_checksum, package_size, db_package_size, l_timestamp, db_timestamp)) if check_rpms: if db_path: @@ -1326,15 +1329,20 @@ def _process_package( # file doesn't match fs_package = package_id channel_package = package_id + log(3, "Package id {} - {} verify failed: {}".format(package_id, db_path, errcode)) path = db_path else: # upload package and reimport metadata channel_package = package_id fs_package = package_id + log(3, "Package id {} path not found in db".format(package_id)) + else: + log(3, "Package id {} found in DB, but missing checksum_type {}".format(package_id, checksum_type)) else: # package is missing from the DB channel_package = package_id fs_package = package_id + log(3, "Package id {} not found in db".format(package_id)) if channel_package: m_channel_packages.append(channel_package) @@ -1500,7 +1508,7 @@ def _compute_not_cached_source_packages(self): _query_compare_source_packages = """ select ps.id, c.checksum_type, c.checksum, ps.path, ps.package_size, - TO_CHAR(ps.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(ps.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnPackageSource ps, rhnChecksumView c where ps.source_rpm_id = lookup_source_name(:package_id) and (ps.org_id = :org_id or @@ -1790,7 +1798,7 @@ def _compute_not_cached_errata(self): _query_get_db_errata = rhnSQL.Statement( """ select e.id, e.advisory_name, - TO_CHAR(e.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(e.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannelErrata ce, rhnErrata e, rhnChannel c where c.label = :channel and ce.channel_id = c.id diff --git a/python/spacewalk/satellite_tools/xmlSource.py b/python/spacewalk/satellite_tools/xmlSource.py index 7bb0f3302823..54a10547114f 100644 --- a/python/spacewalk/satellite_tools/xmlSource.py +++ b/python/spacewalk/satellite_tools/xmlSource.py @@ -1423,8 +1423,8 @@ def _normalizeDateType(value): except ValueError: # string return value - # Timestamp - return backendLib.localtime(value) + # Timestamp in UTC + return backendLib.gmtime(value) # diff --git a/python/spacewalk/server/importlib/backendOracle.py b/python/spacewalk/server/importlib/backendOracle.py index bae05fbfb0dc..fba08c4eeebc 100644 --- a/python/spacewalk/server/importlib/backendOracle.py +++ b/python/spacewalk/server/importlib/backendOracle.py @@ -742,6 +742,10 @@ def setSessionTimeZoneToLocalTimeZone(self): ) sth.execute() + def setSessionTimeZoneToUTC(self): + sth = self.dbmodule.prepare("alter session set time_zone = 'UTC'") + sth.execute() + def init(self): """ Override parent to do explicit setting of the date format. (Oracle @@ -768,6 +772,10 @@ def setSessionTimeZoneToLocalTimeZone(self): ) sth.execute() + def setSessionTimeZoneToUTC(self): + sth = self.dbmodule.prepare("set session time zone 'UTC'") + sth.execute() + def init(self): """ Avoid the Oracle specific stuff here in parent method. diff --git a/python/spacewalk/server/repomd/mapper.py b/python/spacewalk/server/repomd/mapper.py index 5f52d7de322c..6bae891bac1c 100644 --- a/python/spacewalk/server/repomd/mapper.py +++ b/python/spacewalk/server/repomd/mapper.py @@ -71,7 +71,7 @@ def __init__(self, pkg_mapper, erratum_mapper, repomd_mapper): self.last_modified_sql = rhnSQL.prepare( """ select - to_char(last_modified, 'YYYYMMDDHH24MISS') as last_modified + TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as last_modified from rhnChannel where id = :channel_id @@ -413,7 +413,7 @@ def __init__(self): self.last_modified_sql = rhnSQL.prepare( """ select - to_char(last_modified, 'YYYYMMDDHH24MISS') as last_modified + TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as last_modified from rhnPackage where id = :package_id @@ -648,7 +648,7 @@ def __init__(self, package_mapper): self.last_modified_sql = rhnSQL.prepare( """ select - to_char(last_modified, 'YYYYMMDDHH24MISS') as last_modified + TO_CHAR(last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') as last_modified from rhnErrata where id = :erratum_id diff --git a/python/spacewalk/server/rhnChannel.py b/python/spacewalk/server/rhnChannel.py index ec6d5da044c0..9d0637a40d60 100644 --- a/python/spacewalk/server/rhnChannel.py +++ b/python/spacewalk/server/rhnChannel.py @@ -657,7 +657,7 @@ def channel_info(channel): c.summary, c.description, c.update_tag, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnChannelArch ca @@ -687,7 +687,7 @@ def get_base_channel(server_id, none_ok=0): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnChannelArch ca, rhnServerChannel sc where sc.server_id = :server_id and sc.channel_id = c.id @@ -836,7 +836,7 @@ def base_channel_for_rel_arch(release, server_arch, org_id=-1, user_id=None): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnChannelArch ca where c.channel_arch_id = ca.id @@ -960,7 +960,7 @@ def get_channel_for_release_arch(release, server_arch, org_id=None): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnDistChannelMap dcm, rhnChannel c, rhnChannelArch ca, @@ -988,7 +988,7 @@ def get_channel_for_release_arch(release, server_arch, org_id=None): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnOrgDistChannelMap odcm, rhnChannel c, rhnChannelArch ca, @@ -1030,8 +1030,8 @@ def applet_channels_for_uuid(uuid): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified, - to_char(s.channels_changed, 'YYYYMMDDHH24MISS') server_channels_changed + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(s.channels_changed at time zone 'UTC', 'YYYYMMDDHH24MISS') server_channels_changed from rhnChannelArch ca, rhnChannel c, rhnServerChannel sc, @@ -1087,7 +1087,7 @@ def channels_for_release_arch(release, server_arch, org_id=-1, user_id=None): c.name, c.summary, c.description, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified, + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified, -- If user_id is null, then the channel is subscribable rhn_channel.loose_user_role_check(c.id, :user_id, 'subscribe') subscribable @@ -1750,7 +1750,7 @@ def _list_packages(channel, cache_prefix, function): def getChannelInfoForKickstart(kickstart): query = """ select c.label, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnKickstartableTree kt where c.id = kt.channel_id @@ -1764,7 +1764,7 @@ def getChannelInfoForKickstart(kickstart): def getChannelInfoForKickstartOrg(kickstart, org_id): query = """ select c.label, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnKickstartableTree kt where c.id = kt.channel_id @@ -1786,7 +1786,7 @@ def getChannelInfoForKickstartSession(session): query = """ select c.label, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnKickstartableTree kt, rhnKickstartSession ks @@ -1802,7 +1802,7 @@ def getChannelInfoForKickstartSession(session): def getChildChannelInfoForKickstart(kickstart, child): query = """ select c.label, - to_char(c.last_modified, 'YYYYMMDDHH24MISS') last_modified + TO_CHAR(c.last_modified at time zone 'UTC', 'YYYYMMDDHH24MISS') last_modified from rhnChannel c, rhnKickstartableTree kt, rhnKickstartSession ks, diff --git a/python/spacewalk/spacewalk-backend.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc b/python/spacewalk/spacewalk-backend.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc new file mode 100644 index 000000000000..6b37c1e7dda5 --- /dev/null +++ b/python/spacewalk/spacewalk-backend.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc @@ -0,0 +1 @@ +- Make ISSv1 timezone independent (bsc#1221505) diff --git a/python/uyuni/common/rhnLib.py b/python/uyuni/common/rhnLib.py index bfe76c8d0530..254d2fcb0172 100644 --- a/python/uyuni/common/rhnLib.py +++ b/python/uyuni/common/rhnLib.py @@ -15,6 +15,7 @@ # import os +import calendar import re import time from datetime import tzinfo, timedelta @@ -129,7 +130,7 @@ def timestamp(s): timeval = list(time.strptime(s, format_string)) # No daylight information available timeval[8] = -1 - return time.mktime(tuple(timeval)) + return calendar.timegm(tuple(timeval)) def checkValue(val, *args): diff --git a/python/uyuni/uyuni-common-libs.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc b/python/uyuni/uyuni-common-libs.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc new file mode 100644 index 000000000000..6b37c1e7dda5 --- /dev/null +++ b/python/uyuni/uyuni-common-libs.changes.mczernek.Manager-4.3-wip-inter-server-sync-in-with-dates-in-utc @@ -0,0 +1 @@ +- Make ISSv1 timezone independent (bsc#1221505) From dff0f36430aa8cd13ba80faa13f224f418b378b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Fri, 24 Jan 2025 12:41:37 +0000 Subject: [PATCH 2/2] Make black and pylint tests happy --- .../satellite_tools/diskImportLib.py | 2 +- .../satellite_tools/disk_dumper/iss.py | 2 - python/spacewalk/satellite_tools/satsync.py | 44 ++++++++++++++++--- python/spacewalk/server/repomd/mapper.py | 4 -- python/spacewalk/server/rhnChannel.py | 1 + 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/python/spacewalk/satellite_tools/diskImportLib.py b/python/spacewalk/satellite_tools/diskImportLib.py index 6f220c45d228..c504433e3037 100644 --- a/python/spacewalk/satellite_tools/diskImportLib.py +++ b/python/spacewalk/satellite_tools/diskImportLib.py @@ -30,6 +30,7 @@ from spacewalk.server.importlib import supportInformationImport, suseProductsImport +# pylint: disable-next=missing-class-docstring class Backend: __backend = None @@ -67,7 +68,6 @@ def rpmsPath(obj_id, mountPoint, sources=0): # pylint: disable=W0232 class diskImportLibContainer: - """virtual class - redefines endContainerCallback""" # pylint: disable=E1101,E0203,W0201 diff --git a/python/spacewalk/satellite_tools/disk_dumper/iss.py b/python/spacewalk/satellite_tools/disk_dumper/iss.py index 6069771e48e5..80323dfa0165 100644 --- a/python/spacewalk/satellite_tools/disk_dumper/iss.py +++ b/python/spacewalk/satellite_tools/disk_dumper/iss.py @@ -86,7 +86,6 @@ def _getFile(self): class FileMapper: - """This class maps dumps to files. In other words, you give it the type of dump you're doing and it gives you the file to write it to. @@ -261,7 +260,6 @@ def getClonedChannelsFile(self): class Dumper(dumper.XML_Dumper): - """This class subclasses the XML_Dumper class. It overrides the _get_xml_writer method and adds a set_stream method, which will let it write to a file instead of over the wire. diff --git a/python/spacewalk/satellite_tools/satsync.py b/python/spacewalk/satellite_tools/satsync.py index 47fc1b2b09ce..34fc3e97c522 100644 --- a/python/spacewalk/satellite_tools/satsync.py +++ b/python/spacewalk/satellite_tools/satsync.py @@ -20,7 +20,6 @@ # __lang. imports__ # pylint: disable=E0012, C0413 import datetime -import time import os import sys import stat @@ -320,6 +319,7 @@ def main(self): except RhnSyncException: rhnSQL.rollback() raise + # pylint: disable-next=possibly-used-before-assignment except exception: e = sys.exc_info()[1] msg = _( @@ -532,7 +532,6 @@ def sendMail(forceEmail=0): class Syncer: - """high-level sychronization/import class NOTE: there should *ONLY* be one instance of this. """ @@ -1307,7 +1306,13 @@ def _process_package( db_checksum = row["checksum"] db_package_size = row["package_size"] db_path = row["path"] - log(3, "PKG Metadata values: {}, {}, {}, {}".format(checksum_type, checksum, package_size, l_timestamp)) + log( + 3, + # pylint: disable-next=consider-using-f-string + "PKG Metadata values: {}, {}, {}, {}".format( + checksum_type, checksum, package_size, l_timestamp + ), + ) if not ( l_timestamp <= db_timestamp @@ -1316,8 +1321,19 @@ def _process_package( ): # package doesn't match channel_package = package_id - log(3, "Package id {} has different checksum {} vs. {}, package size {} vs. {} or timestamp {} > {}".format( - channel_package, checksum, db_checksum, package_size, db_package_size, l_timestamp, db_timestamp)) + log( + 3, + # pylint: disable-next=consider-using-f-string + "Package id {} has different checksum {} vs. {}, package size {} vs. {} or timestamp {} > {}".format( + channel_package, + checksum, + db_checksum, + package_size, + db_package_size, + l_timestamp, + db_timestamp, + ), + ) if check_rpms: if db_path: @@ -1329,19 +1345,33 @@ def _process_package( # file doesn't match fs_package = package_id channel_package = package_id - log(3, "Package id {} - {} verify failed: {}".format(package_id, db_path, errcode)) + log( + 3, + # pylint: disable-next=consider-using-f-string + "Package id {} - {} verify failed: {}".format( + package_id, db_path, errcode + ), + ) path = db_path else: # upload package and reimport metadata channel_package = package_id fs_package = package_id + # pylint: disable-next=consider-using-f-string log(3, "Package id {} path not found in db".format(package_id)) else: - log(3, "Package id {} found in DB, but missing checksum_type {}".format(package_id, checksum_type)) + log( + 3, + # pylint: disable-next=consider-using-f-string + "Package id {} found in DB, but missing checksum_type {}".format( + package_id, checksum_type + ), + ) else: # package is missing from the DB channel_package = package_id fs_package = package_id + # pylint: disable-next=consider-using-f-string log(3, "Package id {} not found in db".format(package_id)) if channel_package: diff --git a/python/spacewalk/server/repomd/mapper.py b/python/spacewalk/server/repomd/mapper.py index 6bae891bac1c..4795501af0a4 100644 --- a/python/spacewalk/server/repomd/mapper.py +++ b/python/spacewalk/server/repomd/mapper.py @@ -35,7 +35,6 @@ class ChannelMapper: - """Data Mapper for Channels to the RHN db.""" def __init__(self, pkg_mapper, erratum_mapper, repomd_mapper): @@ -187,7 +186,6 @@ def _erratum_generator(self, channel_id): class CachedPackageMapper: - """Data Mapper for Packages to an on-disc cache.""" def __init__(self, mapper): @@ -225,7 +223,6 @@ def get_package(self, package_id): class SqlPackageMapper: - """Data Mapper for Packages to the RHN db.""" def __init__(self): @@ -598,7 +595,6 @@ def _fill_package_other(self, package): class CachedErratumMapper: - """Data Mapper for Errata to an on-disc cache.""" def __init__(self, mapper, package_mapper): diff --git a/python/spacewalk/server/rhnChannel.py b/python/spacewalk/server/rhnChannel.py index 9d0637a40d60..3c072bd428b2 100644 --- a/python/spacewalk/server/rhnChannel.py +++ b/python/spacewalk/server/rhnChannel.py @@ -1157,6 +1157,7 @@ def list_packages_source(channel_id): new_evr["release"], new_evr["epoch"], ] + # pylint: disable-next=possibly-used-before-assignment ret.append(new_evr_list) return ret