https://pulumi.com logo
Title
h

happy-ability-61825

06/14/2021, 3:12 PM
I am trying to update an Azure ACI container group and I am getting the following error:
azure-native:containerinstance:ContainerGroup (spl-outputs):
error: Code="InvalidContainerGroupUpdate" Message="The updates on container group 'spl-outputs' are invalid. If you are going to update the os type, restart policy, network profile, CPU, memory or GPU resources for a container group, you must delete it first and then create a new one."
I updated the ContainerGroup definition to include
opts=pulumi.ResourceOptions(delete_before_replace=True)
(as per https://www.pulumi.com/docs/intro/concepts/resources/#deletebeforereplace) but it doesn't seem to have any effect
b

billowy-army-68599

06/14/2021, 3:14 PM
can you share your code?
h

happy-ability-61825

06/14/2021, 3:15 PM
container_group = azure_native.containerinstance.ContainerGroup(
    f"spl-outputs",
    tags=config.require_object("tags"),
    container_group_name=f"spl-outputs",
    containers=[
        azure_native.containerinstance.ContainerArgs(
            command=[],
            environment_variables=[
                azure_native.containerinstance.EnvironmentVariableArgs(
                    name="AZURE_STORAGE_CONNECTION_STRING",
                    secure_value=config.require_secret("azureStorageConnectionString"),
                ),
                azure_native.containerinstance.EnvironmentVariableArgs(
                    name="API_BASE_URL",
                    secure_value=config.require("apiBaseUrl"),
                ),
            ],
            image=config.require("image"),
            name="spl-output",
            ports=[
                azure_native.containerinstance.ContainerPortArgs(
                    port=80,
                )
            ],
            resources=azure_native.containerinstance.ResourceRequirementsArgs(
                requests=azure_native.containerinstance.ResourceRequestsArgs(
                    cpu=1,
                    memory_in_gb=2,
                ),
            ),
        ),
        azure_native.containerinstance.ContainerArgs(
            command=["python demographics_scheduler.py"],
            image=config.require("image"),
            name="demographics",
            resources=azure_native.containerinstance.ResourceRequirementsArgs(
                requests=azure_native.containerinstance.ResourceRequestsArgs(
                    cpu=0.2,
                    memory_in_gb=0.5,
                ),
            ),
        ),
    ],
    image_registry_credentials=[
        azure_native.containerinstance.ImageRegistryCredentialArgs(
            server=config.require("imageRegistryServer"),
            username=config.require_secret("imageRegistryUsername"),
            password=config.require_secret("imageRegistryPassword"),
        )
    ],
    ip_address=azure_native.containerinstance.IpAddressArgs(
        ports=[
            azure_native.containerinstance.PortArgs(
                port=80,
                protocol="TCP",
            )
        ],
        type="Private",
    ),
    location=config.require("location"),
    network_profile=azure_native.containerinstance.ContainerGroupNetworkProfileArgs(
        id=network_profile.id,
    ),
    os_type="Linux",
    resource_group_name=resource_group.name.apply(lambda x: x),
    opts=pulumi.ResourceOptions(delete_before_replace=True),
)
if I manually delete the container group before running this, it works fine. But if I try to update one which already exists then it throws the aforementioned error
b

billowy-army-68599

06/14/2021, 3:18 PM
I see you're setting the name explicitly:
container_group_name=f"spl-outputs"
which is probably related
is there a reason you're doing that? it seems the upstream API is allowing an update method but the APi doesn't like it
h

happy-ability-61825

06/14/2021, 3:20 PM
is it bad practice to set the container name explicitly? The name needs to be known ahead of time for later steps in CI/CD and other services
b

billowy-army-68599

06/14/2021, 3:21 PM
it's not bad practice per-se, it just creates these kind of issues with some upstream APIs
can you open an issue for this, it may be an edge case
h

happy-ability-61825

06/14/2021, 3:32 PM
t

tall-librarian-49374

06/14/2021, 4:22 PM
I commented in the issue. The explicit name isn’t related I think.