-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1981 from andrewballantyne/support-dsc-status
Expose the DSC status for the client
- Loading branch information
Showing
5 changed files
with
93 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { KubeFastifyInstance } from '../../../types'; | ||
import { secureRoute } from '../../../utils/route-security'; | ||
import { getClusterStatus } from '../../../utils/dsc'; | ||
|
||
module.exports = async (fastify: KubeFastifyInstance) => { | ||
fastify.get( | ||
'/status', | ||
secureRoute(fastify)(async () => { | ||
return getClusterStatus(fastify); | ||
}), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
DataScienceClusterKind, | ||
DataScienceClusterKindStatus, | ||
DataScienceClusterList, | ||
KubeFastifyInstance, | ||
} from '../types'; | ||
import { createCustomError } from './requestUtils'; | ||
|
||
export const getClusterStatus = async ( | ||
fastify: KubeFastifyInstance, | ||
): Promise<DataScienceClusterKindStatus> => { | ||
const result: DataScienceClusterKind | null = await fastify.kube.customObjectsApi | ||
.listClusterCustomObject('datasciencecluster.opendatahub.io', 'v1', 'datascienceclusters') | ||
.then((res) => (res.body as DataScienceClusterList).items[0]) | ||
.catch((e) => { | ||
fastify.log.error(`Failure to fetch dsc: ${e.response.body}`); | ||
return null; | ||
}); | ||
|
||
if (!result) { | ||
// May not be using v2 Operator | ||
throw createCustomError('DSC Unavailable', 'Unable to get status', 404); | ||
} | ||
|
||
return result.status; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters