Chromium Code Reviews| Index: milo/common/config.go |
| diff --git a/milo/common/config.go b/milo/common/config.go |
| index bd73303dceb29f68c6efcfd451935bb3ace0f628..34233c25a57dbc9ca4f5e9cda17adc6808bfc28a 100644 |
| --- a/milo/common/config.go |
| +++ b/milo/common/config.go |
| @@ -34,13 +34,12 @@ import ( |
| // Project is a LUCI project. |
| type Project struct { |
| - // The ID of the project, as per self defined. This is not the luci-config |
| - // name. |
| + // ID of the project, as per self defined. This is the luci-config name. |
| ID string `gae:"$id"` |
| - // The luci-config name of the project. |
| - Name string |
| - // The Project data in protobuf binary format. |
| + // Data is the Project data in protobuf binary format. |
| Data []byte `gae:",noindex"` |
| + // Revision is the latest revision we have of this project's config. |
| + Revision string |
| } |
| // The key for the service config entity in datastore. |
| @@ -188,39 +187,42 @@ func UpdateProjectConfigs(c context.Context) error { |
| configs []*config.Project |
| metas []*cfgclient.Meta |
| ) |
| + |
| logging.Debugf(c, "fetching configs for %s", cfgName) |
| if err := cfgclient.Projects(c, cfgclient.AsService, cfgName, textproto.Slice(&configs), &metas); err != nil { |
|
iannucci
2017/07/15 00:45:53
var merr MultiError
if ! nil {
merr = err.(Mult
Ryan Tseng
2017/07/15 00:53:57
Done.
|
| logging.WithError(err).Errorf(c, "Encountered error while getting project config for %s", cfgName) |
| - return err |
| + // We can continue with the ones that work still. |
| } |
| // A map of project ID to project. |
| projects := map[string]*Project{} |
| for i, proj := range configs { |
| - projectName, _, _ := metas[i].ConfigSet.SplitProject() |
| + meta := metas[i] |
| + projectName, _, _ := meta.ConfigSet.SplitProject() |
| logging.Infof(c, "Prossing %s", projectName) |
| - if dup, ok := projects[proj.ID]; ok { |
| - return fmt.Errorf( |
| - "Duplicate project ID: %s. (%s and %s)", proj.ID, dup.Name, projectName) |
| - } |
| p := &Project{ |
| - ID: proj.ID, |
| - Name: string(projectName), |
| + ID: string(projectName), |
| + Revision: meta.Revision, |
| } |
| - projects[proj.ID] = p |
| var err error |
| p.Data, err = proto.Marshal(proj) |
| if err != nil { |
| - return err |
| + logging.WithError(err).Errorf(c, "Encountered error while processing project %s", projectName) |
| + // Set this to nil to signal this project exists but we don't want to update it. |
| + projects[proj.ID] = nil |
| + continue |
| } |
| + projects[proj.ID] = p |
| } |
| // Now load all the data into the datastore. |
| projs := make([]*Project, 0, len(projects)) |
| for _, proj := range projects { |
| - projs = append(projs, proj) |
| + if proj != nil { |
| + projs = append(projs, proj) |
| + } |
| } |
| if err := datastore.Put(c, projs); err != nil { |
| return err |
| @@ -236,9 +238,7 @@ func UpdateProjectConfigs(c context.Context) error { |
| toDelete = append(toDelete, proj) |
| } |
| } |
| - datastore.Delete(c, toDelete) |
| - |
| - return nil |
| + return datastore.Delete(c, toDelete) |
| } |
| // GetAllProjects returns all registered projects. |