| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. | 1 // Copyright 2017 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // readConfigCron is handler for /internal/cron/read-config GAE cron task. | 60 // readConfigCron is handler for /internal/cron/read-config GAE cron task. |
| 61 func readConfigCron(c *router.Context) { | 61 func readConfigCron(c *router.Context) { |
| 62 // Don't override manually imported configs with 'nil' on devserver. | 62 // Don't override manually imported configs with 'nil' on devserver. |
| 63 if info.IsDevAppServer(c.Context) { | 63 if info.IsDevAppServer(c.Context) { |
| 64 c.Writer.WriteHeader(http.StatusOK) | 64 c.Writer.WriteHeader(http.StatusOK) |
| 65 return | 65 return |
| 66 } | 66 } |
| 67 | 67 |
| 68 wg := sync.WaitGroup{} | 68 wg := sync.WaitGroup{} |
| 69 » var errs [2]error | 69 » var errs [3]error |
| 70 | 70 |
| 71 wg.Add(1) | 71 wg.Add(1) |
| 72 go func() { | 72 go func() { |
| 73 defer wg.Done() | 73 defer wg.Done() |
| 74 _, errs[0] = adminServer.ImportCAConfigs(c.Context, nil) | 74 _, errs[0] = adminServer.ImportCAConfigs(c.Context, nil) |
| 75 if errs[0] != nil { | 75 if errs[0] != nil { |
| 76 logging.Errorf(c.Context, "ImportCAConfigs failed - %s",
errs[0]) | 76 logging.Errorf(c.Context, "ImportCAConfigs failed - %s",
errs[0]) |
| 77 } | 77 } |
| 78 }() | 78 }() |
| 79 | 79 |
| 80 wg.Add(1) | 80 wg.Add(1) |
| 81 go func() { | 81 go func() { |
| 82 defer wg.Done() | 82 defer wg.Done() |
| 83 _, errs[1] = adminServer.ImportDelegationConfigs(c.Context, nil) | 83 _, errs[1] = adminServer.ImportDelegationConfigs(c.Context, nil) |
| 84 if errs[1] != nil { | 84 if errs[1] != nil { |
| 85 logging.Errorf(c.Context, "ImportDelegationConfigs faile
d - %s", errs[1]) | 85 logging.Errorf(c.Context, "ImportDelegationConfigs faile
d - %s", errs[1]) |
| 86 } | 86 } |
| 87 }() | 87 }() |
| 88 | 88 |
| 89 wg.Add(1) |
| 90 go func() { |
| 91 defer wg.Done() |
| 92 _, errs[2] = adminServer.ImportServiceAccountsConfigs(c.Context,
nil) |
| 93 if errs[2] != nil { |
| 94 logging.Errorf(c.Context, "ImportServiceAccountsConfigs
failed - %s", errs[2]) |
| 95 } |
| 96 }() |
| 97 |
| 89 wg.Wait() | 98 wg.Wait() |
| 90 | 99 |
| 91 // Retry cron job only on transient errors. On fatal errors let it rerun
one | 100 // Retry cron job only on transient errors. On fatal errors let it rerun
one |
| 92 // minute later, as usual, to avoid spamming logs with errors. | 101 // minute later, as usual, to avoid spamming logs with errors. |
| 93 c.Writer.WriteHeader(statusFromErrs(errs[:])) | 102 c.Writer.WriteHeader(statusFromErrs(errs[:])) |
| 94 } | 103 } |
| 95 | 104 |
| 96 // fetchCRLCron is handler for /internal/cron/fetch-crl GAE cron task. | 105 // fetchCRLCron is handler for /internal/cron/fetch-crl GAE cron task. |
| 97 func fetchCRLCron(c *router.Context) { | 106 func fetchCRLCron(c *router.Context) { |
| 98 list, err := caServer.ListCAs(c.Context, nil) | 107 list, err := caServer.ListCAs(c.Context, nil) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 149 |
| 141 // statusFromErrs returns 500 if any of gRPC errors is codes.Internal. | 150 // statusFromErrs returns 500 if any of gRPC errors is codes.Internal. |
| 142 func statusFromErrs(errs []error) int { | 151 func statusFromErrs(errs []error) int { |
| 143 for _, err := range errs { | 152 for _, err := range errs { |
| 144 if grpc.Code(err) == codes.Internal { | 153 if grpc.Code(err) == codes.Internal { |
| 145 return http.StatusInternalServerError | 154 return http.StatusInternalServerError |
| 146 } | 155 } |
| 147 } | 156 } |
| 148 return http.StatusOK | 157 return http.StatusOK |
| 149 } | 158 } |
| OLD | NEW |