-
Notifications
You must be signed in to change notification settings - Fork 21
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
Leo/Sam auth: handle Sam API exceptions in SamAuthProvider #138
Conversation
@@ -86,20 +87,6 @@ object Boot extends App with LazyLogging { | |||
} | |||
} | |||
|
|||
private def constructServiceAccountProvider(className: String, config: Config): ServiceAccountProvider = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the *Helper
classes.
authProvider.canSeeAllClustersInProject(userInfo.userEmail, googleProject) flatMap { | ||
authProvider.canSeeAllClustersInProject(userInfo.userEmail, googleProject).recover { case NonFatal(e) => | ||
logger.warn(s"Sam returned an exception for resource ${googleProject.value}. Filtering out from list results.", e) | ||
false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"list clusters" should not throw exceptions for individual clusters: it should filter them out.
fiab-start is failing:
EDIT: just needed to rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice; this will help with #159 too
@@ -207,12 +206,18 @@ class LeonardoService(protected val dataprocConfig: DataprocConfig, | |||
clustersByProject = clusterList.groupBy(_.googleProject) | |||
visibleClusters <- clustersByProject.toList.flatTraverse[Future, Cluster] { case (googleProject, clusters) => | |||
val clusterList = clusters.toList | |||
authProvider.canSeeAllClustersInProject(userInfo.userEmail, googleProject) flatMap { | |||
authProvider.canSeeAllClustersInProject(userInfo.userEmail, googleProject).recover { case NonFatal(e) => | |||
logger.warn(s"The auth provider returned an exception for resource ${googleProject.value}. Filtering out from list results.", e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: note that this is a call to canSeeAllClustersInProject
in this text
Future.failed(ClusterNotFoundException(googleProject, name1)) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment about why this test and the next have exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
fiab-test-leonardo passed; fiab-test is failing due to infrastructure issues. |
jenkins retest |
2 similar comments
jenkins retest |
jenkins retest |
* Add error handling to providers * Add tests * Clean up * Add logging * Exception recovery not needed on SamAuthProvider * Better specs and error handling * Add comment * Log text nit * Add comment to specs
* Add error handling to providers * Add tests * Clean up * Add logging * Exception recovery not needed on SamAuthProvider * Better specs and error handling * Add comment * Log text nit * Add comment to specs
* Add error handling to providers * Add tests * Clean up * Add logging * Exception recovery not needed on SamAuthProvider * Better specs and error handling * Add comment * Log text nit * Add comment to specs
* Add error handling to providers * Add tests * Clean up * Add logging * Exception recovery not needed on SamAuthProvider * Better specs and error handling * Add comment * Log text nit * Add comment to specs
* Add error handling to providers * Add tests * Clean up * Add logging * Exception recovery not needed on SamAuthProvider * Better specs and error handling * Add comment * Log text nit * Add comment to specs
I made a
LeoAuthProviderHelper
andServiceAccountProviderHelper
which wrapLeoAuthProvider
andServiceAccountProvider
respectively and recover all thrown exceptions toLeoException
. I was thinking this would be a better approach than assuming the providers are doing exception handling themselves (because they may not be written by us).Also added some specs to make sure exception handling is working. I don't think additional auto tests are needed for this. I haven't run auto tests yet. :)
Have you read CONTRIBUTING.md lately? If not, do that first.
I, the developer opening this PR, do solemnly pinky swear that:
In all cases: