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

Adaption of scenario scripts for 1-node clusters #534

Open
GeriOnline opened this issue Dec 5, 2022 · 7 comments
Open

Adaption of scenario scripts for 1-node clusters #534

GeriOnline opened this issue Dec 5, 2022 · 7 comments

Comments

@GeriOnline
Copy link

GeriOnline commented Dec 5, 2022

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.

@jaromirk
Copy link
Collaborator

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

@GeriOnline
Copy link
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.

@jaromirk
Copy link
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 :)

@GeriOnline
Copy link
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.

@GeriOnline
Copy link
Author

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

@jaromirk
Copy link
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!

@Karl-WE
Copy link
Contributor

Karl-WE commented Oct 6, 2024

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants