diff --git a/models/etcd/ignition.go b/models/etcd/ignition.go index 902e8dbb..53396e01 100644 --- a/models/etcd/ignition.go +++ b/models/etcd/ignition.go @@ -20,8 +20,6 @@ func (d *driver) PutTemplate(ctx context.Context, role, id string, template stri if metadata == nil { return errors.New("metadata should not be nil") } -RETRY: - now := time.Now() target := path.Join(KeyIgnitionsTemplate, role, id) meta := path.Join(KeyIgnitionsMetadata, role, id) metaJSON, err := json.Marshal(metadata) @@ -41,10 +39,10 @@ RETRY: if !tresp.Succeeded { time.Sleep(1 * time.Nanosecond) - goto RETRY + return sabakan.ErrConflicted } - d.addLog(ctx, now, tresp.Header.Revision, sabakan.AuditIgnition, role, "put", + d.addLog(ctx, time.Now(), tresp.Header.Revision, sabakan.AuditIgnition, role, "put", fmt.Sprintf("id=%s\n%s", id, template)) tmplPrefix := path.Join(KeyIgnitionsTemplate, role) + "/" diff --git a/models/etcd/ignition_test.go b/models/etcd/ignition_test.go index cc84f55e..250f33d0 100644 --- a/models/etcd/ignition_test.go +++ b/models/etcd/ignition_test.go @@ -23,6 +23,10 @@ func testTemplate(t *testing.T) { if err != nil { t.Fatal(err) } + err = d.PutTemplate(context.Background(), "cs", id, "data", map[string]string{}) + if err != sabakan.ErrConflicted { + t.Fatal(err) + } ign, err := d.GetTemplate(context.Background(), "cs", id) if err != nil {