Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way doing a "one-shot" vm creation without doing any polling? #1910

Closed
stipx opened this issue Sep 20, 2017 · 11 comments
Closed
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt - Track 2 Mgmt This issue is related to a management-plane library.
Milestone

Comments

@stipx
Copy link

stipx commented Sep 20, 2017

Hi,

basically we want to achieve a task queue which only creates the machine and does not do the polling directly.

So our workflow is:

  • Create a VM -> store the ID
  • Request the VM state with the ID after 5 minutes with a task which is put into a task queue
  • If not yet finished just enqueue a new task which might run after 5 minutes if there is nothing else in the queue

Also: Is it possible to just create the VM and directly attach a extension without waiting for it to be finally created.

My concern is: We have a microservice which does the azure provisioning and it is container based. So it might be redeployed several times. When the polling is done in one JVM it might get interrupted when the azure handling microservice gets killed. I mean there is a grace period until the JVM exits, but I dont want it to be 20 minutes or more.

Maybe someone has an idea how to achieve something like this with the java sdk.
The REST api (which is used here anyway) supports sending just one PUT http call to create a VM, but as far as I can see there is no way to do such "one-shot" action with the sdk.

Thanks
stipx

@martinsawicki
Copy link

it's something we've been thinking about - a generalized approach for this nature of operations is needed an d is under investigation. Parking on @anuchandy .

@martinsawicki martinsawicki added this to the Backlog milestone Nov 14, 2017
@praries880 praries880 added the Mgmt This issue is related to a management-plane library. label Nov 14, 2018
@anuchandy anuchandy assigned yaohaizh and unassigned anuchandy Feb 19, 2020
@anuchandy
Copy link
Member

This should be addressed in new track2 lite SDK with new Poller, where customers can initiate the LRO, take(1) and unsubscribe, which does not make any more network calls.

Assigning this to new owner @yaohaizh to update the issue when the work is done.

@yaohaizh
Copy link
Contributor

Thanks, @anuchandy.

@yungezz yungezz added the feature-request This issue requires a new behavior in the product in order be resolved. label Mar 26, 2020
@yungezz yungezz added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Apr 17, 2020
@yungezz
Copy link
Member

yungezz commented Jul 2, 2020

part of this is beginCreate work @weidongxu-microsoft is working on

@weidongxu-microsoft weidongxu-microsoft added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Jul 13, 2021
@ghost
Copy link

ghost commented Jul 13, 2021

Hi @stipx. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost
Copy link

ghost commented Jul 20, 2021

Hi @stipx, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Jul 20, 2021
azure-sdk pushed a commit that referenced this issue Aug 16, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 17, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 18, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk pushed a commit that referenced this issue Aug 18, 2021
Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.
azure-sdk added a commit that referenced this issue Aug 18, 2021
* Attempt to purge all vaults, managed HSMs

Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.

* Add timeout and more logging

* Pass required -Resource

* Fix log message

* Ensure the $Resource is correctly captured

Added comment to new code explaining why, since ScriptBlock.GetNewClosure() is not working as expected.

* Add -ErrorAction to Receive-Job

Worked without terminating when run locally, but failed on the first error in the AzDO agent.

* Use $using:r instead of creating ScriptBlock

More idiomatic for passing ScriptBlocks to jobs.

* Resolve PR feedback

* Change default DeleteAfterHours to 120

Resolves #1917

* Use the Az cmdlets built-in -AsJob

Co-authored-by: Heath Stewart <heaths@microsoft.com>
@fkorotkov
Copy link

I'm trying to use the beginCreate method but getting "postRunDependent is not supported" exception with not much of useful information. If I use just create() or createAsync() everything seems work just fine. Here is the related stacktrace:

 java.lang.IllegalStateException: postRunDependent is not supported
	at com.azure.resourcemanager.resources.fluentcore.dag.TaskGroup.lambda$invokeDependencyAsync$2(TaskGroup.java:300)
	at reactor.core.publisher.FluxDefer.subscribe(FluxDefer.java:46)
	at reactor.core.publisher.Flux.subscribe(Flux.java:8468)
	at reactor.core.publisher.Flux.blockLast(Flux.java:2643)
	at com.azure.resourcemanager.compute.implementation.VirtualMachineImpl.lambda$beginCreate$12(VirtualMachineImpl.java:1895)
	at com.azure.resourcemanager.resources.fluentcore.model.implementation.AcceptedImpl.newAccepted(AcceptedImpl.java:414)
	at com.azure.resourcemanager.compute.implementation.VirtualMachineImpl.beginCreate(VirtualMachineImpl.java:1872)

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Jan 29, 2022

@fkorotkov

Sorry for the obscure message (we will improve it in next version). It usually means that certain operation in your VM configure code is required to be done after VM creation (to my memory, maybe VM extension?), hence the "post run dependent".
These operation is handled by create call, as it poll until VM created, then do that operation.

But if via beginCreate call, since it does not poll (or depends on user to poll), it will not know when VM creation is completed, hence it is not able to do this follow up operation.

You can e.g. use beginCreate to create the VM (without extension), then when you sure VM is provided, call update to it to add e.g. VM extension.

If you think your use case does not (or should not) involve such "operation after VM created", would you show us your code?

PS: we might have later response as we are going to have week long holiday here.

@fkorotkov
Copy link

fkorotkov commented Jan 29, 2022

@weidongxu-microsoft thank you for the response! I was kind of lost in debugging the issue and just posted here.

Indeed I have a Custom Script Execution attached to the VM that I'm trying to create. In my case I was looking to an option to do a "one-shot" VM creation with a custom script that will bootstrap the VM.

For context, I'm working on adding support for Azure VMs to Cirrus CI cirruslabs/cirrus-ci-docs#953. We already support Azure Container Instances which has handy withStartingCommandLine method. And most other cloud providers allow to specify "startup scripts" at the moment of VM creation. Seems as you suggested I'll need to do two "one-shot" calls:

  1. Create VM with beginCreate.
  2. Wait for the VM creation.
  3. Update the extension to run a script. Or run a command.

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Jan 30, 2022

@fkorotkov

I am not sure about the exact requirement of "one-shot". If you just call createAsync().toFuture(), does it count as "one-shot" (most of the case, user does not care about the polling requests)?
If you call beginCreate and forget about it, how to you know whether the VM creation is successful or not?

For VM extension, from what I know it had to be done after VM creation.

    "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'),copyindex())]",
        "[variables('musicstoresqlName')]"
    ],

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt - Track 2 Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

No branches or pull requests

8 participants