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

backend: Add websocket multiplexer #2459

Merged
merged 1 commit into from
Oct 24, 2024
Merged

backend: Add websocket multiplexer #2459

merged 1 commit into from
Oct 24, 2024

Conversation

knrt10
Copy link
Contributor

@knrt10 knrt10 commented Oct 22, 2024

This adds websocket multiplexer to the backend. Frontend now need to make a single websocket call to the backend. Once that connection is established with the backend it will send message to the backend with appropriate data. Backend will open multiple websockets and act as a proxy to the frontend. It will make request to k8s server and return data to frontend.

This also adds retry logic if the connection is broken between frontend and backend.

Fixes: #1802

Testing

  • Run backend cd backend && go run ./cmd -dev -enable-dynamic-clusters
  • Run frontend cd frontend && npm start (we need this for userID of the session).
  • Open postman application and use the API here
  • It has message payload which you need to edit
{
  "clusterID": "minikube", // update it with the cluster you have running
  "path": "/api/v1/pods",
  "query": "watch=true",
  "userId": "9872e4f36eaadb0e" // go to localstorage and copy `headlamp-userID` and paste here
}
  • Click on the Connect button
Screenshot 2024-10-22 at 2 08 34 PM
  • Once connected hit the send button.
Screenshot 2024-10-22 at 2 09 41 PM
  • You will see response from your k8s cluster
Screenshot 2024-10-24 at 12 42 28 PM
  • Create an nginx pod kubectl run nginx --image=nginx and try other things like logs and exec

Logs

{
  "clusterID": "minikube",
  "path": "/api/v1/namespaces/default/pods/nginx/log",
  "query": "follow=true&tailLines=100",
  "userId": "9872e4f36eaadb0e"
}
Screenshot 2024-10-24 at 12 45 18 PM

Exec

{
  "clusterID": "minikube",
  "path": "/api/v1/namespaces/default/pods/nginx/exec",
  "query": "command=ls&command=-l&stdout=true&stderr=true",
  "userId": "9872e4f36eaadb0e"
}
Screenshot 2024-10-24 at 12 43 45 PM

The data is sent as binary and it is encoded to bas64 to parse as JSON response.

Close connection

{
  "clusterID": "minikube",
  "path": "/api/v1/pods",
  "userId": "9872e4f36eaadb0e",
  "data": "close"
}
Screenshot 2024-10-24 at 12 40 07 PM

You can edit path as per your needs and check different output.

@knrt10 knrt10 requested a review from a team October 22, 2024 08:41
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Oct 22, 2024
Copy link

Backend Code coverage changed from 61.6% to 61.6%. Change: 0% 😃.

Coverage report
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:91:			ServeHTTP				58.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:140:			fileExists				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:150:			copyReplace				63.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:174:			baseURLReplace				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:202:			getOidcCallbackURL			91.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:229:			serveWithNoCacheHeader			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:238:			defaultKubeConfigPersistenceDir		61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:266:			defaultKubeConfigPersistenceFile	75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:279:			addPluginRoutes				54.2%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:327:			createHeadlampHandler			40.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:694:			parseClusterAndToken			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:711:			decodePayload				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:725:			getExpiryTime				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:734:			isTokenAboutToExpire			61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:758:			refreshAndCacheNewToken			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:828:			OIDCTokenRefreshMiddleware		30.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:879:			StartHeadlampServer			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:893:			getHelmHandler				53.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:921:			checkHeadlampBackendToken		100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:934:			handleClusterHelm			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1013:			handleClusterAPI			51.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1069:			handleClusterRequests			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1077:			getClusters				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1120:			parseCustomNameClusters			38.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1174:			parseClusterFromKubeConfig		83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1208:			getConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1219:			addCluster				57.9%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1254:			decodeClusterRequest			71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1269:			processClusterRequest			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1278:			processKubeConfig			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1295:			processManualConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1315:			handleLoadErrors			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1330:			writeKubeConfig				70.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1350:			addContextsToStore			80.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1362:			deleteCluster				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1411:			getKubeConfigPath			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1420:			handleStatelessClusterRename		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1434:			customNameToExtenstions			45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1467:			updateCustomContextToCache		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1500:			getPathAndLoadKubeconfig		55.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1523:			renameCluster				53.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1586:			addClusterSetupRoute			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1614:			handleNodeDrain				45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1679:			drainNode				37.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1729:			handleNodeDrainStatus			52.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:74:			handleWebSocketMultiplexer		65.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:120:		handleWebSocketConnection		55.6%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:139:		sendErrorResponse			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:153:		sendWebSocketError			62.5%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:181:		handleMessage				83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:200:		watchResource				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:259:		streamResource				46.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:286:		parseResourcePath			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:324:		getResourceInterface			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:336:		createWatcher				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:346:		streamEvents				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:369:		parseLimit				33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:383:		getClusterConfig			75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:400:		cleanupUnusedConnections		44.4%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:419:		getBackoffDuration			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:427:		secureRandInt63n			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:440:		min					66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/server.go:14:			main					0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:17:			MarshalCustomObject			60.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:42:			setKeyInCache				50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:71:			handleStatelessReq			52.9%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:143:			parseKubeConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:182:			websocketConnContextKey			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:232:			getContextKeyForRequest			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:40:			New					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:52:			Set					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:57:			SetWithTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:75:			Delete					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:85:			Get					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:102:		GetAll					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:122:		cleanUp					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:140:		UpdateTTL				88.9%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:40:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:62:		Parse					74.4%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:149:		flagset					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:174:		defaultPluginDir			61.5%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:207:		GetDefaultKubeConfigPath		66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:27:			listCharts				89.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:77:			ListCharts				72.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:35:		NewActionConfig				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:54:		NewHandler				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:60:		NewHandlerWithSettings			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:85:		ToRESTConfig				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:89:		ToRawKubeConfigLoader			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:93:		ToDiscoveryClient			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:109:		ToRESTMapper				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:129:		getReleaseStatus			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:165:		setReleaseStatus			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:188:		setReleaseStatusSilent			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:53:		getReleases				57.1%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:112:		ListRelease				68.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:158:		GetRelease				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:217:		GetReleaseHistory			46.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:277:		UninstallRelease			55.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:334:		uninstallRelease			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:357:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:362:		RollbackRelease				51.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:421:		rollbackRelease				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:453:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:458:		handleError				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:463:		returnResponse				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:479:		InstallRelease				72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:513:		getChart				35.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:565:		installRelease				60.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:625:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:630:		UpgradeRelease				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:666:		logActionState				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:687:		upgradeRelease				63.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:731:		Validate				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:749:		GetActionStatus				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:35:		createFileIfNotThere			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:47:		lockRepositoryFile			87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:68:		addRepository				61.8%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:131:		AddRepo					72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:176:		createFullPath				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:184:		listRepositories			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:213:		ListRepo				58.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:236:		RemoveRepository			64.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:279:		RemoveRepo				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:291:		UpdateRepository			68.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:333:		UpdateRepository			81.8%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:26:	NewContextStore				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:35:	AddContext				23.1%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:64:	GetContexts				85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:80:	GetContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:90:	RemoveContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:95:	AddContextWithKeyAndTTL			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:100:	UpdateTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:14:		WriteToFile				86.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:48:		RemoveContextFromFile			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:62:	DeepCopyObject				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:67:	DeepCopy				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:87:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:98:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:109:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:120:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:133:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:145:	ClientConfig				80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:179:	RESTConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:189:	OidcConfig				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:207:	ProxyRequest				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:221:	ClientSetWithToken			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:235:	SourceStr				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:249:	SetupProxy				91.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:274:	AuthType				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:292:	LoadContextsFromFile			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:307:	LoadContextsFromBase64String		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:319:	LoadContextsFromMultipleFiles		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:342:	loadContextsFromData			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:376:	UnmarshalKubeconfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:388:	GetContextsFromKubeconfig		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:404:	ProcessContext				90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:453:	extractContextInfo			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:471:	extractClusterAndUserNames		83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:488:	getClusterAndUser			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:509:	createAndValidateConfig			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:541:	getNameOrUnknown			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:552:	HandleConfigLoadError			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:593:	checkBase64Errors			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:616:	checkUserBase64Fields			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:636:	checkClusterBase64Fields		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:652:	toStringKeyMap				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:668:	getCluster				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:686:	getUser					80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:707:	createKubeConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:730:	convertToContext			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:771:	LoadContextsFromAPIConfig		76.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:810:	splitKubeConfigPath			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:820:	GetInClusterContext			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:867:	LoadAndStoreKubeConfigs			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:892:	makeDNSFriendly				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:16:		LoadAndWatchFiles			80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:69:		addFilesToWatcher			82.4%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:29:		Log					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:36:		log					80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:80:		SetLogFunc				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:28:		Watch					77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:49:		periodicallyWatchSubfolders		75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:82:		generateSeparatePluginPaths		90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:103:		GeneratePluginPaths			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:118:		ListPlugins				68.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:171:		pluginBasePathListForDir		77.3%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:219:		HandlePluginEvents			70.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:243:		PopulatePluginsCache			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:269:		HandlePluginReload			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:300:		Delete					85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:315:		isSubdirectory				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:46:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:80:		getFreePort				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:99:		StartPortForward			50.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:173:	startPortForward			61.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:269:	checkIfPodIsRunning			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:291:	Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:304:	StopOrDeletePortForward			47.1%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:336:	GetPortForwards				45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:358:	GetPortForwardByID			45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:16:		portforwardKeyGenerator			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:33:		portforwardstore			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:46:		stopOrDeletePortForward			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:74:		getPortForwardList			77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:94:		getPortForwardByID			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/utils/utils.go:4:			Contains				100.0%
total:										(statements)				61.6%

Html coverage report download

@knrt10 knrt10 added the multi Multi cluster aggregated view label Oct 22, 2024
@sniok
Copy link
Contributor

sniok commented Oct 22, 2024

Nice, tested it and it seems to work

There are a couple of crucial things missing though:

  • The data coming in doesn't contain information about which request it is
  • There's no way to close the request (e.g. stop watching /pods)

@sniok
Copy link
Contributor

sniok commented Oct 22, 2024

Does this support webosocket connections other than watching resources, like attaching to the container? I've tried a path like this /api/v1/namespaces/example-namespace/pods/client-deployment-84f498cf94-xnzsl/attach?container=client-container and it doesn't seem to work

@knrt10
Copy link
Contributor Author

knrt10 commented Oct 22, 2024

Thank you for the feedback @sniok. Awesome suggestions. I did forget to add closing the connection on request. Will add

Regarding attaching, I did not try it. Will check why it’s not working.

@illume
Copy link
Collaborator

illume commented Oct 22, 2024

I think we can delay any work on attaching to the container if there is a problem. Because we mainly want this to help with watching.

@illume
Copy link
Collaborator

illume commented Oct 22, 2024

Backend Code coverage changed from 61.6% to 61.6%. Change: 0% 😃.

Hrmm. Not sure why this is at 0, since there are tests... lol.

@knrt10 knrt10 force-pushed the websocket-multiplexer branch from cf0f799 to 3971e72 Compare October 23, 2024 02:31
@knrt10
Copy link
Contributor Author

knrt10 commented Oct 23, 2024

@sniok @illume updated the code + PR description + postman calls. You can now do all k8s operation. Please try and let me know. Also added the state handling of webhook

Copy link

Backend Code coverage changed from 61.5% to 60.8%. Change: -.7% 😞.

Coverage report
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:92:			ServeHTTP				58.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:141:			fileExists				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:151:			copyReplace				63.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:175:			baseURLReplace				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:203:			getOidcCallbackURL			91.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:230:			serveWithNoCacheHeader			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:239:			defaultKubeConfigPersistenceDir		61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:267:			defaultKubeConfigPersistenceFile	75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:280:			addPluginRoutes				54.2%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:328:			createHeadlampHandler			40.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:695:			parseClusterAndToken			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:712:			decodePayload				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:726:			getExpiryTime				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:735:			isTokenAboutToExpire			61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:759:			refreshAndCacheNewToken			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:829:			OIDCTokenRefreshMiddleware		30.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:880:			StartHeadlampServer			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:894:			getHelmHandler				53.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:922:			checkHeadlampBackendToken		100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:935:			handleClusterHelm			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1014:			handleClusterAPI			51.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1070:			handleClusterRequests			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1078:			getClusters				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1121:			parseCustomNameClusters			38.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1175:			parseClusterFromKubeConfig		83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1209:			getConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1220:			addCluster				57.9%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1255:			decodeClusterRequest			71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1270:			processClusterRequest			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1279:			processKubeConfig			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1296:			processManualConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1316:			handleLoadErrors			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1331:			writeKubeConfig				70.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1351:			addContextsToStore			80.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1363:			deleteCluster				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1412:			getKubeConfigPath			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1421:			handleStatelessClusterRename		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1435:			customNameToExtenstions			45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1468:			updateCustomContextToCache		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1501:			getPathAndLoadKubeconfig		55.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1524:			renameCluster				53.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1587:			addClusterSetupRoute			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1612:			handleNodeDrain				45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1677:			drainNode				37.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1727:			handleNodeDrainStatus			52.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:101:		NewMultiplexer				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:114:		updateStatus				91.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:143:		establishClusterConnection		0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:189:		getClusterConfigWithFallback		100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:206:		createConnection			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:221:		dialWebSocket				50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:249:		monitorConnection			54.5%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:274:		reconnect				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:293:		HandleClientWebSocket			44.4%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:326:		readClientMessage			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:340:		getOrCreateConnection			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:364:		handleConnectionError			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:382:		writeMessageToCluster			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:395:		handleClusterMessages			78.9%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:430:		cleanupConnections			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:447:		getClusterConfig			85.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:462:		createWebSocketURL			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/server.go:14:			main					0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:17:			MarshalCustomObject			60.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:42:			setKeyInCache				50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:71:			handleStatelessReq			52.9%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:143:			parseKubeConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:182:			websocketConnContextKey			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:232:			getContextKeyForRequest			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:40:			New					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:52:			Set					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:57:			SetWithTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:75:			Delete					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:85:			Get					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:102:		GetAll					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:122:		cleanUp					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:140:		UpdateTTL				88.9%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:40:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:62:		Parse					74.4%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:149:		flagset					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:174:		defaultPluginDir			61.5%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:207:		GetDefaultKubeConfigPath		66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:27:			listCharts				89.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:77:			ListCharts				72.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:35:		NewActionConfig				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:54:		NewHandler				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:60:		NewHandlerWithSettings			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:85:		ToRESTConfig				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:89:		ToRawKubeConfigLoader			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:93:		ToDiscoveryClient			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:109:		ToRESTMapper				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:129:		getReleaseStatus			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:165:		setReleaseStatus			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:188:		setReleaseStatusSilent			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:53:		getReleases				57.1%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:112:		ListRelease				68.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:158:		GetRelease				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:217:		GetReleaseHistory			46.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:277:		UninstallRelease			55.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:334:		uninstallRelease			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:357:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:362:		RollbackRelease				51.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:421:		rollbackRelease				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:453:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:458:		handleError				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:463:		returnResponse				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:479:		InstallRelease				72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:513:		getChart				35.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:565:		installRelease				60.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:625:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:630:		UpgradeRelease				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:666:		logActionState				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:687:		upgradeRelease				63.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:731:		Validate				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:749:		GetActionStatus				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:35:		createFileIfNotThere			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:47:		lockRepositoryFile			87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:68:		addRepository				61.8%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:131:		AddRepo					72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:176:		createFullPath				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:184:		listRepositories			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:213:		ListRepo				58.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:236:		RemoveRepository			64.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:279:		RemoveRepo				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:291:		UpdateRepository			68.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:333:		UpdateRepository			81.8%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:26:	NewContextStore				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:35:	AddContext				23.1%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:64:	GetContexts				85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:80:	GetContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:90:	RemoveContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:95:	AddContextWithKeyAndTTL			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:100:	UpdateTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:14:		WriteToFile				86.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:48:		RemoveContextFromFile			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:62:	DeepCopyObject				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:67:	DeepCopy				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:87:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:98:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:109:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:120:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:133:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:145:	ClientConfig				80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:179:	RESTConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:189:	OidcConfig				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:207:	ProxyRequest				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:221:	ClientSetWithToken			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:235:	SourceStr				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:249:	SetupProxy				91.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:274:	AuthType				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:292:	LoadContextsFromFile			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:307:	LoadContextsFromBase64String		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:319:	LoadContextsFromMultipleFiles		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:342:	loadContextsFromData			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:376:	UnmarshalKubeconfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:388:	GetContextsFromKubeconfig		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:404:	ProcessContext				90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:453:	extractContextInfo			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:471:	extractClusterAndUserNames		83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:488:	getClusterAndUser			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:509:	createAndValidateConfig			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:541:	getNameOrUnknown			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:552:	HandleConfigLoadError			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:593:	checkBase64Errors			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:616:	checkUserBase64Fields			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:636:	checkClusterBase64Fields		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:652:	toStringKeyMap				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:668:	getCluster				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:686:	getUser					80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:707:	createKubeConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:730:	convertToContext			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:771:	LoadContextsFromAPIConfig		76.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:810:	splitKubeConfigPath			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:820:	GetInClusterContext			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:867:	LoadAndStoreKubeConfigs			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:892:	makeDNSFriendly				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:16:		LoadAndWatchFiles			80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:69:		addFilesToWatcher			82.4%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:29:		Log					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:36:		log					75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:80:		SetLogFunc				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:28:		Watch					77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:49:		periodicallyWatchSubfolders		75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:82:		generateSeparatePluginPaths		90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:103:		GeneratePluginPaths			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:118:		ListPlugins				68.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:171:		pluginBasePathListForDir		77.3%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:219:		HandlePluginEvents			70.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:243:		PopulatePluginsCache			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:269:		HandlePluginReload			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:300:		Delete					85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:315:		isSubdirectory				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:46:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:80:		getFreePort				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:99:		StartPortForward			50.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:173:	startPortForward			61.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:269:	checkIfPodIsRunning			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:291:	Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:304:	StopOrDeletePortForward			47.1%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:336:	GetPortForwards				45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:358:	GetPortForwardByID			45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:16:		portforwardKeyGenerator			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:33:		portforwardstore			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:46:		stopOrDeletePortForward			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:74:		getPortForwardList			77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:94:		getPortForwardByID			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/utils/utils.go:4:			Contains				100.0%
total:										(statements)				60.8%

Html coverage report download

@sniok
Copy link
Contributor

sniok commented Oct 23, 2024

Thanks for the changes.

  • I'm not sure why "type" is required? Isn't path enough to uniquely identify the operation?

  • The messages still don't have information about which request they belong to.

image

Imagine we started watching two /pods from two different clusters (or two different ReplicaSets,etc) and we need to figure out where to put this update that we received from websocket. Currently we just get a Pod without any info where it came from

  • Also I don't see how to close the connection?

@knrt10
Copy link
Contributor Author

knrt10 commented Oct 24, 2024

@sniok thank you for the detailed message. I have updated the description, screenshot, postman API and code. You will now have detailed information from where request is coming from. type as mentioned was not needed so has been removed. Not you can also close connection. Added usage in the description. Thanks

This adds websocket multiplexer to the backend. Frontend now make a
single websocket call to the backend. Once that connection is
established with the backend it will send message to the backend with
appropriate data. Backend will open multiple websockets and act as a
proxy to the frontend. It will make request to k8s server and return
data to frontend.

This also adds retry logic if the connection is broken between frontend
and backend.

Fixes: #1802

Signed-off-by: Kautilya Tripathi <[email protected]>
@knrt10 knrt10 force-pushed the websocket-multiplexer branch from 3971e72 to bf2ec6d Compare October 24, 2024 07:27
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Oct 24, 2024
Copy link

Backend Code coverage changed from 61.5% to 61.1%. Change: -.4% 😞.

