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

kubernetes.configmap_present source is parsed (should be "plain format") #45367

Closed
jryberg opened this issue Jan 10, 2018 · 5 comments
Closed
Labels
Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged stale
Milestone

Comments

@jryberg
Copy link
Contributor

jryberg commented Jan 10, 2018

Description of Issue/Question

I'm trying to load data into a configmap but Salt tries to parse specified source file with the following error message:

local:
----------
          ID: Create alertindex configmap
    Function: kubernetes.configmap_present
        Name: opt-splunk-etc-apps-alertindex-local-indexes.conf
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/dist-packages/salt/state.py", line 1843, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1795, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/states/kubernetes.py", line 678, in configmap_present
                  **kwargs)
                File "/usr/lib/python2.7/dist-packages/salt/modules/kubernetes.py", line 1070, in create_configmap
                  data = __read_and_render_yaml_file(source, template, saltenv)
                File "/usr/lib/python2.7/dist-packages/salt/modules/kubernetes.py", line 1398, in __read_and_render_yaml_file
                  return yaml.load(contents)
                File "/usr/local/lib/python2.7/dist-packages/yaml/__init__.py", line 71, in load
                  return loader.get_single_data()
                File "/usr/local/lib/python2.7/dist-packages/yaml/constructor.py", line 37, in get_single_data
                  node = self.get_single_node()
                File "/usr/local/lib/python2.7/dist-packages/yaml/composer.py", line 39, in get_single_node
                  if not self.check_event(StreamEndEvent):
                File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event
                  self.current_event = self.state()
                File "/usr/local/lib/python2.7/dist-packages/yaml/parser.py", line 174, in parse_document_start
                  self.peek_token().start_mark)
              ParserError: expected '<document start>', but found '<scalar>'
                in "<string>", line 2, column 1:
                  coldPath = $SPLUNK_DB/hbindex/colddb
                  ^
     Started: 12:43:55.422711
    Duration: 415.714 ms
     Changes:

According to the documentation (https://docs.saltstack.com/en/latest/ref/states/all/salt.states.kubernetes.html#salt.states.kubernetes.configmap_present):

source
    A file containing the data of the configmap in plain format.

I expect the content to be added to the configmap, not parsed unless a template engine is engaged (#45018).

Setup

test.sls:

Create alertindex configmap:
  kubernetes.configmap_present:
    - name: opt-splunk-etc-apps-alertindex-local-indexes.conf
    - source: salt://{{ slspath }}/files/indexes.conf

indexes.conf:

[hbindex]
coldPath = $SPLUNK_DB/hbindex/colddb
homePath = $SPLUNK_DB/hbindex/db
thawedPath = $SPLUNK_DB/hbindex/thaweddb

[alertindex]
coldPath = $SPLUNK_DB/alertindex/colddb
homePath = $SPLUNK_DB/alertindex/db
thawedPath = $SPLUNK_DB/alertindex/thaweddb

Steps to Reproduce Issue

Add files above to a state and run

Versions Report

Master

Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.5.0
       dateutil: 2.6.0
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.6 (default, Nov 23 2017, 15:49:48)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-137-generic
         system: Linux
        version: Ubuntu 14.04 trusty

Minion

Salt Version:
           Salt: 2017.7.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 20 2017, 18:23:56)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.10.0-42-generic
         system: Linux
        version: Ubuntu 16.04 xenial
@garethgreenaway
Copy link
Contributor

@jryberg Thanks for the report. It looks like the documentation for this might be wrong and it's actually expecting YAML. Tagging @flavio who added the module and state mdoule.

@garethgreenaway garethgreenaway added this to the Blocked milestone Jan 10, 2018
@garethgreenaway garethgreenaway added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Jan 10, 2018
@jryberg
Copy link
Contributor Author

jryberg commented Jan 11, 2018

Hi @flavio

"Plain format" / binary copy, the exact same way kubectl create configmap --from-file= would make perfect sense.

This one are related to #45018 regarding missing template support.

Yaml representation of the data would not help any of my use cases but binary copy and more important, template support would make a huge difference to the better.

@jryberg
Copy link
Contributor Author

jryberg commented Feb 16, 2018

@garethgreenaway @flavio

Will someone please make a decision? As previously stated I think "plain format" with support for templates would be very useful.

@stale
Copy link

stale bot commented Jun 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jun 1, 2019
@stale stale bot closed this as completed Jun 8, 2019
@jryberg
Copy link
Contributor Author

jryberg commented Jun 13, 2019

Was it fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged stale
Projects
None yet
Development

No branches or pull requests

2 participants