saltstack / saltstack/salt

boto_efs.create_tags seems not to work at all

Open
#53,744 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

boto bug Confirmed severity-high
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue

Due to salt not having states for EFS functionality I am using the boto modules. I have a pillar for AWS authentication which I specify using profile= and the other parameters are as per the documentation.

#  salt-call --local boto_efs.create_tags fs-93f9eb5b Name=awesome profile=my_profile

Passed invalid arguments: create_tags() takes at least 2 arguments (2 given).

Usage:

    Creates or overwrites tags associated with a file system.
    Each tag is a key-value pair. If a tag key specified in the request
    already exists on the file system, this operation overwrites
    its value with the value provided in the request.

    filesystemid
        (string) - ID of the file system for whose tags will be modified.

    tags
        (dict) - The tags to add to the file system

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' boto_efs.create_tags

I can create an efs file system using:
salt-call --local boto_efs.create_file_system $fsname generalPurpose $fsname profile=my_profile

This also produces an error, but the file system IS created in AWS:

root@salt:/srv/salt# fsname="myfsname"
root@salt:/srv/salt# salt-call --local  boto_efs.create_file_system $fsname generalPurpose $fsname  profile=my_profile
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
ParamValidationError: Parameter validation failed:
Invalid type for parameter Tags, value: {u'Value': u'myfsname', u'Key': u'Name'}, type: <type 'dict'>, valid types: <type 'list'>, <type 'tuple'>
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/modules/boto_efs.py", line 167, in create_file_system
    client.create_tags(FileSystemId=response['FileSystemId'], Tags=tags)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 634, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 682, in _convert_to_request_dict
    api_params, operation_model)
  File "/usr/local/lib/python2.7/dist-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
ParamValidationError: Parameter validation failed:
Invalid type for parameter Tags, value: {u'Value': u'myfsname', u'Key': u'Name'}, type: <type 'dict'>, valid types: <type 'list'>, <type 'tuple'>
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 11, in <module>
    salt_call()
  File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 138, in run
    ret = self.call()
  File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 237, in call
    ret['return'] = self.minion.executors[fname](self.opts, data, func, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/modules/boto_efs.py", line 167, in create_file_system
    client.create_tags(FileSystemId=response['FileSystemId'], Tags=tags)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 634, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 682, in _convert_to_request_dict
    api_params, operation_model)
  File "/usr/local/lib/python2.7/dist-packages/botocore/validate.py", line 297, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter Tags, value: {u'Value': u'myfsname', u'Key': u'Name'}, type: <type 'dict'>, valid types: <type 'list'>, <type 'tuple'>
Setup
/srv/pillar/aws_key.sls:
my_profile:
  keyid: 'XXXXXXXXXXXXXXXXXXXX'
  key: 'xxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  region: eu-west-1

The /srv/pillar/top.sls includes this file for '*' and it works fine with all my boto state recipes.

Steps to Reproduce Issue

Debian 9 with salt installed using bootstrap method.
Python boto modules installed using pip.

Versions Report
# salt --versions
Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.8.0
      docker-py: Not Installed
          gitdb: 2.0.0
      gitpython: 2.1.1
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.1
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.9 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-3-amd64
         system: Linux
        version: debian 9.9 

Boto versions:

# pip freeze | grep boto
boto==2.49.0
boto3==1.9.183
botocore==1.12.183

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 in salt/modules/boto_efs.py, especially create_tags and create_file_system around the reported line 167, and compare the tag value passed to the AWS EFS client with the validation error. Reproduce the two reported salt-call commands, then verify that tag creation completes without a validation error and that the filesystem receives the requested Name tag.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.