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

Error with rsync when building AWS instance #64

Closed
ghost opened this issue Jul 7, 2017 · 3 comments
Closed

Error with rsync when building AWS instance #64

ghost opened this issue Jul 7, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 7, 2017

Hey,

when i setup a new vagrant with 'vagrant up' on AWS all went fine, up to the rsync where I get an error:

There was an error when attempting to rsync a synced folder.
Please inspect the error message below for more info.

Host path: /home/losaruka/vagrant-swift-all-in-one/
Guest path: /vagrant
Command: "rsync" "--verbose" "--archive" "--delete" "-z" "--copy-links" "--no-owner" "--no-group" "--rsync-path" "sudo rsync" "-e" "ssh -p 22 -o LogLevel=FATAL  -o ControlMaster=auto -o ControlPath=/tmp/ssh.536 -o ControlPersist=10m  -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i '/home/losaruka/name-of.pem'" "--exclude" ".vagrant/" "/home/losaruka/vagrant-swift-all-in-one/" "[email protected]:/vagrant"
Error: symlink has no referent: "/home/losaruka/vagrant-swift-all-in-one/bin/.unittests"
symlink has no referent: "/home/losaruka/vagrant-swift-all-in-one/bin/.functests"
symlink has no referent: "/home/losaruka/vagrant-swift-all-in-one/bin/.probetests"
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]

The aws section of my Vagrantfile looks like this:

require 'ipaddr'
require 'vagrant-aws'

DEFAULT_BOX = "dummy"

vagrant_boxes = {
  "precise" => "https://hashicorp-files.hashicorp.com/precise64.box",
  "trusty" => "https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box",
  "xenial" => "http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-vagrant.box",
  "dummy" => "https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box",
}
vagrant_box = (ENV['VAGRANT_BOX'] || DEFAULT_BOX)
username = (ENV['VAGRANT_USERNAME'] || "ubuntu")

base_ip = IPAddr.new(ENV['IP'] || "192.168.8.80")
hosts = {
  'default' => base_ip.to_s
}
extra_vms = Integer(ENV['EXTRA_VMS'] || 0)
(1..extra_vms).each do |i|
  base_ip = base_ip.succ
  hosts["node#{i}"] = base_ip.to_s
end

current_datetime = Time.now.strftime("%Y%m%d-%H%M%S")

def load_key(path_or_contents)
  File.open(path_or_contents).read
rescue Errno::ENOENT => ex
  path_or_contents
end

local_config = {
  "username" => username,
  "full_reprovision" => (ENV['FULL_REPROVISION'] || 'false').downcase == 'true',
  "loopback_gb" => Integer(ENV['LOOPBACK_GB'] || 4),
  "extra_packages" => (ENV['EXTRA_PACKAGES'] || '').split(','),
  "storage_policies" => (ENV['STORAGE_POLICIES'] || 'default').split(','),
  "ec_policy" => (ENV['EC_POLICY'] || ''),
  "servers_per_port" => Integer(ENV['SERVERS_PER_PORT'] || 0),
  "object_sync_method" => (ENV['OBJECT_SYNC_METHOD'] || 'rsync'),
  "post_as_copy" => (ENV['POST_AS_COPY'] || 'true').downcase == 'true',
  "encryption" => (ENV['ENCRYPTION'] || 'false').downcase == 'true',
  "part_power" => Integer(ENV['PART_POWER'] || 10),
  "replicas" => Integer(ENV['REPLICAS'] || 3),
  "ec_type" => (ENV['EC_TYPE'] || 'liberasurecode_rs_vand'),
  "ec_replicas" => Integer(ENV['EC_REPLICAS'] || 6),
  "ec_parity" => Integer(ENV['EC_PARITY'] || 2),
  "ec_duplication" => Integer(ENV['EC_DUPLICATION'] || 1),
  "regions" => Integer(ENV['REGIONS'] || 1),
  "zones" => Integer(ENV['ZONES'] || 4),
  "nodes" => Integer(ENV['NODES'] || 4),
  "disks" => Integer(ENV['DISKS'] || 4),
  "ec_disks" => Integer(ENV['EC_DISKS'] || 8),
  "swift_repo" => (ENV['SWIFT_REPO'] || 'git://github.com/openstack/swift.git'),
  "swift_repo_branch" => (ENV['SWIFT_REPO_BRANCH'] || 'master'),
  "swiftclient_repo" => (ENV['SWIFTCLIENT_REPO'] || 'git://github.com/openstack/python-swiftclient.git'),
  "swiftclient_repo_branch" => (ENV['SWIFTCLIENT_REPO_BRANCH'] || 'master'),
  "swift_bench_repo" => (ENV['SWIFTBENCH_REPO'] || 'git://github.com/openstack/swift-bench.git'),
  "swift_bench_repo_branch" => (ENV['SWIFTBENCH_REPO_BRANCH'] || 'master'),
  "swift_specs_repo" => (ENV['SWIFTSPECS_REPO'] || 'git://github.com/openstack/swift-specs.git'),
  "swift_specs_repo_branch" => (ENV['SWIFTSPECS_REPO_BRANCH'] || 'master'),
  "liberasurecode_repo" => (ENV['LIBERASURECODE_REPO'] || 'git://github.com/openstack/liberasurecode.git'),
  "liberasurecode_repo_branch" => (ENV['LIBERASURECODE_REPO_BRANCH'] || 'master'),
  "pyeclib_repo" => (ENV['PYECLIB_REPO'] || 'git://github.com/openstack/pyeclib.git'),
  "pyeclib_repo_branch" => (ENV['PYECLIB_REPO_BRANCH'] || 'master'),
  "extra_key" => load_key(ENV['EXTRA_KEY'] || ''),
  "source_root" => (ENV['SOURCE_ROOT'] || '/vagrant'),
}


Vagrant.configure("2") do |global_config|
  global_config.ssh.username = username
  global_config.ssh.forward_agent = true
  hosts.each do |vm_name, ip|
    global_config.vm.define vm_name do |config|
      hostname = vm_name
      if hostname == 'default' then
        hostname = (ENV['VAGRANT_HOSTNAME'] || 'saio')
      end

      config.vm.box = vagrant_box
      if vagrant_boxes.key? vagrant_box
        config.vm.box_url = vagrant_boxes[vagrant_box]
      end

      config.vm.provider :virtualbox do |vb, override|
        override.vm.hostname = hostname
        override.vm.network :private_network, ip: ip

        vb.name = "vagrant-#{hostname}-#{current_datetime}"
        vb.cpus = Integer(ENV['VAGRANT_CPUS'] || 1)
        vb.memory = Integer(ENV['VAGRANT_RAM'] || 1024)
        if (ENV['GUI'] || '').nil?  # Why is my VM hung on boot? Find out!
          vb.gui = true
        end
      end

      config.vm.provider :aws do |v, override|
        override.ssh.private_key_path = '/home/losaruka/name-of.pem'

        v.access_key_id = 'access_key'
        v.secret_access_key = 'secret_key'
        v.region = 'eu-central-1'
        v.ami = 'ami-1c45e273'
        v.instance_type = 't2.micro'
        v.elastic_ip = 'true'
        v.keypair_name = 'name'
        security_groups = 'group'
        v.security_groups = security_groups.split(',') unless security_groups.nil?
        v.tags = {'Name' => 'swift'}
      end

      config.vm.provision :chef_solo do |chef|
        chef.add_recipe "swift"
        chef.json = local_config
        chef.synced_folder_type = 'rsync'
      end
    end
  end
end

I hope anyone can help me. I need this for my master's thesis and don't know why I get this error.

Thank you in advance.

-losaruka

@clayg clayg changed the title Error with rsync Error with rsync when building AWS instance Jul 7, 2017
@clayg
Copy link
Collaborator

clayg commented Jul 7, 2017

You shouldn't need/want to edit the Vagrantfile directly, you should make a copy of the localrc-template and add the relevant aws options:

export AWS_ACCESS_KEY_ID=<access_key>
export AWS_SECRET_ACCESS_KEY=<secret_key>
export SSH_PRIVATE_KEY_PATH=/my/path/to/.ssh/id_rsa
export AWS_REGION=us-east-1
export AWS_AMI=ami-03d2116e
export AWS_INSTANCE_TYPE=m3.medium
export AWS_ELASTIC_IP=true
export AWS_KEYPAIR_NAME=<my-key-pair>
export AWS_SECURITY_GROUPS=ssh-only
export VAGRANT_BOX=dummy

... and source into your environment that before running vagrant up

The error seems to indicate maybe the remote path /vagrant doesn't exist or isn't getting created correctly? You might want to change SOURCE_ROOT to something that already exists on the host or manually ensure /vagrant exists??? I'm not 100% sure, it's been a while since I've tried the aws build options, it may have rusted. I'll try to give it a go.

Depending on if we can this working, I think there is a non-zero chance this is a dupe of issue #41

@ghost
Copy link
Author

ghost commented Jul 7, 2017

I think this error has something to do with the symlinked files in the bin-folder. I have removed it and the script doesn't show any error. All went successful.

In my opinion this is logical because the symlinked files doesn't have any source files to link to. In this case the script can't copy anything to the VM. I wonder that no one else get this error or anybody else removed this files by themselves 😆

I hope you can follow my thoughts.

And thanks for the input, that I shouldn't edit the Vagrantfile. I have now a localrc.aws-File with the aws-options you mentioned. 👍

@clayg
Copy link
Collaborator

clayg commented Jul 7, 2017

ugh, so hashicorp/vagrant#5471 makes reference to how the rsync options for --archive and --copy-links don't really make sense together, in our case we need --archive to just create the links in the remote, they'll start to work on the guest after provisioning.

I think the solution in 09f749 should fix this in the future.

FWIW, I had a hard time upgrading to a newer version of vagrant that would reproduce this error because of mitchellh/vagrant-aws#516

Thanks for taking the time to report the issue! Good luck on your thesis!

@clayg clayg closed this as completed Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant