eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 314 forks source link

odd error when running cactus domain:setup #193

Open robertminer1 opened 8 years ago

robertminer1 commented 8 years ago

Hi!

Trying to work this out, I'm not sure the exact reason for this:

Traceback (most recent call last):
  File "/usr/local/bin/cactus", line 9, in <module>
    load_entry_point('Cactus==3.1.0', 'console_scripts', 'cactus')()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 118, in main
    args.target(**{k: v for k, v in vars(args).items() if k != 'target'})
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 60, in domain_setup
    site.domain_setup()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/site.py", line 500, in domain_setup
    self.deployment_engine.domain_setup()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/engine.py", line 115, in domain_setup
    domain.setup()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 240, in setup
    self.pointRootToBucket()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 201, in pointRootToBucket
    endpoint = bucket.websiteEndpoint()
  File "/Library/Python/2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 81, in websiteEndpoint
    return self.bucket().get_website_endpoint()
AttributeError: 'NoneType' object has no attribute 'get_website_endpoint'
krallin commented 8 years ago

I haven't really touched this code, but it looks like there's an exception being swallowed in bucket. Not sure why this is done this way.

Are you able to install Cactus from source and change this line: https://github.com/koenbok/Cactus/blob/master/cactus/deployment/s3/domain.py#L62

to:

raise

Then, re-run, and send along the new error

Let me know

robertminer1 commented 8 years ago

Ahh.. Seems to be a similar issue that I've seen looking through closed issues here. Let me know if there is a work around:

Traceback (most recent call last):
  File "/usr/local/bin/cactus", line 9, in <module>
    load_entry_point('Cactus==3.1.0', 'console_scripts', 'cactus')()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 143, in main
    args.target(**{k: v for k, v in vars(args).items() if k != 'target'})
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 70, in domain_setup
    site.domain_setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/site.py", line 500, in domain_setup
    self.deployment_engine.domain_setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/engine.py", line 115, in domain_setup
    domain.setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 240, in setup
    self.pointRootToBucket()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 201, in pointRootToBucket
    endpoint = bucket.websiteEndpoint()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 81, in websiteEndpoint
    return self.bucket().get_website_endpoint()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 60, in bucket
    return self.connection.get_bucket(self.name)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 502, in get_bucket
    return self.head_bucket(bucket_name, headers=headers)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 521, in head_bucket
    response = self.make_request('HEAD', bucket_name, headers=headers)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 664, in make_request
    retry_handler=retry_handler
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/connection.py", line 1071, in make_request
    retry_handler=retry_handler)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/connection.py", line 943, in _mexe
    request.body, request.headers)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1053, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1093, in _send_request
    self.endheaders(body)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 893, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 855, in send
    self.connect()
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1274, in connect
    server_hostname=server_hostname)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 352, in wrap_socket
    _context=self)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 579, in __init__
    self.do_handshake()
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 816, in do_handshake
    match_hostname(self.getpeercert(), self.server_hostname)
  File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 271, in match_hostname
    % (hostname, ', '.join(map(repr, dnsnames))))
ssl.CertificateError: hostname u'jabbyjabby.com.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com'    
robertminer1 commented 8 years ago

Okay, so I changed the boto config as referenced here :+1: https://github.com/koenbok/Cactus/issues/113#issuecomment-72480759 , but I seem to be getting another error:

CREATE alias jabbyjabby.com.:A in zone jabbyjabby.com
Traceback (most recent call last):
  File "/usr/local/bin/cactus", line 9, in <module>
    load_entry_point('Cactus==3.1.0', 'console_scripts', 'cactus')()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 143, in main
    args.target(**{k: v for k, v in vars(args).items() if k != 'target'})
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/cli.py", line 70, in domain_setup
    site.domain_setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/site.py", line 500, in domain_setup
    self.deployment_engine.domain_setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/engine.py", line 115, in domain_setup
    domain.setup()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 243, in setup
    self.setupRedirect()
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 220, in setupRedirect
    if bucket.isCreated():
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 69, in isCreated
    return self.bucket() is not None
  File "/usr/local/lib/python2.7/site-packages/Cactus-3.1.0-py2.7.egg/cactus/deployment/s3/domain.py", line 60, in bucket
    return self.connection.get_bucket(self.name)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 502, in get_bucket
    return self.head_bucket(bucket_name, headers=headers)
  File "/Library/Python/2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 546, in head_bucket
    raise err
boto.exception.S3ResponseError: S3ResponseError: 404 Not Found

I can confirm it does create the first alias record in Route 53 but seems like its failing to create the www alias record?

robertminer1 commented 8 years ago

Okay, I think I figured this out. If a cactus site is setup with the www subdomain, everything works perfectly. If it is setup without a www subdomain, it fails. I wish I knew python a little bit better, I would submit a PR. For now, I can just use the www version of the domain but it would be nice to be able to choose to use www or without.

krallin commented 8 years ago

Hey Rob,

The SSL issue is indeed due to a bug in Boto ( I have a PR pending with them to fix it, but it's been waiting for a while now).

We can work around it, which we've done in other parts of Cactus. I'll try and take a crack at refactoring the DNS code so it uses the same engine code we use for S3 deployments (which works without the botorc workaround).

Now, to your second issue (www subdomain).

What's going on is that you probably don't have a bucket with the www prefix.

Unless S3 changed this recently, and if my memory is correct, a S3 bucket with static website hosting can only serve a single domain (the domain in question should be its bucket name).

So, you usually need two buckets to serve over www and the bare domain. One merely has to redirect to the other.

It looks like Cactus normally creates that second domain for you, but that raise I asked you to add breaks this.

Remove it and you should (I think) be fine.


We should definitely NOT swallow all exceptions here (just 404 / bucket not found). I'll try and fix that too,

Cheers,

On Friday, 9 October 2015, Robert Miner <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

Okay, I think I figured this out. If a cactus site is setup with the www subdomain, everything works perfectly. If it is setup without a www subdomain, it fails. I wish I knew python a little bit better, I would submit a PR. For now, I can just use the www version of the domain but it would be nice to be able to choose to use www or without.

— Reply to this email directly or view it on GitHub https://github.com/koenbok/Cactus/issues/193#issuecomment-146986557.

robertminer1 commented 8 years ago

Yes, removed the raise line and everything is working. Thanks so much!