func (h *syncHandler) Handler(event *events.Event, cli *client.RancherClient) error {
	log := logrus.WithFields(logrus.Fields{
		"eventName":  event.Name,
		"eventID":    event.ID,
		"resourceID": event.ResourceID,
	})
	log.Infof("Rancher event: %#v", event)
	labels := map[string]string{}

	containerLabels, err := h.parseContainerLabels(event)
	if err != nil {
		log.Errorf("Failed to read labels", err)
		return util.CreateAndPublishReply(event, cli)
	}

	namespace := containerLabels["io.kubernetes.pod.namespace"]
	name := containerLabels["io.kubernetes.pod.name"]
	if namespace == "" || name == "" {
		return util.CreateAndPublishReply(event, cli)
	}

	labels["io.rancher.service.deployment.unit"] = containerLabels["io.kubernetes.pod.uid"]
	labels["io.rancher.stack.name"] = namespace

	if isPodContainer(containerLabels) {
		labels["io.rancher.container.network"] = "true"
		labels["io.rancher.service.launch.config"] = "io.rancher.service.primary.launch.config"
		labels["io.rancher.container.display_name"] = containerLabels["io.kubernetes.pod.name"]
		if found, err := h.copyPodLabels(namespace, name, labels); err != nil {
			return err
		} else if !found {
			return util.CreateAndPublishReply(event, cli)
		}
	} else {
		labels["io.rancher.container.display_name"] = containerLabels["io.kubernetes.container.name"]
	}

	return h.replyWithLabels(event, cli, labels)
}
func (h *PingHandler) Handler(event *revents.Event, cli *client.RancherClient) error {
	if err := util.CreateAndPublishReply(event, cli); err != nil {
		return err
	}
	return nil
}
func (h *syncHandler) Handler(event *revents.Event, cli *client.RancherClient) error {
	log.Infof("Received event: Name: %s, Event Id: %s, Resource Id: %s", event.Name, event.Id, event.ResourceId)

	namespace, name := h.getPod(event)
	if namespace == "" || name == "" {
		if err := util.CreateAndPublishReply(event, cli); err != nil {
			return err
		}
		return nil
	}

	pod, err := h.kClient.Pod.ByName(namespace, name)
	if err != nil {
		log.Warnf("Error looking up pod: %#v", err)
		if apiErr, ok := err.(*client.ApiError); ok && apiErr.StatusCode == 404 {
			if err := util.CreateAndPublishReply(event, cli); err != nil {
				return err
			}
			return nil
		}
		return err
	}

	/*
	   Building this:
	   {instancehostmap: {
	       instance: {
	           +data: {
	               +fields: {
	                 labels: {
	*/
	replyData := make(map[string]interface{})
	ihm := make(map[string]interface{})
	i := make(map[string]interface{})
	data := make(map[string]interface{})
	fields := make(map[string]interface{})
	labels := make(map[string]string)

	replyData["instanceHostMap"] = ihm
	ihm["instance"] = i
	i["+data"] = data
	data["+fields"] = fields
	fields["+labels"] = labels

	for key, v := range pod.Metadata.Labels {
		if val, ok := v.(string); ok {
			labels[key] = val
		}
	}

	labels["io.rancher.service.deployment.unit"] = pod.Metadata.Uid
	labels["io.rancher.stack.name"] = pod.Metadata.Namespace

	reply := util.NewReply(event)
	reply.ResourceType = "instanceHostMap"
	reply.ResourceId = event.ResourceId
	reply.Data = replyData
	log.Infof("Reply: %+v", reply)
	err = util.PublishReply(reply, cli)
	if err != nil {
		return err
	}
	return nil
}