Details
-
Type:
Bug
-
Status: Open
-
Priority:
High
-
Resolution: Unresolved
-
Affects Version/s: 3.18.0
-
Fix Version/s: None
-
Component/s: Promise type: files
-
Labels:None
Description
I found that the content attribute does not function properly if it's being used to promise a file in a directory that does not already exist.
bundle agent __main__ { vars: "echo_1631897060" string => "Never more, quote the raven", meta => { "echo_signal" }; "echo_signals" data => variablesmatching_as_data( ".*", echo_signal ); "_echo_signals_idx" slist => getindices( echo_signals ); commands: "/bin/echo $(echo_signals[$(_echo_signals_idx)])" unless => fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)" ), classes => results( "bundle", "$(_echo_signals_idx)" ); files: "$(sys.statedir)/one-shot/$(_echo_signals_idx)" content => "/bin/echo $(echo_signals[$(_echo_signals_idx)])", if => canonify( "$(_echo_signals_idx)_repaired" ); reports: "echo execution for '$(echo_signals[$(_echo_signals_idx)])' since '$(sys.statedir)/one-shot/$(_echo_signals_idx)' is absent" unless => fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)" ); "Skipping echo execution for '$(echo_signals[$(_echo_signals_idx)])' since '$(sys.statedir)/one-shot/$(_echo_signals_idx)' exists" unless => or( not( fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)") ), canonify( "$(_echo_signals_idx)_repaired" )); }
info: Executing 'no timeout' ... '/bin/echo Never more, quote the raven' notice: Q: ".../bin/echo Never": Never more, quote the raven info: Last 1 quoted lines were generated by promiser '/bin/echo Never more, quote the raven' info: Completed execution of '/bin/echo Never more, quote the raven' R: echo execution for 'Never more, quote the raven' since '/home/nickanderson/.cfagent/state/one-shot/default:main.echo_1631897060' is absent error: Failed to chdir into '/home/nickanderson/.cfagent/state/one-shot'. (chdir: 'No such file or directory') error: Cannot open file '/home/nickanderson/.cfagent/state/one-shot/default:main.echo_1631897060' for writing error: Errors encountered when actuating files promise '/home/nickanderson/.cfagent/state/one-shot/default:main.echo_1631897060'
Works fine if you first promise the directory exists:
bundle agent __main__ { vars: "echo_1631897060" string => "Never more, quote the raven", meta => { "echo_signal" }; "echo_signals" data => variablesmatching_as_data( ".*", echo_signal ); "_echo_signals_idx" slist => getindices( echo_signals ); commands: "/bin/echo $(echo_signals[$(_echo_signals_idx)])" unless => fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)" ), classes => results( "bundle", "$(_echo_signals_idx)" ); files: "$(sys.statedir)/one-shot/." create => "true"; "$(sys.statedir)/one-shot/$(_echo_signals_idx)" content => "/bin/echo $(echo_signals[$(_echo_signals_idx)])", if => canonify( "$(_echo_signals_idx)_repaired" ); reports: "echo execution for '$(echo_signals[$(_echo_signals_idx)])' since '$(sys.statedir)/one-shot/$(_echo_signals_idx)' is absent" unless => fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)" ); "Skipping echo execution for '$(echo_signals[$(_echo_signals_idx)])' since '$(sys.statedir)/one-shot/$(_echo_signals_idx)' exists" unless => or( not( fileexists( "$(sys.statedir)/one-shot/$(_echo_signals_idx)") ), canonify( "$(_echo_signals_idx)_repaired" )); }
info: Created directory '/home/nickanderson/.cfagent/state/one-shot/.' info: Executing 'no timeout' ... '/bin/echo Never more, quote the raven' notice: Q: ".../bin/echo Never": Never more, quote the raven info: Last 1 quoted lines were generated by promiser '/bin/echo Never more, quote the raven' info: Completed execution of '/bin/echo Never more, quote the raven' R: echo execution for 'Never more, quote the raven' since '/home/nickanderson/.cfagent/state/one-shot/default:main.echo_1631897060' is absent info: Updated content of '/home/nickanderson/.cfagent/state/one-shot/default:main.echo_1631897060' with content '/bin/echo Never more, quote the raven'