Coverage report
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:92:			ServeHTTP				58.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:141:			fileExists				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:151:			copyReplace				63.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:175:			baseURLReplace				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:203:			getOidcCallbackURL			91.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:230:			serveWithNoCacheHeader			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:239:			defaultKubeConfigPersistenceDir		61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:267:			defaultKubeConfigPersistenceFile	75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:280:			addPluginRoutes				54.2%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:328:			createHeadlampHandler			40.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:695:			parseClusterAndToken			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:712:			decodePayload				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:726:			getExpiryTime				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:735:			isTokenAboutToExpire			61.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:759:			refreshAndCacheNewToken			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:829:			OIDCTokenRefreshMiddleware		30.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:880:			StartHeadlampServer			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:894:			getHelmHandler				53.8%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:922:			checkHeadlampBackendToken		100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:935:			handleClusterHelm			33.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1014:			handleClusterAPI			51.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1070:			handleClusterRequests			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1078:			getClusters				71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1121:			parseCustomNameClusters			38.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1175:			parseClusterFromKubeConfig		83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1209:			getConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1220:			addCluster				57.9%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1255:			decodeClusterRequest			71.4%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1270:			processClusterRequest			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1279:			processKubeConfig			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1296:			processManualConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1316:			handleLoadErrors			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1331:			writeKubeConfig				70.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1351:			addContextsToStore			80.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1363:			deleteCluster				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1412:			getKubeConfigPath			66.7%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1421:			handleStatelessClusterRename		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1435:			customNameToExtenstions			45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1468:			updateCustomContextToCache		50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1501:			getPathAndLoadKubeconfig		55.6%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1524:			renameCluster				53.1%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1587:			addClusterSetupRoute			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1612:			handleNodeDrain				45.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1677:			drainNode				37.5%
github.com/headlamp-k8s/headlamp/backend/cmd/headlamp.go:1727:			handleNodeDrainStatus			52.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:100:		NewMultiplexer				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:113:		updateStatus				82.4%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:156:		establishClusterConnection		0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:201:		getClusterConfigWithFallback		100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:218:		createConnection			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:240:		dialWebSocket				50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:268:		monitorConnection			54.5%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:293:		reconnect				0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:320:		HandleClientWebSocket			34.8%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:369:		readClientMessage			50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:390:		getOrCreateConnection			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:419:		handleConnectionError			75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:441:		writeMessageToCluster			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:459:		handleClusterMessages			87.5%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:478:		processClusterMessage			83.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:502:		createWrapperMessage			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:535:		handleReadError				100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:546:		handleWriteError			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:557:		cleanupConnections			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:574:		getClusterConfig			85.7%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:589:		CloseConnection				92.3%
github.com/headlamp-k8s/headlamp/backend/cmd/multiplexer.go:625:		createWebSocketURL			0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/server.go:14:			main					0.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:17:			MarshalCustomObject			60.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:42:			setKeyInCache				50.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:71:			handleStatelessReq			52.9%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:143:			parseKubeConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:182:			websocketConnContextKey			100.0%
github.com/headlamp-k8s/headlamp/backend/cmd/stateless.go:232:			getContextKeyForRequest			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:40:			New					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:52:			Set					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:57:			SetWithTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:75:			Delete					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:85:			Get					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:102:		GetAll					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:122:		cleanUp					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/cache/cache.go:140:		UpdateTTL				88.9%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:40:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:62:		Parse					74.4%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:149:		flagset					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:174:		defaultPluginDir			61.5%
github.com/headlamp-k8s/headlamp/backend/pkg/config/config.go:207:		GetDefaultKubeConfigPath		66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:27:			listCharts				89.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/charts.go:77:			ListCharts				72.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:35:		NewActionConfig				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:54:		NewHandler				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:60:		NewHandlerWithSettings			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:85:		ToRESTConfig				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:89:		ToRawKubeConfigLoader			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:93:		ToDiscoveryClient			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:109:		ToRESTMapper				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:129:		getReleaseStatus			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:165:		setReleaseStatus			60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/handler.go:188:		setReleaseStatusSilent			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:53:		getReleases				57.1%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:112:		ListRelease				68.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:158:		GetRelease				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:217:		GetReleaseHistory			46.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:277:		UninstallRelease			55.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:334:		uninstallRelease			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:357:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:362:		RollbackRelease				51.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:421:		rollbackRelease				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:453:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:458:		handleError				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:463:		returnResponse				71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:479:		InstallRelease				72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:513:		getChart				35.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:565:		installRelease				60.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:625:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:630:		UpgradeRelease				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:666:		logActionState				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:687:		upgradeRelease				63.6%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:731:		Validate				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/release.go:749:		GetActionStatus				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:35:		createFileIfNotThere			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:47:		lockRepositoryFile			87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:68:		addRepository				61.8%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:131:		AddRepo					72.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:176:		createFullPath				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:184:		listRepositories			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:213:		ListRepo				58.3%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:236:		RemoveRepository			64.0%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:279:		RemoveRepo				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:291:		UpdateRepository			68.2%
github.com/headlamp-k8s/headlamp/backend/pkg/helm/repository.go:333:		UpdateRepository			81.8%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:26:	NewContextStore				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:35:	AddContext				23.1%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:64:	GetContexts				85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:80:	GetContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:90:	RemoveContext				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:95:	AddContextWithKeyAndTTL			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/contextStore.go:100:	UpdateTTL				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:14:		WriteToFile				86.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/file.go:48:		RemoveContextFromFile			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:62:	DeepCopyObject				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:67:	DeepCopy				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:87:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:98:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:109:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:120:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:133:	Error					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:145:	ClientConfig				80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:179:	RESTConfig				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:189:	OidcConfig				0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:207:	ProxyRequest				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:221:	ClientSetWithToken			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:235:	SourceStr				60.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:249:	SetupProxy				91.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:274:	AuthType				66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:292:	LoadContextsFromFile			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:307:	LoadContextsFromBase64String		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:319:	LoadContextsFromMultipleFiles		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:342:	loadContextsFromData			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:376:	UnmarshalKubeconfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:388:	GetContextsFromKubeconfig		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:404:	ProcessContext				90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:453:	extractContextInfo			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:471:	extractClusterAndUserNames		83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:488:	getClusterAndUser			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:509:	createAndValidateConfig			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:541:	getNameOrUnknown			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:552:	HandleConfigLoadError			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:593:	checkBase64Errors			90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:616:	checkUserBase64Fields			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:636:	checkClusterBase64Fields		100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:652:	toStringKeyMap				83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:668:	getCluster				87.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:686:	getUser					80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:707:	createKubeConfig			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:730:	convertToContext			85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:771:	LoadContextsFromAPIConfig		76.5%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:810:	splitKubeConfigPath			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:820:	GetInClusterContext			0.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:867:	LoadAndStoreKubeConfigs			83.3%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/kubeconfig.go:892:	makeDNSFriendly				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:16:		LoadAndWatchFiles			80.0%
github.com/headlamp-k8s/headlamp/backend/pkg/kubeconfig/watcher.go:69:		addFilesToWatcher			82.4%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:29:		Log					100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:36:		log					75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/logger/logger.go:80:		SetLogFunc				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:28:		Watch					77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:49:		periodicallyWatchSubfolders		75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:82:		generateSeparatePluginPaths		90.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:103:		GeneratePluginPaths			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:118:		ListPlugins				68.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:171:		pluginBasePathListForDir		77.3%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:219:		HandlePluginEvents			70.0%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:243:		PopulatePluginsCache			66.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:269:		HandlePluginReload			76.9%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:300:		Delete					85.7%
github.com/headlamp-k8s/headlamp/backend/pkg/plugins/plugins.go:315:		isSubdirectory				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:46:		Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:80:		getFreePort				75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:99:		StartPortForward			50.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:173:	startPortForward			61.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:269:	checkIfPodIsRunning			71.4%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:291:	Validate				100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:304:	StopOrDeletePortForward			47.1%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:336:	GetPortForwards				45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/handler.go:358:	GetPortForwardByID			45.5%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:16:		portforwardKeyGenerator			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:33:		portforwardstore			75.0%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:46:		stopOrDeletePortForward			69.2%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:74:		getPortForwardList			77.8%
github.com/headlamp-k8s/headlamp/backend/pkg/portforward/store.go:94:		getPortForwardByID			100.0%
github.com/headlamp-k8s/headlamp/backend/pkg/utils/utils.go:4:			Contains				100.0%
total:										(statements)				61.1%

Html coverage report download

@illume
Copy link
Collaborator

illume commented Oct 24, 2024

Thanks @knrt10

(It looks like close can be used, and now a clusterID can be used to identify the response... Or is it also important to identify the specific request, rather than just the cluster?)

Does it make sense to start implementing the frontend/ integration now? Will you do that?

Note I started an issue here about multi cluster e2e tests here:

@illume
Copy link
Collaborator

illume commented Oct 24, 2024

Thanks for the explanation @knrt10

So the response returns (clusterID, path, query, and userID) as well as the data. This can be used to know from which websocket it comes from.

We discussed the possibility that multiple ones could be made with the same of those... in this case it will not work. I don't think we need to cover this now though. It could be solved in the future by adding a separate unique ID for each one. Again, I don't think this is necessary for our use cases... we can use (clusterID, path, query, and userID) as the unique key.

Copy link
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 24, 2024
@illume
Copy link
Collaborator

illume commented Oct 24, 2024

If @sniok you don't have any more comments or concerns, then we can merge this?

@knrt10 will begin frontend integration probably tomorrow, but we can merge this in first. (please correct me if I'm wrong)

@sniok
Copy link
Contributor

sniok commented Oct 24, 2024

looks good, thanks!

@illume illume merged commit dd9697a into main Oct 24, 2024
13 checks passed
@illume illume deleted the websocket-multiplexer branch October 24, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer multi Multi cluster aggregated view size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multi-plexing single browser websocket to multiple backend websockets
3 participants