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

(Frontend): Add commands for generic snapshots #308

Open
wants to merge 3 commits into
base: feature-k8s-snapshots
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add generic snapshot functionality to leftpanel
davidspek committed Feb 2, 2021
commit 260fd030a1946186d92db9292bba05c2cd934733
81 changes: 66 additions & 15 deletions labextension/src/widgets/LeftPanel.tsx
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ interface IProps {
backend: boolean;
kernel: Kernel.IKernelConnection;
rokError: IRPCError;
snapshotError: IRPCError;
}

interface IState {
@@ -442,6 +443,16 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
notebookVolumes,
selectVolumeTypes,
});
} else if (!this.props.snapshotError) {
// Get information about volumes currently mounted on the notebook server
const {
notebookVolumes,
selectVolumeTypes,
} = await commands.getMountedVolumes(this.state.notebookVolumes);
this.setState({
notebookVolumes,
selectVolumeTypes,
});
} else {
this.setState((prevState, props) => ({
selectVolumeTypes: prevState.selectVolumeTypes.map(t => {
@@ -532,8 +543,25 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
}
return volume;
});
let snapstateVolumes = this.props.snapshotError
? metadataVolumes
: metadataVolumes.map((volume: IVolumeMetadata) => {
if (
volume.type === 'new_pvc' &&
volume.annotations.length > 0 &&
volume.annotations[0].key === 'rok/origin'
) {
return { ...volume, type: 'snap' };
}
return volume;
});
if (stateVolumes.length === 0 && metadataVolumes.length === 0) {
metadataVolumes = stateVolumes = this.state.notebookVolumes;
} else if (
snapstateVolumes.length === 0 &&
metadataVolumes.length === 0
) {
metadataVolumes = snapstateVolumes = this.state.notebookVolumes;
} else {
metadataVolumes = metadataVolumes.concat(this.state.notebookVolumes);
stateVolumes = stateVolumes.concat(this.state.notebookVolumes);
@@ -557,11 +585,15 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
},
autosnapshot:
notebookMetadata['autosnapshot'] === undefined
? !this.props.rokError && this.state.notebookVolumes.length > 0
? !this.props.rokError &&
!this.props.snapshotError &&
this.state.notebookVolumes.length > 0
: notebookMetadata['autosnapshot'],
snapshot_volumes:
notebookMetadata['snapshot_volumes'] === undefined
? !this.props.rokError && this.state.notebookVolumes.length > 0
? !this.props.rokError &&
!this.props.snapshotError &&
this.state.notebookVolumes.length > 0
: notebookMetadata['snapshot_volumes'],
// fixme: for now we are using the 'steps_defaults' field just for poddefaults
// so we replace any existing value every time
@@ -577,9 +609,13 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
...DefaultState.metadata,
volumes: prevState.notebookVolumes,
snapshot_volumes:
!this.props.rokError && prevState.notebookVolumes.length > 0,
!this.props.rokError &&
!this.props.snapshotError &&
prevState.notebookVolumes.length > 0,
autosnapshot:
!this.props.rokError && prevState.notebookVolumes.length > 0,
!this.props.rokError &&
!this.props.snapshotError &&
prevState.notebookVolumes.length > 0,
},
volumes: prevState.notebookVolumes,
}));
@@ -647,18 +683,32 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
metadata.volumes.filter((v: IVolumeMetadata) => v.type === 'clone')
.length > 0
) {
const task = await commands.runSnapshotProcedure(_updateDeployProgress);
console.log(task);
if (!task) {
this.setState({ runDeployment: false });
return;
if (!this.props.rokError) {
const task = await commands.runSnapshotProcedure(_updateDeployProgress);
console.log(task);
if (!task) {
this.setState({ runDeployment: false });
return;
}
metadata.volumes = await commands.replaceClonedVolumes(
task.bucket,
task.result.event.object,
task.result.event.version,
metadata.volumes,
);
} else if (!this.props.snapshotError) {
const task = await commands.runGenericSnapshotProcedure(
_updateDeployProgress,
);
console.log(task);
if (!task) {
this.setState({ runDeployment: false });
return;
}
metadata.volumes = await commands.replaceGenericClonedVolumes(
metadata.volumes,
);
}
metadata.volumes = await commands.replaceClonedVolumes(
task.bucket,
task.result.event.object,
task.result.event.version,
metadata.volumes,
);
}

// CREATE PIPELINE
@@ -817,6 +867,7 @@ export class KubeflowKaleLeftPanel extends React.Component<IProps, IState> {
autosnapshot={this.state.metadata.autosnapshot}
updateAutosnapshotSwitch={this.updateAutosnapshotSwitch}
rokError={this.props.rokError}
snapshotError={this.props.snapshotError}
updateVolumes={this.updateVolumes}
storageClassName={this.state.metadata.storage_class_name}
updateStorageClassName={this.updateStorageClassName}