Skip to content

Commit

Permalink
Rebased BYON from master (#162)
Browse files Browse the repository at this point in the history
* Updated way that to detect an admin. (#137)

Fixed linting error.

* Update backend port setting and makefile dev commands. (#133)

* Update README.md (#96)

Updated Readme to specify that a build is required prior to running the development server.

* Fix for input not allowing blank spaces.:

Fix to allow a user to enter an empty string.

Fixed with review comment.

* Add culler timeout settings feature (#134)

* Added types for notebookimage and status (#147)

Updated with REST api notebook image endpoints and new notebook image types.

* Updated REST API  (#155)

* Updated with REST API design changes.

Fixed formatting error.

* Update backend/src/types.ts

Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com>

Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com>

* Updated type.ts in front end with Succeeded

* [byon] Implement backend (#156)

* feat(byon): List all notebooks

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

* feat(byon): Get single notebook

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

* fix(byon): Update api spec to include software and id

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

* feat(byon): Schedule new notebook import

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

* feat(byon): Delete notebook

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

* feat(byon): Update notebook

Signed-off-by: Tomas Coufal <tcoufal@redhat.com>

Co-authored-by: Christopher Chase <cchase@redhat.com>
Co-authored-by: Chad Roberts <croberts@redhat.com>
Co-authored-by: Juntao Wang <37624318+DaoDaoNoCode@users.noreply.github.com>
Co-authored-by: Tom Coufal <7453394+tumido@users.noreply.github.com>
  • Loading branch information
5 people authored Mar 30, 2022
1 parent 7c4965b commit 3427e7a
Show file tree
Hide file tree
Showing 18 changed files with 336 additions and 168 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ SOURCE_REPOSITORY_REF=master
DOC_LINK ='https://opendatahub.io/docs.html'
COMMUNITY_LINK ='https://opendatahub.io/community.html'
ENABLED_APPS_CM = 'odh-enabled-applications-config'
ADMIN_GROUP = 'odh-admins'
16 changes: 0 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ reinstall: build push undeploy deploy

##################################

# DEV - run apps locally for development

.PHONY: dev-frontend
dev-frontend:
./install/dev-frontend.sh

.PHONY: dev-backend
dev-backend:
./install/dev-backend.sh

.PHONY: dev
dev:
./install/dev.sh

##################################

# BUILD - build image locally using s2i

.PHONY: build
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ Before developing for ODH, the basic requirements:
$ cd odh-dashboard && npm install
```
### Build project
```
$ npm run build
```
### Serve development content
This is the default context for running a local UI
This is the default context for running a local UI. Make sure you build the project using the instructions above prior to running the command below.
```
$ npm run start
Expand Down
10 changes: 8 additions & 2 deletions backend/src/routes/api/cluster-settings/clusterSettingsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export const updateClusterSettings = async (
const query = request.query as { [key: string]: string };
try {
const jupyterhubCM = await coreV1Api.readNamespacedConfigMap(name, namespace);
if (query.pvcSize) {
if (query.pvcSize && query.cullerTimeout) {
await coreV1Api.patchNamespacedConfigMap(
name,
namespace,
{
data: { singleuser_pvc_size: `${query.pvcSize}Gi` },
data: { singleuser_pvc_size: `${query.pvcSize}Gi`, culler_timeout: query.cullerTimeout },
},
undefined,
undefined,
Expand All @@ -33,6 +33,11 @@ export const updateClusterSettings = async (
if (jupyterhubCM.body.data.singleuser_pvc_size.replace('Gi', '') !== query.pvcSize) {
await scaleDeploymentConfig(fastify, 'jupyterhub', 0);
}
if (jupyterhubCM.body.data['culler_timeout'] !== query.cullerTimeout) {
// scale down to 0 and scale it up to 1
await scaleDeploymentConfig(fastify, 'jupyterhub-idle-culler', 0);
await scaleDeploymentConfig(fastify, 'jupyterhub-idle-culler', 1);
}
}
return { success: true, error: null };
} catch (e) {
Expand All @@ -52,6 +57,7 @@ export const getClusterSettings = async (
const clusterSettingsRes = await coreV1Api.readNamespacedConfigMap(name, namespace);
return {
pvcSize: Number(clusterSettingsRes.body.data.singleuser_pvc_size.replace('Gi', '')),
cullerTimeout: Number(clusterSettingsRes.body.data.culler_timeout),
};
} catch (e) {
if (e.response?.statusCode !== 404) {
Expand Down
1 change: 0 additions & 1 deletion backend/src/routes/api/cluster-settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
import { DEV_MODE } from '../../../utils/constants';
import { getClusterSettings, updateClusterSettings } from './clusterSettingsUtils';

export default async (fastify: FastifyInstance): Promise<void> => {
Expand Down
9 changes: 6 additions & 3 deletions backend/src/routes/api/status/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const status = async (
fastify: KubeFastifyInstance,
request: FastifyRequest,
): Promise<{ kube: KubeStatus }> => {
const adminGroup = process.env.ADMIN_GROUP;
const kubeContext = fastify.kube.currentContext;
const { currentContext, namespace, currentUser, clusterID } = fastify.kube;
const currentUserName =
Expand All @@ -20,10 +19,14 @@ const status = async (
userName = 'kube:admin';
}
const customObjectsApi = fastify.kube.customObjectsApi;
const coreV1Api = fastify.kube.coreV1Api;
let isAdmin = false;

try {
//const adminGroup2 = (await coreV1Api.readNamespacedConfigMap('rhods-groups-config', namespace)).body.data['admin_groups'];
const configGroupName = (await coreV1Api.readNamespacedConfigMap('groups-config', namespace))
.body.data['groups-config'];
const adminGroup = (await coreV1Api.readNamespacedConfigMap(configGroupName, namespace)).body
.data['admin_groups'];
const adminGroupResponse = await customObjectsApi.getClusterCustomObject(
'user.openshift.io',
'v1',
Expand All @@ -33,7 +36,7 @@ const status = async (
const adminUsers = (adminGroupResponse.body as groupObjResponse).users;
isAdmin = adminUsers.includes(userName);
} catch (e) {
console.log('Failed to get role bindings: ' + e.toString());
console.log('Failed to get groups: ' + e.toString());
}
fastify.kube.coreV1Api.getAPIResources();
if (!kubeContext && !kubeContext.trim()) {
Expand Down
1 change: 1 addition & 0 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type DashboardConfig = {

export type ClusterSettings = {
pvcSize: number;
cullerTimeout: number;
}

// Add a minimal QuickStart type here as there is no way to get types without pulling in frontend (React) modules
Expand Down
2 changes: 2 additions & 0 deletions frontend/config/dotenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const setupDotenvFilesForEnv = ({ env }) => {
const DIST_DIR = path.resolve(RELATIVE_DIRNAME, process.env.ODH_DIST_DIR || TS_OUT_DIR || 'public');
const HOST = process.env.ODH_HOST || 'localhost';
const PORT = process.env.ODH_PORT || '3000';
const BACKEND_PORT = process.env.PORT || process.env.BACKEND_PORT || 8080;
const DEV_MODE = process.env.ODH_DEV_MODE || undefined;
const OUTPUT_ONLY = process.env._ODH_OUTPUT_ONLY === 'true';

Expand All @@ -158,6 +159,7 @@ const setupDotenvFilesForEnv = ({ env }) => {
process.env._ODH_PORT = PORT;
process.env._ODH_OUTPUT_ONLY = OUTPUT_ONLY;
process.env._ODH_DEV_MODE = DEV_MODE;
process.env._BACKEND_PORT = BACKEND_PORT;
};

module.exports = { setupWebpackDotenvFilesForEnv, setupDotenvFilesForEnv };
2 changes: 1 addition & 1 deletion frontend/config/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const COMMON_DIR = process.env._ODH_COMMON_DIR;
const DIST_DIR = process.env._ODH_DIST_DIR;
const HOST = process.env._ODH_HOST;
const PORT = process.env._ODH_PORT;
const BACKEND_PORT = process.env.BACKEND_PORT || 8080;
const BACKEND_PORT = process.env._BACKEND_PORT;

module.exports = merge(
{
Expand Down
54 changes: 41 additions & 13 deletions frontend/src/pages/clusterSettings/ClusterSettings.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
.odh-cluster-settings {
.pf-c-form__group {
border: var(--pf-global--BorderWidth--sm) solid var(--pf-global--BorderColor--100);
padding: var(--pf-global--spacer--md);
margin: 0;
}
.pf-c-form__group {
border: var(--pf-global--BorderWidth--sm) solid var(--pf-global--BorderColor--100);
padding: var(--pf-global--spacer--md);
margin: 0;
}

.odh-number-input {
max-width: 100px;
.odh-number-input {
max-width: 100px;
}

.pf-c-input-group {
padding-top: var(--pf-global--spacer--md);
padding-bottom: var(--pf-global--spacer--md);
&__text {
font-size: var(--pf-global--FontSize--sm);
color: var(--pf-global--Color--100);
}
}

.pf-c-helper-text {
margin-top: var(--pf-global--spacer--sm);
}

.pf-c-input-group {
padding-top: var(--pf-global--spacer--md);
padding-bottom: var(--pf-global--spacer--md);
.pf-c-radio {
margin: var(--pf-global--spacer--sm) 0;
padding-left: var(--pf-global--spacer--sm);
&__label {
font-size: var(--pf-global--FontSize--sm);
}
}

&__form {
margin: 0 var(--pf-global--spacer--lg);
&__form {
margin: 0 var(--pf-global--spacer--lg);
}

&__culler-input-group {
&.pf-c-input-group {
padding: var(--pf-global--spacer--xs) var(--pf-global--spacer--lg) 0;
}
.odh-number-input {
max-width: 40px;
&__hour {
max-width: 60px;
}
}
}
}
}
Loading

0 comments on commit 3427e7a

Please sign in to comment.