Updating сanister сontrollers

Changing the controller. I updated the code in the canister with the same account. The update was successful. After trying to change the controller to the IC, it returns an error, even if you try to change it to the original controller (test version).

I assert
1)The my controller is the one that created the canisters.
2)There is a successful update of the code in the canister.
3)The change of the canister controller occurs with an error even if the controller is the creator of the canister

Details below:

*dfx canister --network=ic call ngdpi-laaaa-aaaah-aaosa-cai update_canister_settings '("mlx7d-nlzwm-jsiyr-txxc2-mlgsf-hafo6-73wnd-du4xx-f2tsd-mjtum-pae", "ngdpi-laaaa-aaaah-aaosa-cai")'*
*Error: Failed update call.*
*Caused by: Failed update call.*
*  The Replica returned an error: code 4, message: "Only the controllers of the canister ngdpi-laaaa-aaaah-aaosa-cai can control it.*
*Canister's controllers: mlx7d-nlzwm-jsiyr-txxc2-mlgsf-hafo6-73wnd-du4xx-f2tsd-mjtum-pae*
*Sender's ID: ngdpi-laaaa-aaaah-aaosa-cai"*

As a result, it turns out that the installation of the controller is only at the birth of the canister?

The error message tells you:

Canister's controllers: mlx7d-nlzwm-jsiyr-txxc2-mlgsf-hafo6-73wnd-du4xx-f2tsd-mjtum-pae
Sender's ID: ngdpi-laaaa-aaaah-aaosa-cai

This shows that the identity/entity/principal that makes the call to the management canister (the function call that actually changes the controller) is your canister, not yourself. In other words: your canister tries to update its own controller, which it can’t because you are its controller, not itself. This happens because you are proxying this call through the canister itself.

You have two similar ways to solve this:

  1. Do the controller update yourself using dfx canister --network ic update-settings (use the --help flag to figure out the exact syntax)
  2. Add the canister as its own controller, then it is allowed to make changes to its controllers
1 Like

It worked great with the first option. The second option remained problematic.

1 Like

A canister can be it’s own controller? I wasn’t aware this was possible. Can a canister stop and delete itself then as well?

If a canister is stopped it can’t execute code to delete itself, but I don’t see a reason why it shouldn’t be able to stop itself. Haven’t tried it myself, though :smile: