Skip to content

Glob pattern isn't resolved for !include directive in YAML format #3901

Description

@AngryGami

Describe the bug

No matter how I've tried I can't make paths with * in them work in !include directive.

To Reproduce

Here is simple Docker file that demonstrates the problem:

FROM fluent/fluentd:v1.15-1

SHELL ["/bin/ash", "-c"]

RUN mkdir -p /fluentd/etc/more \
  && echo $'\
- match:\n\
    $tag: "morematch" \n\
    $type: stdout\
' > /fluentd/etc/more/morematchers.yaml 
RUN cat /fluentd/etc/more/morematchers.yaml

RUN echo $'\
config:\n\
  - match:\n\
      $tag: "**" \n\
      $type: stdout \n\
  - !include /fluentd/etc/more/*.yaml\
#  - !include /fluentd/etc/more/morematchers.yaml\
' > /fluentd/etc/fluentd.yaml \
  && cat /fluentd/etc/fluentd.yaml

RUN fluentd --dry-run -c /fluentd/etc/fluentd.yaml

you can build it using:

 docker build --no-cache .

and It will spit out following exception:

/usr/lib/ruby/gems/3.1.0/gems/fluentd-1.15.2/lib/fluent/config/yaml_parser/loader.rb:58:in `initialize': No such file or directory @ rb_sysopen - /fluentd/etc/more/*.yaml (Errno::ENOENT)
        from /usr/lib/ruby/gems/3.1.0/gems/fluentd-1.15.2/lib/fluent/config/yaml_parser/loader.rb:58:in `open'
        from /usr/lib/ruby/gems/3.1.0/gems/fluentd-1.15.2/lib/fluent/config/yaml_parser/loader.rb:58:in `open'
        from /usr/lib/ruby/gems/3.1.0/gems/fluentd-1.15.2/lib/fluent/config/yaml_parser/loader.rb:58:in `load'
        from /usr/lib/ruby/gems/3.1.0/gems/fluentd-1.15.2/lib/fluent/config/yaml_parser/loader.rb:47:in `block in load'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:43:in `accept'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:338:in `block in register_empty'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:338:in `each'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:338:in `register_empty'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:146:in `visit_Psych_Nodes_Sequence'
        from /usr/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
        from /usr/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:345:in `block in revive_hash'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each_slice'
        from /usr/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `revive_hash'
...

And if I use actual file name instead (in docker file above):

#  - !include /fluentd/etc/more/*.yaml\
  - !include /fluentd/etc/more/morematchers.yaml\

it just works without errors

Expected behavior

Glob pattern must be resolved or documentation here must be fixed.

Your Environment

- Fluentd version:1.15
- Operating system: linux (docker container)

Your Configuration

see "To reproduce" section

Your Error Log

see "To reproduce" section

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions