GithubHelp home page GithubHelp logo

Comments (10)

TuxInvader avatar TuxInvader commented on June 2, 2024 1

More digging has revealed that this happens to me when the hostname of the instance is the same as the hostname used in building the image. It's because the the waagent process doesn't reset the set-hostname file when deprovisioning. This results in setting the hostname being skipped in cc_set_hostname.py during cloud-init:

https://github.com/canonical/cloud-init/blob/695c4f8f46585dd7feac2fdc0729f410c539d3bc/cloudinit/config/cc_set_hostname.py#L80

I'm going to open a bug to request that waagent removes or updates /var/lib/cloud/data/set-hostname on deprovision. As a workaround I manually rm the file as the last step in my packer script.

 {
    "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'",
    "inline": [
      "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0",
      "rm /var/lib/cloud/data/set-hostname || echo 'no set-hostname file'",
      "sync; sync; sync"
    ],
    "inline_shebang": "/bin/sh -x",
    "type": "shell"
  }

from walinuxagent.

yuezh avatar yuezh commented on June 2, 2024

What is the cloud-init version the image is using? There was a bug with cloud-init that it will remove the file "SharedConfig.xml" which is essential for waagent.

from walinuxagent.

mhmxs avatar mhmxs commented on June 2, 2024

We are using cloud-init.x86_64 0:0.7.5-10.el7.centos.1. Sorry maybe i was misunderstood, i pasted the full log of the waagent. Our problem is not around the SharedConfig.xml, but in the Ovf XML processing. On the rigth node i see:

2015/10/28 13:01:16 Provisioning image using OVF settings in the DVD.
...
2015/10/28 13:01:20 EnvMonitor: Detected host name change: localhost.localdomain -> vmslave12
2015/10/28 13:01:20 Setting host name: vmslave12
2015/10/28 13:01:21 Ovf XML process finished

but on the failed:

2015/10/28 13:00:53 Provisioning image using OVF settings in the DVD.
2015/10/28 13:00:53 Wrote /var/lib/waagent/CustomData
2015/10/28 13:00:53 Disabled SSH password-based authentication methods.
2015/10/28 13:00:55 Created user account: asd
2015/10/28 13:00:55 Deploy public key:750A...
2015/10/28 13:00:55 Ovf XML process finished

So there are missing Detected host name changeand Setting host name lines.

Update: Is it true, that waagent is just reacting to the hostname change which caused by cloud-init and publishing new hostname to Azure services?

from walinuxagent.

yuezh avatar yuezh commented on June 2, 2024

Sorry. I may mislead you in the preview post. Your problem is that Network Manager is conflict with waagent. I assume you are using a customized image. You need to uninstall the Network Manager first.

from walinuxagent.

mhmxs avatar mhmxs commented on June 2, 2024

Thank you, we would try it, but really hard to catch the problem, because for example yesterday i created almost 40 instances without any problem.

from walinuxagent.

mhmxs avatar mhmxs commented on June 2, 2024

We are running on Centos7, and i found the text below in the official documentation:

Preparing a CentOS 7 virtual machine for Azure is very similar to CentOS 6, however there are several important differences worth noting:

The NetworkManager package no longer conflicts with the Azure Linux agent. This package is installed by default and we recommend that it is not removed.

from walinuxagent.

szarkos avatar szarkos commented on June 2, 2024

Right, NetworkManager is required in CentOS 7. The issue here is probably with cloud-init. Canonical wrote the cloud-init data provider for Azure, but it's really only been tested on Ubuntu. If you just install cloud-init it will work partially and probably try to provision the VM at the same time as the Azure Linux agent, which will probably be very racy and lead to odd issues like this. So in this case I would recommend removing cloud-init.

from walinuxagent.

mhmxs avatar mhmxs commented on June 2, 2024

Thank you.

from walinuxagent.

TuxInvader avatar TuxInvader commented on June 2, 2024

I think this is still an issue, at least for custom images. I'm using an Ubuntu 18.04 image created and provisioned by packer. After installing my software waagent is called with -deprovision+user.

The first machine deployed from this image in a new VNET will register with DHCP using localhost. The default config for provision.MonitorHostName in ubuntu is no so even if the hostname is changed in cloud-init or via some other mechanism the DHCP wont get updated (not unless the lease is renewed).

Subsequent hosts will get the hostname they were given through the ARM template, presumably because DHCP rejects the attempt to register localhost, and gives them the name configured for them in the Azure.

I'm guessing the issue is caused by the set_dhcp_hostname function being called during the packer build

def set_dhcp_hostname(self, hostname):

There should be an unset_dhcp_hostname() called during -deprovision

from walinuxagent.

TuxInvader avatar TuxInvader commented on June 2, 2024

Actually send host-name gethostname(); is in the original dhclient.conf, so waagent isn't adding it, it would have hardcoded the hostname if it had anyway.

For me, removing the send_hostname line from dhclient in my packer script stops localhost getting added to DNS, and modifying setting Provisioning.MonitorHostName=y in waagent.conf adds the hostname I set in cloud-init.

from walinuxagent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.