Commit 2bb635e3 authored by Thomas de Grenier de Latour's avatar Thomas de Grenier de Latour
Browse files

fix: fully support ISO 8601 timestamps (pipeline updated_at), including with a non-UTC TZ

parent 617665a0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -445,8 +445,8 @@ class Butler:
        if self.verbose and self.debug:
            print(f'loaded cfg for project {project.path_with_namespace} = {cfg}')

        # # generate cutoff date
        updated_limit = datetime.today() - timedelta(days=cfg.pipelines.delete_older_than)
        # generate cutoff datetime, from current local day (must be offset-aware)
        updated_limit = datetime.now().astimezone().replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(days=cfg.pipelines.delete_older_than)

        # count deletion attempts, and actual deletions
        pipelines_deletions_attempts = 0
@@ -467,10 +467,10 @@ class Butler:
                break

            # if the pipeline has been updated after the cutoff date: keep and break loop
            if datetime.strptime(pipeline.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ") >= updated_limit:
            if datetime.fromisoformat(pipeline.updated_at) >= updated_limit:
                if self.verbose and self.debug:
                    print(
                        f'Pipeline {pipeline.id} age is under limit ({datetime.strptime(pipeline.created_at, "%Y-%m-%dT%H:%M:%S.%fZ")} >= {updated_limit}), stopping')
                        f'Pipeline {pipeline.id} age is under limit ({datetime.fromisoformat(pipeline.updated_at)} >= {updated_limit}), stopping')
                break

            # check pipeline source status