Azure / azure-libraries-for-net

Azure libraries for .Net
MIT License
377 stars 190 forks source link

[BUG] PowerState sometimes returns `null` #1249

Closed shahzzzam closed 2 years ago

shahzzzam commented 2 years ago

Describe the bug We use the Microsoft.Azure.Management.Compute.Fluent SDK 1.34.0. We use the library to check the PowerState of a VM inside VMSS.

Sometimes, the PowerState property returned from IVirtualMachineScaleSetVM object returns null.

What is the meaning of that? PowerState is an enum containing only following values:

public static readonly PowerState Running;
        //
        // Summary:
        //     Static value PowerState/deallocating for PowerState.
        public static readonly PowerState Deallocating;
        //
        // Summary:
        //     Static value PowerState/deallocated for PowerState.
        public static readonly PowerState Deallocated;
        //
        // Summary:
        //     Static value PowerState/starting for PowerState.
        public static readonly PowerState Starting;
        //
        // Summary:
        //     Static value PowerState/stopped for PowerState.
        public static readonly PowerState Stopped;
        //
        // Summary:
        //     Static value PowerState/stopping for PowerState.
        public static readonly PowerState Stopping;
        //
        // Summary:
        //     Static value PowerState/unknown for PowerState.
        public static readonly PowerState Unknown;

Exception or Stack Trace Add the exception log and stack trace if available

To Reproduce Steps to reproduce the behavior:

Code Snippet Add the code snippet that causes the issue.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

Additional context Add any other context about the problem here.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

weidongxu-microsoft commented 2 years ago

@shahzzzam

I think compute service stated in a previous issue that this is caused that service cannot determine the state at this particular time of the request.

My suggestion is either check in some later time, or kind of assume that VM instance works (until next check).

shahzzzam commented 2 years ago

What about calling RefreshInstanceView() on the VM. Will that update the state? I also see the state Unknown and I am wondering whats the difference between null and Unknown.

weidongxu-microsoft commented 2 years ago

@shahzzzam I am not exactly sure. I will loop in service for answer.

ghost commented 2 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @avirishuv.

Issue Details
**Describe the bug** We use the `Microsoft.Azure.Management.Compute.Fluent` SDK 1.34.0. We use the library to check the PowerState of a VM inside VMSS. Sometimes, the `PowerState` property returned from `IVirtualMachineScaleSetVM` object returns `null`. What is the meaning of that? PowerState is an enum containing only following values: ``` public static readonly PowerState Running; // // Summary: // Static value PowerState/deallocating for PowerState. public static readonly PowerState Deallocating; // // Summary: // Static value PowerState/deallocated for PowerState. public static readonly PowerState Deallocated; // // Summary: // Static value PowerState/starting for PowerState. public static readonly PowerState Starting; // // Summary: // Static value PowerState/stopped for PowerState. public static readonly PowerState Stopped; // // Summary: // Static value PowerState/stopping for PowerState. public static readonly PowerState Stopping; // // Summary: // Static value PowerState/unknown for PowerState. public static readonly PowerState Unknown; ``` ***Exception or Stack Trace*** Add the exception log and stack trace if available **To Reproduce** Steps to reproduce the behavior: ***Code Snippet*** Add the code snippet that causes the issue. **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Setup (please complete the following information):** - OS: [e.g. iOS] - IDE : [e.g. IntelliJ] - Version of the Library used **Additional context** Add any other context about the problem here. **Information Checklist** Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report - [ ] Bug Description Added - [ ] Repro Steps Added - [ ] Setup information Added
Author: shahzzzam
Assignees: -
Labels: `Compute - VM`, `Service Attention`
Milestone: -
amjads1 commented 2 years ago

@avirishuv Could you please look into the issue?

avirishuv commented 2 years ago

hi @shahzzzam the power state of VMs can sometimes fail to be retrieved as mentioned in this issue https://github.com/Azure/azure-powershell/issues/13178 Please let us know if that helps. Happy to answer any additional questions.

avirishuv commented 2 years ago

@shahzzzam Are there any additional questions on this topic? If not, can we close the issue?