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

Properly poll Openstack metadata + other Openstack improvements #818

Merged
merged 8 commits into from
May 11, 2016

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented May 9, 2016

The existing Openstack metadata logic failed as it was hardcoded to use metadata from 2013 that doesn't seem to exist in standard installs. Instead lets use the logic in the EC2 metadata mixin to find the latest version we support.
Wrap metadata fetching around socket connection check from the EC2 metadata plugin. This prevents hung Ohai runs on providers that don't support the metadata endpoint
Grab the Openstack data correctly in the Cloud plugins
Detect a system as being on Openstack based on DMI data
Remove HP cloud logic since that's dead
Add debug logging so we can follow what's happening in the logs better

Previously nil data we now have:

 "cloud": {
    "public_ips": [
      "172.16.20.52"
    ],
    "private_ips": [
      "192.168.1.203"
    ],
    "public_ipv4": "172.16.20.52",
    "public_hostname": "ohai.novalocal",
    "local_ipv4": "192.168.1.203",
    "local_hostname": "ohai.novalocal",
    "provider": "openstack"
  },
  "cloud_v2": {
    "public_ipv4_addrs": [
      "172.16.20.52"
    ],
    "local_ipv4_addrs": [
      "192.168.1.203"
    ],
    "provider": "openstack",
    "public_hostname": "ohai.novalocal",
    "local_hostname": "ohai.novalocal",
    "public_ipv4": "172.16.20.52",
    "local_ipv4": "192.168.1.203"
  },
 "openstack": {
    "provider": "openstack",
    "metadata": {
      "ami_id": "ami-00000002",
      "ami_launch_index": "0",
      "ami_manifest_path": "FIXME",
      "block_device_mapping_ami": "vda",
      "block_device_mapping_root": "/dev/vda",
      "hostname": "ohai.novalocal",
      "instance_action": "none",
      "instance_id": "i-00000211",
      "instance_type": "m1.medium",
      "kernel_id": "None",
      "local_hostname": "ohai.novalocal",
      "local_ipv4": "192.168.1.203",
      "placement_availability_zone": "nova",
      "public_hostname": "ohai.novalocal",
      "public_ipv4": "172.16.20.52",
      "public_keys_0_openssh_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxAVkrfknXoHFQtyXtYZ6vONLHn7HTKQq4mkwvCOPMKb3gr6gsLQkCdzmO3CQwOcFl7uDWGdfjH/ocuSUSn6xMvfCdsdGzDiLQXcDJ4jGOuuyOioniN1N00IhAD7Tqsf4AvbQJ7gDqfPKDCw6LdlZ0d0d9pWlJf7eKf/Hq3x8RCqWek/+UCoU4l4T1eAM0N/bA5tj3EfvRuDniO8U5ClsuUbtJ1uxJmrWMhFox3jFp6oNrleHWFTiRsNKfbtfTrTJRYlqcOG2jGAb49JY+p6Ykku4vq0ezYZFYXGJki6a0yLu1kMg5aHJo9UX0d9JW6y11KfXbGKN4okeRcH/tSNov jasghar@remasghar01.local",
      "ramdisk_id": "None",
      "reservation_id": "r-nvo4xzvf",
      "security_groups": [
      ]
    }

The existing Openstack metadata logic failed as it was hardcoded to use metadata from 2013 that doesn't seem to exist in standard installs. Instead lets use the logic in the EC2 metadata mixin to find the latest version we support.
Wrap metadata fetching around  socket connection check from the EC2 metadata plugin. This prevents hung Ohai runs on providers that don't support the metadata endpoint
Grab the Openstack data correctly in the Cloud plugins
Detect a system as being on Openstack based on DMI data
Remove HP cloud logic since that's dead
Add debug logging so we can follow what's happening in the logs better
@jjasghar
Copy link

jjasghar commented May 9, 2016

🤘 this is awesome sauce.

Test DMI data path, remove openstack specific metadata since we're not gathering this at the moment.
@tas50
Copy link
Contributor Author

tas50 commented May 9, 2016

This is ready for review @chef/client-core @mcquin @btm

@tas50 tas50 changed the title WIP: Properly poll Openstack detection + other Openstack improvements Properly poll Openstack detection + other Openstack improvements May 9, 2016
This makes it easier to write recipes without being super defensive in
your code
def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = "2013-04-04")
path = "/openstack/#{api_version}/meta_data.json"
uri = "http://#{addr}#{path}"
# dreamhost systems hae the dhc-user on them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@thommay
Copy link
Contributor

thommay commented May 10, 2016

some tweaks, but 👍

tas50 added 2 commits May 10, 2016 09:01
This reverts nesting the attributes in openstack['metadata']. This
matches what we do in other clouds
@@ -189,7 +189,7 @@ def get_openstack_values
cloud[:public_hostname] = openstack["public_hostname"]
cloud[:local_ipv4] = openstack["local_ipv4"]
cloud[:local_hostname] = openstack["local_hostname"]
cloud[:provider] = openstack["provider"]
cloud[:provider] = "openstack"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this can sometimes be "dreamhost"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this one gets a bit weird and here's why I went with openstack. When you're in the context of the cloud plugin says provider you'd think openstack (right? maybe...). When you're in the context of the openstack plugin you know you're openstack so when someone says provider you're thinking about what openstack provider and that could be dreamhost. I guess it could really go either way though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be breaking for some users. Though I understand your argument, I think it's safer to keep it as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous behavior was HP or Openstack, but I'll switch this one back. People on Dreamhost can figure it out probably.

@mcquin
Copy link
Contributor

mcquin commented May 11, 2016

👍 🚀 🎉

@tas50 tas50 merged commit ab28b87 into master May 11, 2016
@tas50 tas50 deleted the openstack branch May 11, 2016 15:23
@tas50 tas50 changed the title Properly poll Openstack detection + other Openstack improvements Properly poll Openstack metadata + other Openstack improvements May 11, 2016
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 24, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants