code: func (ssc *StatefulSetController) sync(key string) error {
  	startTime := time.Now()
  	defer func() {
  		klog.V(4).Infof("Finished syncing statefulset %q (%v)", key, time.Since(startTime))
  	}()
  
  	namespace, name, err := cache.SplitMetaNamespaceKey(key)
  	if err != nil {
  		return err
  	}
  	set, err := ssc.setLister.StatefulSets(namespace).Get(name)
  	if errors.IsNotFound(err) {
  		klog.Infof("StatefulSet has been deleted %v", key)
  		return nil
  	}
  	if err != nil {
  		utilruntime.HandleError(fmt.Errorf("unable to retrieve StatefulSet %v from store: %v", key, err))
  		return err
  	}
  
  	selector, err := metav1.LabelSelectorAsSelector(set.Spec.Selector)
  	if err != nil {
  		utilruntime.HandleError(fmt.Errorf("error converting StatefulSet %v selector: %v", key, err))
  		// This is a non-transient error, so don't retry.
  		return nil
  	}
  
  	if err := ssc.adoptOrphanRevisions(set); err != nil {
  		return err
  	}
  
  	pods, err := ssc.getPodsForStatefulSet(set, selector)
  	if err != nil {
  		return err
  	}
  
  	return ssc.syncStatefulSet(set, pods)
  }
docs: // sync syncs the given statefulset.