Skip to content

Commit

Permalink
Add error handling for ns creation (#184)
Browse files Browse the repository at this point in the history
Add error messages for namespace creation
  • Loading branch information
wg102 authored Feb 23, 2024
1 parent 258ead8 commit c608466
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 31 deletions.
13 changes: 11 additions & 2 deletions components/centraldashboard/public/assets/i18n/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"landingPage.slackLink": "https://statcan-aaw.slack.com",
"landingPage.firstTime": "This seems to be the first time you access Kubeflow, we are happy to see you!",
"landingPage.autoNamespace": "Your namespace is automatically generated.",
"landingPage.yourNamespace": "Your namespace will be",
"landingPage.email": "Your email is",
"landingPage.errCreateNS": "An error occured while creating the namespace.",
"landingPage.errGetNS": "An error occured while trying to retrieve the namespace",
"landingPage.errCreateDefaultNotebook": "An error occured while trying to create the default notebook",
"landingPage.errGeneral": "An unexpected error occured, details available in English:",
"notebookDefaultCard.goto": "Go to Notebooks",
"notebookDefaultCard.create": "Create",
"notebookDefaultCard.details": "Details",
Expand All @@ -76,8 +82,7 @@
"notebookDefaultCard.txtNoDefaultNotebook": "No default notebook for this namespace. You may click on 'Create' below to generate one.",
"notebookDefaultCard.txtDefaultNotReady": "The default notebook is not ready yet.",
"notebookDefaultCard.errorDefaultNotebook": "Failed to do the current operation, because:",
"landingPage.yourNamespace": "Your namespace will be",
"landingPage.email": "Your email is",

"registrationPage.btnNext": "Next",
"registrationPage.lblNamespace": "Namespace",
"registrationPage.lblNamespaceDesc": "A namespace is a collection of Kubeflow services. Resources created within a namespace are isolated to that namespace. By default, a namespace will be created for you.",
Expand Down Expand Up @@ -200,6 +205,10 @@
"landingPage.autoNamespace": "Votre espace de noms est automatiquement généré.",
"landingPage.yourNamespace": "Votre espace de noms sera",
"landingPage.email": "Votre courriel est",
"landingPage.errCreateNS": "Une erreur s'est produite lors de la création de l'espace de noms.",
"landingPage.errGetNS": "Une erreur s'est produite lors de la tentative de récupération de l'espace de noms",
"landingPage.errCreateDefaultNotebook": "Une erreur s'est produite lors de la tentative de création du notebook par défaut",
"landingPage.errGeneral": "Une erreur inattendue s'est produite, détails disponibles en anglais :",
"registrationPage.btnNext": "Suivant",
"registrationPage.btnStartSetup": "Commencer",
"registrationPage.lblNamespace": "Espace de nom",
Expand Down
61 changes: 35 additions & 26 deletions components/centraldashboard/public/components/landing-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
userDetails: {type: Object, observer: '_onUserDetails'},
namespaceName: String,
emailAddress: String,
error: Object,
errorText: {type: String, value: ''},
errorDetail: {type: String, value: ''},
flowComplete: {type: Boolean, value: false},
waitForRedirect: {type: Boolean, value: false},
showAPIText: {type: Boolean, value: false},
Expand All @@ -51,7 +52,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
super.ready();
}

_onUserDetails(d) {
_onUserDetails() {
this.emailAddress = this.userDetails;
this.generateNamespace(this.userDetails);
}
Expand Down Expand Up @@ -93,10 +94,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
}
this.namespaceName = ns;
}).catch((e)=> {
this.set('error', {response: {
error: e,
namespace: this.namespaceName,
}});
this.showError('landingPage.errGeneral');
this.errorDetail= e;
});
}

Expand All @@ -106,15 +105,7 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
this.waitForRedirect = true;
await API.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule
if (this.error && this.error.response) {
if (this.error.response.error) {
this.set('error', {response: {
error: 'registrationPage.errDuplicate',
namespace: this.namespaceName,
}});
}
return this.waitForRedirect = false;
}

/*
* Poll for profile over a span of 20 seconds (every 300ms)
* if still not there, let the user click next again!
Expand All @@ -127,16 +118,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities

await APICreateDefault.generateRequest().completes.catch((e) => e);
await this.sleep(1); // So the errors and callbacks can schedule
if (this.error && this.error.response) {
if (this.error.response.error) {
this.set('error', {response: {
error: 'registrationPage.errCreateNotebook',
namespace: this.namespaceName,
}});
}
return this.waitForRedirect = false;
}
this.waitForRedirect = false;

return this.waitForRedirect = false;
}

async pollProfile(times, delay) {
Expand All @@ -152,9 +135,35 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities

_successSetup() {
this.flowComplete = true;
this.set('error', {});
this.closeError();
this.fireEvent('flowcomplete');
}

// Error handling functions
showError(err) {
this.errorText = err;
this.errorDetail = '';
}

closeError() {
this.errorText = '';
this.errorDetail = '';
}

_onCreateNamespaceError(ev) {
this.showError('mainPage.errCreateNS');
return;
}

_onGetNamespaceError(ev) {
this.showError('mainPage.errGetNS');
return;
}

_onCreateDefaultNotebookError(ev) {
this.showError('mainPage.errCreateDefaultNotebook');
return;
}
}


Expand Down
10 changes: 7 additions & 3 deletions components/centraldashboard/public/components/landing-page.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
iron-ajax#MakeNamespace(method='POST', url='/api/workgroup/create', handle-as='json', last-error='{{error}}', last-response='{{resp}}',
iron-ajax#MakeNamespace(method='POST', url='/api/workgroup/create', handle-as='json', on-error='_onCreateNamespaceError', last-response='{{resp}}',
content-type='application/json', loading='{{submittingWorkgroup}}')
iron-ajax#GetMyNamespace(url='/api/workgroup/exists', handle-as='json')
iron-ajax#CreateDefaultNotebook(method='POST', url='/jupyter/api/namespaces/[[namespaceName]]/createdefault', headers='{"Content-Type": "application/json"}')
iron-ajax#GetMyNamespace(url='/api/workgroup/exists', handle-as='json', on-error='_onGetNamespaceError')
iron-ajax#CreateDefaultNotebook(method='POST', url='/jupyter/api/namespaces/[[namespaceName]]/createdefault', headers='{"Content-Type": "application/json"}', on-error='_onCreateDefaultNotebookError')
paper-card#MainCard
figure#Logo !{logo}
neon-animatable.Main-Content
Expand All @@ -21,3 +21,7 @@ nav#Links
a(href='https://github.com/kubeflow/kubeflow', tabindex='-1', target="_blank") {{localize('registrationPage.linkGitHub')}}
a(href='https://www.kubeflow.org/docs/about/kubeflow/', tabindex='-1', target="_blank") {{localize('registrationPage.linkDocumentation')}}
a(href='https://policies.google.com/privacy', tabindex='-1', target="_blank") {{localize('registrationPage.linkPrivacy')}}

paper-toast#ErrorLandingPageToast(duration=0, opened='[[!empty(errorText)]]', on-click='closeError') {{localize(errorText)}}
strong [[errorDetail]]
paper-icon-button(icon='close')

0 comments on commit c608466

Please sign in to comment.