Skip to content

feat: extend dfx canister update-settings to support --sync-with - #4378

Merged
vincent-dfinity merged 7 commits into
masterfrom
vincent/SDK-2045
Sep 9, 2025
Merged

vincent-dfinity merged 7 commits into
masterfrom
vincent/SDK-2045

Conversation

@vincent-dfinity

@vincent-dfinity vincent-dfinity commented Sep 8, 2025 •

Copy link
Copy Markdown
Contributor

Description

Extend dfx canister update-settings to support --sync-with, an example as below

dfx canister update-settings to_canister --sync-with from_canister
  • without --yes, the command will output the from_canister settings and ask for consent as below
    $ dfx canister update-settings to_canister --sync-with from_canister
    Canister settings: from_canister
    Controllers: uom2z-lqsqq-qbn4p-nts4l-2xjfl-oeivu-oso42-4t4jh-54ikd-ewnvi-tqe uqqxf-5h777-77774-qaaaa-cai
    Memory allocation: 0 Bytes
    Compute allocation: 1 %
    Freezing threshold: 2_592_000 Seconds
    Reserved cycles limit: 8_000_000_000_000 Cycles
    Wasm memory limit: 3_221_225_472 Bytes
    Wasm memory threshold: 0 Bytes
    Log visibility: controllers
    
    WARNING!
    You are trying to sync settings from 'from_canister' to 'to_canister'.
    Do you want to proceed? yes/No
    yes
    Synced settings from 'from_canister' to 'to_canister'.
    
  • with --yes, it won't ask for consent and start syncing immediately.

Fixes # (issue)

SDK-2045

How Has This Been Tested?

Added a new e2e test.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@mraszyk mraszyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Leaving a few notes:

  • Let's make sure that environment variables are added to this new flow once they are enabled in production.
  • Let's maybe print a warning if the user is not a controller after the sync, e.g., if the user tried to sync settings of a black-holed canister.

@vincent-dfinity

vincent-dfinity commented Sep 8, 2025 •

Copy link
Copy Markdown
Contributor Author

Looks good to me! Leaving a few notes:

  • Let's make sure that environment variables are added to this new flow once they are enabled in production.
  • Let's maybe print a warning if the user is not a controller after the sync, e.g., if the user tried to sync settings of a black-holed canister.

environment variables

Could you please provide more info on this?
Ah, I see. dfinity/cdk-rs#636.
Once it's enabled in production, we can do a follow-up pr to support the canister environment variables. Sounds good to you?

Let's maybe print a warning

The function will output error messages like below

$ dfx canister update-settings to_canister --sync-with from_canister --identity not-controller
Error: Each canister has a set of controllers. Only those controllers have access to the canister's management functions (like install_code or stop_canister).
The principal you are using to call a management function is not part of the controllers.
To fix: To make the management function call succeed, you have to make sure the principal that calls the function is a controller.
...

@vincent-dfinity
vincent-dfinity marked this pull request as ready for review September 8, 2025 12:48
@vincent-dfinity
vincent-dfinity requested a review from a team as a code owner September 8, 2025 12:48
Comment thread src/dfx/src/commands/canister/update_settings.rs
@vincent-dfinity
vincent-dfinity merged commit 744bfbe into master Sep 9, 2025
314 of 320 checks passed
@vincent-dfinity
vincent-dfinity deleted the vincent/SDK-2045 branch September 9, 2025 02:34
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

Successfully merging this pull request may close these issues.

3 participants