Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job_status: Convert datetime objects into formatted strings #61043

Merged
merged 1 commit into from Dec 10, 2021

Conversation

bdrung
Copy link
Contributor

@bdrung bdrung commented Oct 13, 2021

salt-call schedule.job_status will return empty values for the datetime.datetime objects. So convert the datetime.datetime objects into formatted strings. Then they will be shown correctly:

$ sudo salt-call schedule.job_status __mine_interval
local:
    ----------
    _last_run:
        2021-11-01T12:36:57
    _next_fire_time:
        2021-11-01T13:36:57
    _next_scheduled_fire_time:
        2021-11-01T13:36:57
    _run_on_start:
        False
    _seconds:
        3600
    _splay:
        None
    enabled:
        True
    function:
        mine.update
    jid_include:
        True
    maxrunning:
        2
    minutes:
        60
    name:
        __mine_interval
    return_job:
        False
    run:
        True
    run_on_start:
        True
    splay:
        None

@bdrung bdrung requested a review from a team as a code owner October 13, 2021 15:19
@bdrung bdrung requested review from garethgreenaway and removed request for a team October 13, 2021 15:19
bdrung added a commit to bdrung/salt that referenced this pull request Oct 13, 2021
Backport `schedule.job_status` from version 3003 (commit
291912b).

Also include my improvemements:
* Add missing job_name to schedule.job_status example
  saltstack#61041
* job_status: Convert datetime objects into formatted strings
  saltstack#61043

Forwarded: not-needed
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
Copy link
Contributor

@Ch3LL Ch3LL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will require a changelog and test coverage.

bdrung added a commit to bdrung/salt that referenced this pull request Oct 14, 2021
`salt-call schedule.job_status` will return empty values for the
`datetime.datetime` objects. So convert the `datetime.datetime` objects
into formatted strings. Then they will be shown correctly:

```
$ sudo salt-call schedule.job_status backup
local:
    ----------
    _next_fire_time:
        2021-10-13T15:10:18
    _next_scheduled_fire_time:
        2021-10-13T15:10:00
    _run:
        True
    _splay:
        2021-10-13T15:10:18
    args:
        - run_backup
    function:
        state.sls
    name:
        backup
    splay:
        60
    when:
        15:10
```

Forwarded: saltstack#61043
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
@bdrung
Copy link
Contributor Author

bdrung commented Nov 1, 2021

Added a changelog and enhanced test_job_status to cover this change.

Ch3LL
Ch3LL previously approved these changes Nov 10, 2021
@Ch3LL Ch3LL added the Phosphorus v3005.0 Release code name and version label Nov 10, 2021
@bdrung
Copy link
Contributor Author

bdrung commented Nov 11, 2021

Just rebased on master

@github-actions
Copy link

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
[INFO] Initializing environment for https://github.com/saltstack/pip-tools-compile-impersonate.
[INFO] Initializing environment for https://github.com/asottile/pyupgrade.
[INFO] Initializing environment for https://github.com/saltstack/pre-commit-remove-import-headers.
[INFO] Initializing environment for https://github.com/s0undt3ch/salt-rewrite.
[INFO] Initializing environment for https://github.com/timothycrosley/isort.
[INFO] Initializing environment for https://github.com/timothycrosley/isort:toml.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/asottile/blacken-docs.
[INFO] Initializing environment for https://github.com/asottile/blacken-docs:black==21.7b0.
[INFO] Initializing environment for https://github.com/PyCQA/bandit.
[INFO] Initializing environment for https://github.com/saltstack/invoke-pre-commit.
[INFO] Initializing environment for https://github.com/saltstack/invoke-pre-commit:blessings,distro,jinja2,msgpack,pyyaml.
[INFO] Initializing environment for https://github.com/saltstack/mirrors-nox.
[INFO] Initializing environment for https://github.com/saltstack/mirrors-nox:pip>=20.2.4,<21.2,setuptools<58.0.
[INFO] Installing environment for https://github.com/saltstack/invoke-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Check Known Missing Docstrings...........................................Passed
- hook id: invoke
- duration: 1.25s

Thanks again!

@Ch3LL
Copy link
Contributor

Ch3LL commented Dec 7, 2021

Can you rebase again, Fedora 35 was removed form the pipelines until we can take the time to fix all the tests.

@bdrung
Copy link
Contributor Author

bdrung commented Dec 7, 2021

Rebased.

`salt-call schedule.job_status` will return empty values for the
`datetime.datetime` objects. So convert the `datetime.datetime` objects
into formatted strings. Then they will be shown correctly:

```
$ sudo salt-call schedule.job_status __mine_interval
local:
    ----------
    _last_run:
        2021-11-01T12:36:57
    _next_fire_time:
        2021-11-01T13:36:57
    _next_scheduled_fire_time:
        2021-11-01T13:36:57
    _run_on_start:
        False
    _seconds:
        3600
    _splay:
        None
    enabled:
        True
    function:
        mine.update
    jid_include:
        True
    maxrunning:
        2
    minutes:
        60
    name:
        __mine_interval
    return_job:
        False
    run:
        True
    run_on_start:
        True
    splay:
        None
```

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
@Ch3LL Ch3LL merged commit e11e385 into saltstack:master Dec 10, 2021
@bdrung bdrung deleted the fix-datetime-in-job-status branch December 11, 2021 14:20
bdrung added a commit to bdrung/salt that referenced this pull request Apr 15, 2022
`salt-call schedule.job_status` will return empty values for the
`datetime.datetime` objects. So convert the `datetime.datetime` objects
into formatted strings. Then they will be shown correctly:

```
$ sudo salt-call schedule.job_status __mine_interval
local:
    ----------
    _last_run:
        2021-11-01T12:36:57
    _next_fire_time:
        2021-11-01T13:36:57
    _next_scheduled_fire_time:
        2021-11-01T13:36:57
    _run_on_start:
        False
    _seconds:
        3600
    _splay:
        None
    enabled:
        True
    function:
        mine.update
    jid_include:
        True
    maxrunning:
        2
    minutes:
        60
    name:
        __mine_interval
    return_job:
        False
    run:
        True
    run_on_start:
        True
    splay:
        None
```

Forwarded: saltstack#61043
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
Gbp-Pq: Name job_status-Convert-datetime-objects-into-formatted-s.patch
bdrung added a commit to bdrung/salt that referenced this pull request Apr 16, 2022
`salt-call schedule.job_status` will return empty values for the
`datetime.datetime` objects. So convert the `datetime.datetime` objects
into formatted strings. Then they will be shown correctly:

```
$ sudo salt-call schedule.job_status __mine_interval
local:
    ----------
    _last_run:
        2021-11-01T12:36:57
    _next_fire_time:
        2021-11-01T13:36:57
    _next_scheduled_fire_time:
        2021-11-01T13:36:57
    _run_on_start:
        False
    _seconds:
        3600
    _splay:
        None
    enabled:
        True
    function:
        mine.update
    jid_include:
        True
    maxrunning:
        2
    minutes:
        60
    name:
        __mine_interval
    return_job:
        False
    run:
        True
    run_on_start:
        True
    splay:
        None
```

Forwarded: saltstack#61043
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
Gbp-Pq: Name job_status-Convert-datetime-objects-into-formatted-s.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Phosphorus v3005.0 Release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants