code: func (e *CombinedEtcdClient) AttachLease(leaseDuration time.Duration) error {
  	ttlKeysPrefix := e.cfg.ttlKeysDirectory
  	// Make sure that ttlKeysPrefix is ended with "/" so that we only get children "directories".
  	if !strings.HasSuffix(ttlKeysPrefix, "/") {
  		ttlKeysPrefix += "/"
  	}
  	ctx := context.Background()
  
  	v3client, err := e.clientV3()
  	if err != nil {
  		return err
  	}
  	defer v3client.Close()
  	objectsResp, err := v3client.KV.Get(ctx, ttlKeysPrefix, clientv3.WithPrefix())
  	if err != nil {
  		return fmt.Errorf("Error while getting objects to attach to the lease")
  	}
  
  	lease, err := v3client.Lease.Grant(ctx, int64(leaseDuration/time.Second))
  	if err != nil {
  		return fmt.Errorf("Error while creating lease: %v", err)
  	}
  	klog.Infof("Lease with TTL: %v created", lease.TTL)
  
  	klog.Infof("Attaching lease to %d entries", len(objectsResp.Kvs))
  	for _, kv := range objectsResp.Kvs {
  		putResp, err := v3client.KV.Put(ctx, string(kv.Key), string(kv.Value), clientv3.WithLease(lease.ID), clientv3.WithPrevKV())
  		if err != nil {
  			klog.Errorf("Error while attaching lease to: %s", string(kv.Key))
  		}
  		if bytes.Compare(putResp.PrevKv.Value, kv.Value) != 0 {
  			return fmt.Errorf("concurrent access to key detected when setting lease on %s, expected previous value of %s but got %s",
  				kv.Key, kv.Value, putResp.PrevKv.Value)
  		}
  	}
  	return nil
  }
docs: // AttachLease attaches leases of the given leaseDuration to all the  etcd objects under
  // ttlKeysDirectory specified in this client's config.