Open Liuwenfan opened 8 months ago
I add some other test case, I change the config apply_network_config:false and sync the change to vm image. the config in new machine that create from this image take effect.
@Liuwenfan Quick question, do you run sudo cloud-init clean --logs
after modifying the /etc/cloud/cloud.cfg
file and before rebooting the VM?
I have followed the following steps:
/etc/cloud/cloud.cfg
sudo cloud-init clean --logs
2024-03-12 09:22:58,103 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-12 09:22:58,103 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config_from_fallback_config: _generate_network_config_from_fallback_config
2024-03-12 09:22:58,107 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config_from_fallback_config: SUCCESS: _generate_network_config_from_fallback_config
2024-03-12 09:22:58,107 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
2024-03-12 09:23:59,112 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-12 09:23:59,112 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config_from_fallback_config: _generate_network_config_from_fallback_config
2024-03-12 09:23:59,113 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config_from_fallback_config: SUCCESS: _generate_network_config_from_fallback_config
2024-03-12 09:23:59,113 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
I see it generates the network config from fallback config.
old config is apply_network_config:true? I have changed the config value to false in image; I change the value to true in machine which default value of apply_network_config is false and effect, then run cloud-init clean command, command return status is zero. after machine reboot, I get following logs:
2024-03-13 05:35:31,539+0000 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config_from_fallback_config: SUCCESS: _generate_network_config_from_fallback_config
the desired result is generate_network_config_from_instance_network_metadata, the current apply_network_config is true
Hey @Liuwenfan I have tried reproducing this
Rocky 9.3 Cloud-init v23.1.1 platform Azure
However I have not been successful.
2024-03-13 09:16:12,045 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-13 09:16:12,045 - handlers.py[DEBUG]: start: azure-ds/generate_network_config_from_instance_network_metadata: generate_network_config_from_instance_network_metadata
2024-03-13 09:16:12,048 - handlers.py[DEBUG]: finish: azure-ds/generate_network_config_from_instance_network_metadata: SUCCESS: generate_network_config_from_instance_network_metadata
2024-03-13 09:16:12,049 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
2024-03-13 09:17:12,952 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-13 09:17:12,952 - handlers.py[DEBUG]: start: azure-ds/generate_network_config_from_instance_network_metadata: generate_network_config_from_instance_network_metadata
2024-03-13 09:17:12,954 - handlers.py[DEBUG]: finish: azure-ds/generate_network_config_from_instance_network_metadata: SUCCESS: generate_network_config_from_instance_network_metadata
2024-03-13 09:17:12,954 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
sudo cloud-init clean --logs
2024-03-15 13:15:01,608 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-15 13:15:01,608 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config_from_fallback_config: _generate_network_config_from_fallback_config
2024-03-15 13:15:01,609 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config_from_fallback_config: SUCCESS: _generate_network_config_from_fallback_config
2024-03-15 13:15:01,609 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
2024-03-15 13:16:02,540 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config: _generate_network_config
2024-03-15 13:16:02,541 - handlers.py[DEBUG]: start: azure-ds/_generate_network_config_from_fallback_config: _generate_network_config_from_fallback_config
2024-03-15 13:16:02,542 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config_from_fallback_config: SUCCESS: _generate_network_config_from_fallback_config
2024-03-15 13:16:02,542 - handlers.py[DEBUG]: finish: azure-ds/_generate_network_config: SUCCESS: _generate_network_config
Thanks, @Liuwenfan, for reporting this.
I am unable to reproduce your issue. In my end, if apply_network_config
is set to true
, then generate_network_config_from_instance_network_metadata
is executed and if set to false
, then _generate_network_config_from_fallback_config
and that is the expected behavior.
Could you please attach the [logs](sudo cloud-init collect-logs) of one of your instances, without any modification of cloud-init source code, and explain what is the behavior you expect?
Environment is such as:
I need to set apply_network_config to false in config file: /etc/cloud/cloud.cfg, to disable change the way of create network config file(ifcfg-ethx), because when more than one ip in machine metadata,cloud-init in init-local step set other ip to static ip.
I change config first, such as
then reboot virtual machine, I find it is not effect, I can find message from log, this log is added by myself
but I alse can see the config is loaded by program,
I add some debug code in DataSourceAzure.py file
as you see, I want cloud-init generate network config content from _generate_network_config_from_fallback_config function, but the apply_network_config: false is not effect