saltstack / saltstack/salt

module.run file.find failed: '<' not supported between instances of 'str' and 'list'

Open
#61,572 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Execution-Module
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
In my state we are running file.find using module.run. Here we are checking log files which are older than 10 days and delete them according by passing delete: f as a option. When there are files to delete then it fails with:
'file.find' failed: '<' not supported between instances of 'str' and 'list'

Setup
Need some files older than 10 days or change the value in state files, otherwise it will not produce any error

delete test:
  module.run:
    - file.find:
      - path: /tmp/
      - iname: "*_access_log.*.log"
      - delete: f
      - maxdepth: 1
      - mtime: +10d
      - print: path,size,mtime

output:

ID: delete test
   Function: module.run
     Result: False
    Comment: 'file.find' failed: '<' not supported between instances of 'str' and 'list'
    Started: 17:10:34.548267
   Duration: 14.472 ms
    Changes:

Expected behavior
It should return the file path, size, mtime which are deleted using this state as we have specified in print option.

Versions Report

Salt: 3002.6

Dependency Versions:
          cffi: 1.11.5
      cherrypy: unknown
      Python: 3.6.8 (default, Sep  9 2021, 07:49:02)
System Versions:
          dist: rhel 8.5 Ootpa
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-348.7.1.el8_5.x86_64
        system: Linux
       version: Red Hat Enterprise Linux 8.5 Ootpa

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Salt 3002.6 state with module.run, file.find, delete: f, and print: path,size,mtime using files older than 10 days. Trace how file.find handles the delete and print options; done means deletion succeeds without the string/list comparison error and the requested file path, size, and mtime are returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.