Skip to content

Commit

Permalink
update kf version to 0.3.5; add retry around IAM policy edit (kubeflo…
Browse files Browse the repository at this point in the history
…w#2161)

* update kf version to 0.3.5; add retry around IAM policy edit

* update messages
  • Loading branch information
kunmingg authored and k8s-ci-robot committed Dec 21, 2018
1 parent ec0279f commit 19468b6
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions components/gcp-click-to-deploy/src/DeployForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class DeployForm extends React.Component<any, DeployFormState> {
dialogBody: '',
dialogTitle: '',
iap: true,
kfversion: 'v0.3.4',
kfversion: 'v0.3.5',
project: '',
showLogs: false,
zone: 'us-central1-a',
Expand Down Expand Up @@ -144,7 +144,7 @@ export default class DeployForm extends React.Component<any, DeployFormState> {
public render() {
const zoneList = ['us-central1-a', 'us-central1-c', 'us-east1-c', 'us-east1-d', 'us-west1-b',
'europe-west1-b', 'europe-west1-d', 'asia-east1-a', 'asia-east1-b'];
const versionList = ['v0.3.4'];
const versionList = ['v0.3.5'];

return (
<div>
Expand Down Expand Up @@ -435,12 +435,21 @@ export default class DeployForm extends React.Component<any, DeployFormState> {
'members': ['serviceAccount:' + saEmail],
'role': 'roles/owner'
});
await Gapi.cloudresourcemanager.setIamPolicy(project, currProjPolicy)
.catch(e => {
this.setState({
dialogTitle: 'Failed setting IAM policy, please verify if have permission',
});
let returnPloicy = null;
for (let retries = 5; retries > 0; retries -= 1) {
returnPloicy = await Gapi.cloudresourcemanager.setIamPolicy(project, currProjPolicy)
.catch(e => this._appendLine('Pending on project environment sync up'));
if (returnPloicy !== undefined) {
break;
}
await wait(10000);
}
if (returnPloicy === undefined) {
this.setState({
dialogTitle: 'Failed to set IAM policy, please make sure you have enough permissions.',
});
return;
}

const currSAPolicy = await Gapi.iam.getServiceAccountIAM(project, saEmail);
if (!(bindingKey in currSAPolicy)) {
Expand All @@ -453,24 +462,26 @@ export default class DeployForm extends React.Component<any, DeployFormState> {
await Gapi.iam.setServiceAccountIAM(project, saEmail, currSAPolicy)
.catch(e => {
this.setState({
dialogTitle: 'Failed setting service account policy, please verify if have permission',
dialogTitle: 'Failed to set service account policy, please make sure you have enough permissions.',
});
});
if (this.state.dialogTitle) {
return;
}

let token = null;
for (let retries = 10; retries > 0; retries -= 1) {
for (let retries = 20; retries > 0; retries -= 1) {
token = await Gapi.iam.getServiceAccountToken(project, saEmail)
.catch(e => this._appendLine('Pending on new service account policy sync up'));
if (token !== undefined) {
break;
}
await wait(5000);
await wait(10000);
}
if (token === undefined) {
this._appendLine('Failed creating service account token, please verify if have permission');
this.setState({
dialogTitle: 'Failed to create service account token, please make sure you have enough permissions.',
});
return;
}

Expand Down

0 comments on commit 19468b6

Please sign in to comment.