Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(931)

Unified Diff: milo/common/config.go

Issue 2980153002: Milo: Fix project importer so it doesn't error out on a bad config (Closed)
Patch Set: stuff Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | milo/common/config_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | milo/common/config_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698