code: func (m *ReplicaSetControllerRefManager) ReleaseReplicaSet(replicaSet *apps.ReplicaSet) error {
  	klog.V(2).Infof("patching ReplicaSet %s_%s to remove its controllerRef to %s/%s:%s",
  		replicaSet.Namespace, replicaSet.Name, m.controllerKind.GroupVersion(), m.controllerKind.Kind, m.Controller.GetName())
  	deleteOwnerRefPatch := fmt.Sprintf(`{"metadata":{"ownerReferences":[{"$patch":"delete","uid":"%s"}],"uid":"%s"}}`, m.Controller.GetUID(), replicaSet.UID)
  	err := m.rsControl.PatchReplicaSet(replicaSet.Namespace, replicaSet.Name, []byte(deleteOwnerRefPatch))
  	if err != nil {
  		if errors.IsNotFound(err) {
  			// If the ReplicaSet no longer exists, ignore it.
  			return nil
  		}
  		if errors.IsInvalid(err) {
  			// Invalid error will be returned in two cases: 1. the ReplicaSet
  			// has no owner reference, 2. the uid of the ReplicaSet doesn't
  			// match, which means the ReplicaSet is deleted and then recreated.
  			// In both cases, the error can be ignored.
  			return nil
  		}
  	}
  	return err
  }
docs: // ReleaseReplicaSet sends a patch to free the ReplicaSet from the control of the Deployment controller.
  // It returns the error if the patching fails. 404 and 422 errors are ignored.