You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adaption of scenario scripts for 1-node clusters #534
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.
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.
$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.
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.
Activity
jaromirk commentedon Dec 13, 2022
Okok. It's easy - you just skip smb nics creation. Everything else is same.
GeriOnline commentedon Dec 16, 2022
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.
jaromirk commentedon Dec 16, 2022
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 :)
GeriOnline commentedon Dec 16, 2022
$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.
GeriOnline commentedon Dec 16, 2022
Another way with hard coded server names would be to write
$servers=,"AzSHCI1"
for single nodes (another trick of PowerShell)
jaromirk commentedon Dec 16, 2022
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!
Karl-WE commentedon Oct 6, 2024
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.