Skip to content

Flooring since and until datetime arguments down to second resolution in container.logs. #3342

@alexander-travov

Description

@alexander-travov

I was surprised to figure out that when you pass since and until arguments to container.logs() as datetimes they internally are floored down to the closest second with utils.datetime_to_timestamp(...).

Millisecond part of datetime is discarded.

That leads to unwanted extra logs in the output from the past before since and absent valid logs before until.

For example:

since = datetime(2025, 6, 1, hour=12, minute=0, second=0, microsecond=500_000)
logs = container.logs(since=since)
# logs would have EXTRA records in half a second from 12:00:00.000 to 12:00:00.500

until = datetime(2025, 6, 1, hour=12, minute=0, second=0, microsecond=500_000)
logs = container.logs(until=until)
# logs would NOT have records in half a second from 12:00:00.000 to 12:00:00.500

Is it by design and I need to manually convert datetime to float in such usecase?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions