-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GAWB-2942] Leo pets per project: Make ServiceAccountProvider interfa…
…ce and update Leo code to use it (#89) * Initial refactoring. Main compiles, tests don't. * Tests compile, don't pass * Add DB migration, tests pass now * Added Sam ServiceAccountProvider implementation, clean up some code * Oops, fix name * Beef up pet swat a little bit * Rebase from develop * Minor fixup * post rebase fix * Fix LeonardoModelCopy + ClusterKluge * Add stub method to remove creds from instance metadata, if an override service account is used. * Fix label swat test * s/overrideServiceAccount/notebookServiceAccount/g * Fix comment * Fix substring check * Dummy commit to test github * PR feedback: made ServiceAccountProvider return both the Leo SA and the pem file * Sleep a little more * Jam a recover on removeServiceAccountKey so the delete doesn't fail * Fix swat test flakiness, fix TODOs * retrieving service account keys from Google is SUPER inconsistent and flakey
- Loading branch information
1 parent
752cf2a
commit 0368259
Showing
33 changed files
with
587 additions
and
287 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
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
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
21 changes: 21 additions & 0 deletions
21
...de/workbench/leonardo/liquibase/changesets/20171205_cluster-split-up-service-accounts.xml
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog logicalFilePath="leonardo" xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"> | ||
<changeSet logicalFilePath="leonardo" author="rtitle" id="cluster_add_service_account_columns"> | ||
<addColumn tableName="CLUSTER"> | ||
<column name="clusterServiceAccount" type="varchar(254)" /> | ||
</addColumn> | ||
<addColumn tableName="CLUSTER"> | ||
<column name="notebookServiceAccount" type="varchar(254)" /> | ||
</addColumn> | ||
</changeSet> | ||
|
||
<changeSet logicalFilePath="leonardo" author="rtitle" id="cluster_migrate_service_accounts"> | ||
<sql dbms="mysql">UPDATE CLUSTER SET notebookServiceAccount = googleServiceAccount</sql> | ||
</changeSet> | ||
|
||
<changeSet logicalFilePath="leonardo" author="rtitle" id="cluster_drop_service_account_columns"> | ||
<dropColumn tableName="CLUSTER"> | ||
<column name="googleServiceAccount" /> | ||
</dropColumn> | ||
</changeSet> | ||
</databaseChangeLog> |
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
23 changes: 23 additions & 0 deletions
23
...ain/scala/org/broadinstitute/dsde/workbench/leonardo/auth/PetServiceAccountProvider.scala
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,23 @@ | ||
package org.broadinstitute.dsde.workbench.leonardo.auth | ||
|
||
import com.typesafe.config.Config | ||
import org.broadinstitute.dsde.workbench.model.{UserInfo, WorkbenchEmail} | ||
import org.broadinstitute.dsde.workbench.model.google.GoogleProject | ||
|
||
import scala.concurrent.Future | ||
|
||
/** | ||
* Created by rtitle on 12/5/17. | ||
*/ | ||
class PetServiceAccountProvider(config: Config) extends SamServiceAccountProvider(config) { | ||
|
||
override def getClusterServiceAccount(userInfo: UserInfo, googleProject: GoogleProject): Future[Option[WorkbenchEmail]] = { | ||
// Create cluster with the Google Compute Engine default service account | ||
Future(None) | ||
} | ||
|
||
override def getNotebookServiceAccount(userInfo: UserInfo, googleProject: GoogleProject): Future[Option[WorkbenchEmail]] = { | ||
// Ask Sam for the pet service account for the user | ||
samDAO.getPetServiceAccount(userInfo).map(Option(_)) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ain/scala/org/broadinstitute/dsde/workbench/leonardo/auth/SamServiceAccountProvider.scala
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,23 @@ | ||
package org.broadinstitute.dsde.workbench.leonardo.auth | ||
|
||
import akka.actor.ActorSystem | ||
import akka.stream.ActorMaterializer | ||
import com.typesafe.config.Config | ||
import net.ceedubs.ficus.Ficus._ | ||
import org.broadinstitute.dsde.workbench.leonardo.config.SamConfig | ||
import org.broadinstitute.dsde.workbench.leonardo.dao.HttpSamDAO | ||
import org.broadinstitute.dsde.workbench.leonardo.model.ServiceAccountProvider | ||
|
||
/** | ||
* Created by rtitle on 12/5/17. | ||
*/ | ||
abstract class SamServiceAccountProvider(config: Config) extends ServiceAccountProvider(config) { | ||
// Need to specify a new ActorSystem for Sam | ||
implicit val system = ActorSystem("SamServiceAccountProvider") | ||
implicit val materializer = ActorMaterializer() | ||
implicit val executionContext = system.dispatcher | ||
|
||
protected lazy val samConfig = config.as[SamConfig]("sam") | ||
protected lazy val samDAO = new HttpSamDAO(samConfig.server) | ||
|
||
} |
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
Oops, something went wrong.