salt: Salt-Cloud failing to deploy to EC2 -- "There was a profile error: encode() argument 1 must be string, not None"
Description of Issue/Question
When attempting to launch an instance into AWS EC2 via salt-cloud, using a previously working profile, all attempts fail with error:
AWS Response Status Code: 400 Error Creating <servername> on EC2 when trying to run the Initial Deployment: encode() argument 1 must be string, not none
Setup
salt-cloud -p base_ec2_private SERVERNAME -l debug
/etc/salt/cloud.profiles.d/profiles.conf:
base_ec2_private:
provider: my-ec2-northeast-private-ips
script: salt_deploy_w_dns
image: ami-XXXXXXXXX
size: t2.large
subnetid: subnet-XXXXXXXXX
ssh_username: ubuntu
securitygroupid: sg-XXXXXXXXX
volumes:
- { size: 55, device: /dev/sdf }
minion:
grains:
setup: False
environment_type: qa
startup_states: highstate`
/etc/salt/cloud.providers.d/providers.conf:
my-ec2-northeast-private-ips:
#Set the location of the Salt Master
minion:
master: XXXXXXXXX
#set grains information
grains:
dom: XXXXXX
#Specify that the private IP is to be used for the script execution
ssh_interface: private_ips
#set the credientials to be used -- these are the master role credentials, which will be appended the next time we create a working Salt master
id: 'XXXXXXXX'
key: 'XXXXXXXXX'
private_key: /etc/salt/XXXX.pem
keyname: XXXXX
#specify the Salt Driver
driver: ec2
Steps to Reproduce Issue
(Include debug logs if possible and relevant.)
salt-cloud -p base_ec2_private 'SERVERNAME' -l debug
[DEBUG ] Reading configuration from /etc/salt/cloud
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Including configuration from '/etc/salt/master.d/reactor.conf'
[DEBUG ] Reading configuration from /etc/salt/master.d/reactor.conf
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: MASTER
[DEBUG ] Missing configuration file: /etc/salt/cloud.providers
[DEBUG ] Including configuration from '/etc/salt/cloud.providers.d/providers.conf'
[DEBUG ] Reading configuration from /etc/salt/cloud.providers.d/providers.conf
[DEBUG ] Missing configuration file: /etc/salt/cloud.profiles
[DEBUG ] Including configuration from '/etc/salt/cloud.profiles.d/profiles.conf'
[DEBUG ] Reading configuration from /etc/salt/cloud.profiles.d/profiles.conf
[DEBUG ] Including configuration from '/etc/salt/cloud.profiles.d/profiles2.conf'
[DEBUG ] Reading configuration from /etc/salt/cloud.profiles.d/profiles2.conf
[DEBUG ] Configuration file path: /etc/salt/cloud
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[INFO ] salt-cloud starting
[DEBUG ] Could not LazyLoad parallels.avail_sizes: 'parallels' __virtual__ returned False
[DEBUG ] LazyLoaded parallels.avail_locations
[DEBUG ] LazyLoaded proxmox.avail_sizes
[DEBUG ] Could not LazyLoad saltify.destroy: 'saltify.destroy' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_sizes: 'saltify.avail_sizes' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_images: 'saltify.avail_images' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_locations: 'saltify.avail_locations' is not available.
[DEBUG ] LazyLoaded rackspace.reboot
[DEBUG ] LazyLoaded openstack.list_locations
[DEBUG ] LazyLoaded rackspace.list_locations
[DEBUG ] Could not LazyLoad parallels.avail_sizes: 'parallels' __virtual__ returned False
[DEBUG ] LazyLoaded parallels.avail_locations
[DEBUG ] LazyLoaded proxmox.avail_sizes
[DEBUG ] Could not LazyLoad saltify.destroy: 'saltify.destroy' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_sizes: 'saltify.avail_sizes' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_images: 'saltify.avail_images' is not available.
[DEBUG ] Could not LazyLoad saltify.avail_locations: 'saltify.avail_locations' is not available.
[DEBUG ] LazyLoaded rackspace.reboot
[DEBUG ] LazyLoaded openstack.list_locations
[DEBUG ] LazyLoaded rackspace.list_locations
[DEBUG ] Using AWS endpoint: ec2.us-east-1.amazonaws.com
[DEBUG ] AWS Request: https://ec2.us-east-1.amazonaws.com/?Action=DescribeInstances&Version=2014-10-01
[DEBUG ] AWS Response Status Code: 200
[DEBUG ] LazyLoaded cloud.cache_node_list
[DEBUG ] Generating minion keys for '<SERVERNAME>'
[DEBUG ] LazyLoaded cloud.fire_event
[DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Sending event: tag = salt/cloud/<SERVERNAME>/creating; data = {'profile': 'base_ec2_private', 'event': 'starting create', '_stamp': '2016-12-15T20:27:43.460003', 'name': '<SERVERNAME>', 'provider': 'my-ec2-northeast-private-ips:ec2'}
[INFO ] Creating Cloud VM <SERVERNAME> in us-east-1
[DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Sending event: tag = salt/cloud/<SERVERNAME>/requesting; data = {'event': 'requesting instance', '_stamp': '2016-12-15T20:27:43.487663', 'location': 'us-east-1', 'kwargs': {'SecurityGroupId.7': 's', 'SecurityGroupId.6': '0', 'SecurityGroupId.5': '1', 'SecurityGroupId.4': '-', 'SecurityGroupId.3': 'f', 'SecurityGroupId.2': 'g', 'SecurityGroupId.1': 'd', 'SecurityGroupId.0': 'c', 'SecurityGroupId.9': '8', 'ImageId': 'ami-40d28157', 'SubnetId': 'subnet-3dd7b416', 'KeyName': 'Salt_Master_Test', 'MaxCount': 1, 'Action': 'RunInstances', 'MinCount': 1, 'SecurityGroupId.8': '6', 'InstanceType': 't2.large'}}
[DEBUG ] Using AWS endpoint: ec2.us-east-1.amazonaws.com
[DEBUG ] AWS Request: https://ec2.us-east-1.amazonaws.com/?Action=RunInstances&ImageId=ami-40d28157&InstanceType=t2.large&KeyName=MASTER&MaxCount=1&MinCount=1&SecurityGroupId.0=c&SecurityGroupId.1=d&SecurityGroupId.2=g&SecurityGroupId.3=f&SecurityGroupId.4=-&SecurityGroupId.5=1&SecurityGroupId.6=0&SecurityGroupId.7=s&SecurityGroupId.8=6&SecurityGroupId.9=8&SubnetId=subnet-XXXXXX&Version=2014-10-01
[DEBUG ] AWS Response Status Code: 400
[ERROR ] Error creating <SERVERNAME> on EC2 when trying to run the initial deployment:
encode() argument 1 must be string, not None
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 1921, in request_instance
sigver='4')
File "/usr/lib/python2.7/dist-packages/salt/utils/aws.py", line 463, in query
result.text.encode(result.encoding)
TypeError: encode() argument 1 must be string, not None
[ERROR ] There was a profile error: encode() argument 1 must be string, not None
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cloud/cli.py", line 284, in run
self.config.get('names')
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1458, in run_profile
ret[name] = self.create(vm_)
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1288, in create
output = self.clouds[func](vm_)
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 2510, in create
data, vm_ = request_instance(vm_, location)
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/ec2.py", line 1921, in request_instance
sigver='4')
File "/usr/lib/python2.7/dist-packages/salt/utils/aws.py", line 463, in query
result.text.encode(result.encoding)
TypeError: encode() argument 1 must be string, not None
Versions Report
(Provided by running salt --versions-report
. Please also mention any differences in master/minion versions.)
Salt Version:
Salt: 2016.11.1
Dependency Versions:
cffi: Not Installed
cherrypy: 3.5.0
dateutil: 2.4.2
gitdb: 0.6.4
gitpython: 1.0.1
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
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
machine: x86_64
release: 4.4.0-34-generic
system: Linux
version: Ubuntu 16.04 xenial
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 40 (26 by maintainers)
The easiest way to do this is to check which tags a commit is in
git tag --contains <commitid>| head -n1
In this case, the first tag that the commit in that PR is in is
Thanks for all your help @Ch3LL
K thanks for clarifying. yeah i’ve hit my limit on this one and hoping @techhat has more insight.
K perfect! Let me know if it doesn’t work and I can dive in and figure out which PR fixes it exactly.
Like I stated above though we still shouldn’t be stacktracing on that encoding error when we get a 400 error so regardless we should do a better job on the error reporting there
Hmmm I was getting the same error you were getting when i set a
securitygroupid
in the config on versoin 2016.11.1 but when i removed thesecuritygroupid
from teh config it worked.And I also found that adding
securitygroupid
back into the config on the head of 2016.11 branch it also worked so i wonder if there is a different PR that fixes the issueJust to make sure i’m tracking down the right issue can you try one more thing. If you just remove your securitygroupid does it work?