Skip to content

Commit d366454

Browse files
authored
chore: retrieve google sa in batch job only if it's specified (#653)
# Description Previously, the batch-job in Merlin was using BQ table and when client tries to submit a batch-job, Merlin assumed that a Google Service Account will be provided in the job configuration. But as we have added option for using MaxCompute and it doesn't need a Google SA, I'm adding a check where it will only try to retrieve the service account if it's provided # Modifications <!-- Summarize the key code changes. --> # Tests # Checklist - [x] Added PR label - [ ] Added unit test, integration, and/or e2e tests - [x] Tested locally - [ ] Updated documentation - [ ] Update Swagger spec if the PR introduce API changes - [ ] Regenerated Golang and Python client if the PR introduces API changes # Release Notes ```release-note remove google sa dependency in batch job ```
1 parent 96cf05d commit d366454

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

api/batch/controller.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,13 @@ func (c *controller) onUpdate(old, new interface{}) {
324324
func (c *controller) getMLPSecrets(ctx context.Context, predictionJob *models.PredictionJob, namespace string) (map[string]string, error) {
325325
secretMap := make(map[string]string)
326326
// Retrieve Google Service Account secret from MLP
327-
googleServiceAccountSecret, err := c.mlpAPIClient.GetSecretByName(ctx, predictionJob.Config.ServiceAccountName, int32(predictionJob.ProjectID))
328-
if err != nil {
329-
return nil, fmt.Errorf("service account %s is not found within %s project: %w", predictionJob.Config.ServiceAccountName, namespace, err)
327+
if predictionJob.Config.ServiceAccountName != "" {
328+
googleServiceAccountSecret, err := c.mlpAPIClient.GetSecretByName(ctx, predictionJob.Config.ServiceAccountName, int32(predictionJob.ProjectID))
329+
if err != nil {
330+
return nil, fmt.Errorf("service account %s is not found within %s project: %w", predictionJob.Config.ServiceAccountName, namespace, err)
331+
}
332+
secretMap[serviceAccountFileName] = googleServiceAccountSecret.Data
330333
}
331-
secretMap[serviceAccountFileName] = googleServiceAccountSecret.Data
332334

333335
// Retrieve user-configured secrets from MLP
334336
for _, secret := range predictionJob.Config.Secrets {

0 commit comments

Comments
 (0)