Skip to content

fix(storage pool): rely on operation when api extension is present#1899

Draft
kimanhou wants to merge 1 commit intocanonical:mainfrom
kimanhou:async-storage-pool-endpoints
Draft

fix(storage pool): rely on operation when api extension is present#1899
kimanhou wants to merge 1 commit intocanonical:mainfrom
kimanhou:async-storage-pool-endpoints

Conversation

@kimanhou
Copy link
Copy Markdown
Contributor

@kimanhou kimanhou commented Mar 25, 2026

Done

  • fix(storage pool): rely on operation when api extension storage_and_network_operations is present
  • Affected methods: createPool, updatePool, updateClusteredPool, renameStoragePool and deleteStoragePool.

Follow up of canonical/lxd#17955

QA

  1. Run the LXD-UI:
  2. Perform the following QA steps and for each step, make sure the action is performed successfully and that 2 notifications (started and success) are displayed correctly:
    • Create pool
    • Create pool in a cluster
    • Update pool
    • Update clustered pool
    • Rename pool
    • Delete pool

Screenshots

image

@webteam-app
Copy link
Copy Markdown

Comment on lines 151 to 178
export const createClusteredPool = async (
pool: LxdStoragePool,
clusterMembers: LxdClusterMember[],
sourcePerClusterMember?: ClusterSpecificValues,
zfsPoolNamePerClusterMember?: ClusterSpecificValues,
sizePerClusterMember?: ClusterSpecificValues,
): Promise<void> => {
): Promise<LxdOperationResponse> => {
const { memberPoolPayload, clusterPoolPayload } =
getClusterAndMemberPoolPayload(pool);
return Promise.allSettled(
clusterMembers.map(async (item) => {
const clusteredMemberPool = {
...memberPoolPayload,
config: {
...memberPoolPayload.config,
source: sourcePerClusterMember?.[item.server_name],
size: sizePerClusterMember?.[item.server_name],
"zfs.pool_name": zfsPoolNamePerClusterMember?.[item.server_name],
},
};
return createPool(clusteredMemberPool, item.server_name);
}),
)
.then(handleSettledResult)
.then(async () => {
return createPool(clusterPoolPayload);
});
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is way harder with the extension. Because we have to wait until all operations of the cluster member pools are finished before we do the createPool(clusterPoolPayload) call.

So the createPool(clusterPoolPayload) call has to await all operations for each cluster member to finish.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah 😬

Copy link
Copy Markdown
Contributor Author

@kimanhou kimanhou Mar 30, 2026

Choose a reason for hiding this comment

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

I implemented a new waitForOperation function that polls /1.0/operations/{id} endpoint and then the final API call once all operations are in success status.

@kimanhou kimanhou force-pushed the async-storage-pool-endpoints branch from c69fad4 to e43bd5a Compare March 30, 2026 12:18
Signed-off-by: Kim Anh Nguyen <4783194+kimanhou@users.noreply.github.com>
@kimanhou kimanhou force-pushed the async-storage-pool-endpoints branch from e43bd5a to 1a96687 Compare March 30, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants