Changes in tonight's nightly

TLDR: It’d be great if you could test your dashboards as I’ve found some issues with session state that required some work and I want to make sure everything is solid.

As always you can download the latest nightly using this script: https://github.com/ironmansoftware/universal-dashboard/blob/master/tools/install-nightly.ps1

Explanation:

After some discussion on some other threads (primarily this one: Collection was modified; enumeration operation may not execute) as well as a couple of issues around session and cache, I’ve identified a pretty gnarly issue that was causing sessions to stomp on each other, endpoints to not be cleaned up properly and various other issues that would cause strange things to happen.

I’ve made a couple of fixes that everyone should be aware of and if you have the opportunity, it would be great if you could run a test of the latest nightly against your dashboard.

Connection IDs are tied to session IDs

Connection IDs (SignalR) are tied to session IDs such that when you call something like Set-UDElement or Show-UDModal, the session ID will be used to locate the Connection ID and then an event will be sent. This works great until you have 2 windows open. The first window will stop functioning and the second one may receive events from the first. Ew.

I’ve resolved this by tying multiple connection IDs to the same session ID. Now your events should end up in the correct window.

Session Clean up after a window is closed

There is no way in ASP.NET Core to determine when a session has expired from the server. There is a cookie on the client with a life-time but no way to check to see if a particular session has expired from the server end. To combat this, UD was supposed to be cleaning up sessions after the window was closed. Cleaning up sessions meant getting rid of Endpoints generated during the session and any variables that were set.

This wasn’t happening at all. This meant that every time you open a new window and you used any dynamic endpoints within dynamic endpoints or $Session scope variables, they would live forever. This is painfully obvious on long-running dashboards that eventually max out CPU and run out of memory.

I fixed this by correctly cleaning up after the last window is closed.

Global Cache

The global cache was a ASP.NET MemoryCache that contained anything you put in the $Cache scope. No cache management was applied to these entries so they would live forever. This isn’t a huge deal unless you are heavily using auto-generated variable names or super large data sets but it was still really tricky to clear out the cache.

I’ve introduced a new Clear-UDCache cmdlet that will do just that. If there is ever a time you want to clear that cache (maybe once a night or something), you can now do so at your convenience.

3 Likes

something is weird on my dashboard then it come down to usage of $session.
but it’s used in a place where I try to handle cookies, and that have always been funky.
I will try see if I can find some smoking gun.

Cool. Thanks for letting me know! If you can give a good example of how to reproduce the weirdness…that would be awesome.

Hey Adam - Just loading up last nights build and testing out the Cache and Session Variables - I will load it up in an Azure Web app and throw some load at it and ill keep an eye on the performance over the next day.

thanks again for all your efforts!

Great! Thank you! I’m feeling pretty good about the changes but every time I release something I realize everyone is using UD different than I thought. :wink:

okey it seems that sessions are not working at all:

no matter what I do, a F5 will have a total blank session’s.
are im doing it wrong?

this is ofcause with the nightly build, and browser is Edge Dev

Thanks! I will give this a shot.

@adam

looks like Clear-UDCache has not been added to the project cmdlts New-UDModuleManifest.ps1 file.

unfortunately i am getting it bigger than before :rofl::rofl::rofl::rofl:

god help you Adam i wish i can help

Can you get a log for me, please? Glad I posted about this before releasing anything :wink:

1 Like

How can I test the nightly version if I am running the premium version? I tried to use the script @adam mentions in the top of this post, but it installs the community edition.

Hello @guy they are here:-
Enterprise: https://github.com/ironmansoftware/universal-dashboard-enterprise/releases

You the man! Thanks!

1 Like

Logs sent privately.

Discovered another issue with session variables,

in my first page i am getting the username to $Session:CurrentUserName and the privilege to $Session:Privilege then i forward this to the next page which uses them as an input for another function to get the servers for the users and loop through to get he vlan location that doesn’t work but if i directly input the variables (not $Session:) it works

so Multiple session variables from the first page to function in the second page doesn’t work and the CPU and Ram Booooms to the sky

to simulate the issue

@alaaelmahdy

It will be difficult to address your issue without a code to analyze, i recommend that you create a new limited dashboard with 2 pages for example and have a piece of your code posted there so we can test on our end like having one or two variables on one page and expected results on the second page.

this way we can identify the issue and if its a bug, Adam will be able to address it.

Regards.

you are totally right initially i actually shared the code with Adam in a private message before , and will clean up and post it but it need some time as i wrote it for internal use with lots of names, locations ips , hints and it’s based on SQL so i am doing a new copy of the database and will post it along with the code soon.

upon your request the code is published to https://github.com/alaaelmahdy/ServersMgmt

The Non working parts which produce high CPU and Ram Utilization are:

$Vlan_All = New-UDRow -Endpoint {
	$Servers = Update-Servers $Session:LoggedInUser
	$VlanLocations = Update-VlanLocations $Session:LoggedInUser
	$vlans = $Servers.Vlan | select -Unique
	ForEach ($vlan in $vlans)
	{
		$vlanLocation = ($VlanLocations | where{ $_.Vlan -eq $vlan }).VlanLocation
		New-UDColumn -LargeSize 12 -Content {
			New-UDCard -Title "$vlan Servers" -Content {
				New-UDGrid -Id "$($vlan)_AGrid" -Title "Vlan Description: $vlanLocation" -DefaultSortColumn "Asset_ID" -PageSize 100 -FilterText "Enter any thing to search for" -Headers ("Asset ID", "Name", "IP Address", "Operating System", "Owner", "Backup State") -Properties ("Asset_ID", "Name", "IPAddress", "OperatingSystem", "Owner", "Backup") -Endpoint {
					$Servers | where { $_.Vlan -eq $vlan } | Out-UDGridData
				}
			}
		}
	}
}
$VLan_Tower2 = New-UDRow -Endpoint {
	$Servers = Update-Servers $Session:LoggedInUser
	$VlanLocations = Update-VlanLocations $Session:LoggedInUser
	$HFilter = $Servers | ?{ $_.location -eq "Tower2 Datacenter" }
	$vlans = $HFilter.Vlan | select -Unique
	ForEach ($vlan in $vlans)
	{
		$vlanLocation = ($VlanLocations | where{ $_.Vlan -eq $vlan }).VlanLocation
		New-UDColumn -LargeSize 12 -Content {
			New-UDCard -Title "$vlan Servers" -Content {
				New-UDGrid -Id "$($vlan)_HGrid" -Title "Vlan Description: $vlanLocation" -DefaultSortColumn "Asset_ID" -PageSize 100 -FilterText "Enter any thing to search for" -Headers ("Asset ID", "Name", "IP Address", "Operating System", "Owner", "Backup State") -Properties ("Asset_ID", "Name", "IPAddress", "OperatingSystem", "Owner", "Backup") -Endpoint {
					$Servers | where { $_.Vlan -eq $vlan -and $_.location -eq "Tower2 Datacenter" } | Out-UDGridData
				}
			}
		}
	}
}
$VLan_Tower1 = New-UDRow -Endpoint {
	$Servers = Update-Servers $Session:LoggedInUser
	$FFilter = $Servers | ?{ $_.location -eq "Tower1 Datacenter" }
	$vlans = $FFilter.Vlan | select -Unique
	ForEach ($vlan in $vlans)
	{
		New-UDColumn -LargeSize 12 -Content {
			New-UDCard -Title "$vlan Servers" -Content {
				New-UDGrid -Id "$($vlan)_FGrid" -Title "" -DefaultSortColumn "Asset_ID" -PageSize 100 -FilterText "Enter any thing to search for" -Headers ("Asset ID", "Name", "IP Address", "Operating System", "Owner", "Backup State") -Properties ("Asset_ID", "Name", "IPAddress", "OperatingSystem", "Owner", "Backup") -Endpoint {
					$Servers | where { $_.Vlan -eq $vlan -and $_.location -eq "Tower1 Datacenter" } | Out-UDGridData
				}
			}
		}
	}
}
$VLan_Tower3 = New-UDRow -Endpoint {
	$Servers = Update-Servers $Session:LoggedInUser
	$JFilter = $Servers | ?{ $_.location -eq "Tower3 Datacenter" }
	$vlans = $JFilter.Vlan | select -Unique
	ForEach ($vlan in $vlans)
	{
		New-UDColumn -LargeSize 12 -Content {
			New-UDCard -Title "$vlan Servers" -Content {
				New-UDGrid -Id "$($vlan)_JGrid" -Title "" -DefaultSortColumn "Asset_ID" -PageSize 100 -FilterText "Enter any thing to search for" -Headers ("Asset ID", "Name", "IP Address", "Operating System", "Owner", "Backup State") -Properties ("Asset_ID", "Name", "IPAddress", "OperatingSystem", "Owner", "Backup") -Endpoint {
					$Servers | where { $_.Vlan -eq $vlan -and $_.location -eq "Tower3 Datacenter" } | Out-UDGridData
				}
			}
		}
	}
}
$VLans_Table = New-UDRow -Endpoint {
	$Servers = Update-Servers $Session:LoggedInUser
	$VlanLocations = Update-VlanLocations $Session:LoggedInUser
	$vlocs = $VlanLocations.type | where { $_ -ne "-" } | select -Unique
	ForEach ($vloc in $vlocs)
	{
		New-UDColumn -LargeSize 12 -Content {
			New-UDCard -Title "$vloc Networks" -Content {
				New-UDGrid -Id "$($vloc)_vlGrid" -Title "" -DefaultSortColumn "vlan" -PageSize 100 -FilterText "Enter any thing to search for" -Headers ("Vlan Location", "Start IP", "End IP", "VLAN IP", "GateWay") -Properties ("VlanLocation", "Realstart", "Realend", "Vlan", "GateWay") -Endpoint {
					$VlanLocations | where { $_.type -eq $vloc } | Out-UDGridData
				}
			}
		}
	}
}

@adam about that session variable that is having it’s only life,
image
this is a browser window, just open, why is it changing/adding new connections Id’s ?
ok, so it’s the server that are sending that over the websocket.
is connection ID leaking between users? or am I reading this the wrong way?

Update: new nightly dont fix it.
I were working locally, but again, I guess because im the only one on it :slight_smile:
I still get multiply connectionId from the “published” dashboard.