mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Do not leave stale entries on etcd on a failed update operation (#6048)
This commit is contained in:
parent
577d10674d
commit
05a64dee95
@ -102,10 +102,8 @@ func (c *coreDNS) list(key string) ([]SrvRecord, error) {
|
||||
|
||||
// Adds DNS entries into etcd endpoint in CoreDNS etcd message format.
|
||||
func (c *coreDNS) Put(bucket string) error {
|
||||
var err error
|
||||
for ip := range c.domainIPs {
|
||||
var bucketMsg []byte
|
||||
bucketMsg, err = newCoreDNSMsg(bucket, ip, c.domainPort, defaultTTL)
|
||||
bucketMsg, err := newCoreDNSMsg(bucket, ip, c.domainPort, defaultTTL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -115,8 +113,14 @@ func (c *coreDNS) Put(bucket string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), defaultContextTimeout)
|
||||
_, err = kapi.Set(ctx, key, string(bucketMsg), nil)
|
||||
cancel()
|
||||
if err != nil {
|
||||
ctx, cancel = context.WithTimeout(context.Background(), defaultContextTimeout)
|
||||
kapi.Delete(ctx, key, &etcd.DeleteOptions{Recursive: true})
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// Removes DNS entries added in Put().
|
||||
|
Loading…
Reference in New Issue
Block a user