Skip to content

Adaption of scenario scripts for 1-node clusters #534

Open

Description

@GeriOnline

As Microsoft now supports 1-node clusters for AZSHCI and WS2022, I experimented a bit with the cluster scenario scripts for 1-node environments. I got various errors about non-existent host names.

Reason: Most scenario scripts initially define a variable for the names of the cluster nodes and implicitly assume that this results in a PowerShell array (e.g. $servers = "...", "..."). This works if you assign more than one hostname. However, if only 1 hostname is specified, PowerShell only creates a string variable - i.e. no array. If later the script references a single element (e.g. $server[0]), the result is an invalid hostname.

The remedy is simple: The variable for the host names should be set explicitly as an array type (e.g. [array] $servers="...").

However, this would mean that most of the scenario scripts would have to be adjusted and re-released. I would therefore suggest that an appropriate note be included in the MSLab readme page and the adjustments made in the scenario scripts when they are released as such.

Activity

  1. jaromirk commented on Dec 13, 2022

    @jaromirk
    Collaborator

    Okok. It's easy - you just skip smb nics creation. Everything else is same.

  2. GeriOnline commented on Dec 16, 2022

    @GeriOnline
    Author

    I have the impression that we are talking about different things. I mean the array with the server names at the beginning of the different scenario scripts. As an example, let's take a look at the scenario.ps1 script of the AzSHCI deployment scenario:

    With
    line 7: $numberofnodes=4
    and
    line 10: $Servers=1..$numberofnodes | ForEach-Object {"$ServersNamePrefix$"}

    $servers results in an array with 4 strings:

    $servers.GetType()
    IsPublic IsSerial Name BaseType
    True True Object[] System.Array

    $Servers
    AzSHCI1
    AzSHCI2
    AzSHCI3
    AzSHCI4

    Now for 1-node clusters you have to change line 7 to
    line 7: $numberofnodes=1
    and now $servers results in a simple string:

    $Servers.GetType()
    IsPublic IsSerial Name BaseType
    True True String System.Object

    Later on in the script if $Servers[0] is referenced (e.g. in line 190) only the first char of the server name is retrieved:

    $Servers[0]
    A

    which of course leads to various runtime errors.

    The correction is very easy: Simply change line 10 to
    [array]$Servers=1..$numberofnodes | ForEach-Object {"$ServersNamePrefix$"}_

    and everything works like it should independent of the value of $numberofnodes in line 7.

    I hope with that I have presented my request a little bit better.

  3. jaromirk commented on Dec 16, 2022

    @jaromirk
    Collaborator

    Ah, got it! With one server you can simply say $servers="AzSHCI1". I kept this array to make things simpler when you deal with 16 node clusters :)

  4. GeriOnline commented on Dec 16, 2022

    @GeriOnline
    Author

    $servers="AzSHCI1" does not solve the problem. You have to write [array] $servers="AzSHCI1" - then it would work.
    It's a special PowerShell feature that if only one string is assigned only a string var is allocated. So you have always to use strong type definitions for such situations.

  5. GeriOnline commented on Dec 16, 2022

    @GeriOnline
    Author

    Another way with hard coded server names would be to write
    $servers=,"AzSHCI1"
    for single nodes (another trick of PowerShell)

  6. jaromirk commented on Dec 16, 2022

    @jaromirk
    Collaborator

    Ah, you are ofc right. Okok, I'll fix it! I hope you enjoy this stuff. Check out 22H2 scenario (in dev) . It's lot of fun!

  7. Karl-WE commented on Oct 6, 2024

    @Karl-WE
    Contributor

    Jaromir Kaspar (@jaromirk) friendly reminder, is this code change implemented yet? might get lost.
    would still affect S2D and Azure Stack HCI as it is a syntax problem, as I understood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions