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

Cron.present state always updates in version 2014.1.1 #11935

Closed
caladd opened this issue Apr 11, 2014 · 7 comments
Closed

Cron.present state always updates in version 2014.1.1 #11935

caladd opened this issue Apr 11, 2014 · 7 comments
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this Regression The issue is a bug that breaks functionality known to work in previous releases.

Comments

@caladd
Copy link

caladd commented Apr 11, 2014

After the release of 2014.1.1 cron.present state always updates the cron line even when nothing has changed. For example, I have this state in my SLS:

scan-/var/www-for-viruses:
    pkg.installed:
        - name: clamav
        - require:
            - pkg: apache2

    cron.present:
        - name: "find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null"
        - user: root
        - hour: 2
        - minute: 0
        - require:
            - pkg: scan-/var/www-for-viruses

The cron line is updated every time I trigger a highstate even though nothing about the state has been updated:

      ID: scan-/var/www-for-viruses
Function: cron.present
    Name: find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
  Result: True
 Comment: Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null updated
 Changes:   
          ----------
          root:
              find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

This issue was not present in 2014.1 and was introduced when I upgraded to 2014.1.1

@basepi
Copy link
Contributor

basepi commented Apr 16, 2014

Interesting. Thanks for the heads up, we'll investigate this.

@basepi basepi added this to the Outstanding Bugs milestone Apr 16, 2014
@cachedout
Copy link
Contributor

I'm having trouble replicating this.

I'm on Ubuntu 13.10 and using the following command:

salt-call --local state.single cron.present name="find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null" user=root hour=2 minute=0 

After modifying the crontab on the initial run, additional runs are idempotent and return the following:

[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 10:59:42.030909
[INFO    ] Executing state cron.present for find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit
# SALT_CRON_IDENTIFIER:NO ID SET
0 2 * * * find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

[INFO    ] Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null already present
[INFO    ] Completed state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 10:59:42.039508
local:
----------
          ID: find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
    Function: cron.present
      Result: True
     Comment: Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null already present
     Changes:   

Summary
------------
Succeeded: 1
Failed:    0
------------
Total:     1

If you remove the offending line from your crontab and let Salt re-write it, does the behaviour change? I'm trying to figure out what we can do here to replicate this so we can try and fix it.

@caladd
Copy link
Author

caladd commented Apr 17, 2014

OK, I think I've traced a possible cause:

Here is what my crontab started as:

# Lines below here are managed by Salt, do not edit
0 2 * * * find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

Running the same salt-call as you, before removing my crontab line, gives me the update still:

[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:28:22.115706
[INFO    ] Executing state cron.present for find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit
0 2 * * * find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit
0 2 * * * find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

[INFO    ] Executing command 'crontab -u root /tmp/tmpAyHOOD' in directory '/root'
[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit

[INFO    ] Executing command 'crontab -u root /tmp/tmpsA08Ev' in directory '/root'
[INFO    ] {'root': 'find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null'}
[INFO    ] Completed state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:28:22.249573
local:
----------
          ID: find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
    Function: cron.present
      Result: True
     Comment: Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null updated
     Changes:   
              ----------
              root:
                  find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

Summary
------------
Succeeded: 1
Failed:    0
------------
Total:     1

Then I manually removed the line and ran the salt-call again, to add the command back to the crontab:

[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:30:22.126425
[INFO    ] Executing state cron.present for find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit

[INFO    ] Executing command 'crontab -u root /tmp/tmpiWzXiv' in directory '/root'
[INFO    ] {'root': 'find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null'}
[INFO    ] Completed state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:30:22.197529
local:
----------
          ID: find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
    Function: cron.present
      Result: True
     Comment: Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null added to root's crontab
     Changes:   
              ----------
              root:
                  find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

Summary
------------
Succeeded: 1
Failed:    0
------------
Total:     1

I noticed it added this line, which wasn't in the crontab before:
# SALT_CRON_IDENTIFIER:NO ID SET

Running the salt-call a third time now properly detects that the crontab line doesn't need updated:

[INFO    ] Loading fresh modules for state activity
[INFO    ] Running state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:30:34.030873
[INFO    ] Executing state cron.present for find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
[INFO    ] Executing command 'crontab -l -u root' in directory '/root'
[INFO    ] stdout: # Lines below here are managed by Salt, do not edit
# SALT_CRON_IDENTIFIER:NO ID SET
0 2 * * * find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null

[INFO    ] Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null already present
[INFO    ] Completed state [find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null] at time 11:30:34.045556
local:
----------
          ID: find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null
    Function: cron.present
      Result: True
     Comment: Cron find /var/www -type f -mtime -7 -print0 | xargs -0 clamscan -i --no-summary 2>/dev/null already present
     Changes:   

Summary
------------
Succeeded: 1
Failed:    0
------------
Total:     1

So, it appears that the missing # SALT_CRON_IDENTIFIER:NO ID SET line could be the cause?

@caladd caladd closed this as completed Apr 17, 2014
@caladd caladd reopened this Apr 17, 2014
@cachedout
Copy link
Contributor

@caladd That's exactly what I suspected might be happening. Thanks for the confirmation here. We'll get this fixed.

@kiorky
Copy link
Contributor

kiorky commented Apr 18, 2014

missing id line is not the culprint @cachedout, its even tested...
but i ve not free time for a while to look it myself.

@kiorky
Copy link
Contributor

kiorky commented Apr 18, 2014

@kiorky
Copy link
Contributor

kiorky commented Apr 18, 2014

i fixed it, making the PR.

thatch45 added a commit that referenced this issue Apr 18, 2014
basepi pushed a commit that referenced this issue Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior help-wanted Community help is needed to resolve this Regression The issue is a bug that breaks functionality known to work in previous releases.
Projects
None yet
Development

No branches or pull requests

4 participants