// OutOfSync checks if the container is out of sync with the service definition. // It looks if the the service hash container label is the same as the computed one. func (s *Service) OutOfSync(ctx context.Context, c *container.Container) (bool, error) { if c.ImageConfig() != s.serviceConfig.Image { logrus.Debugf("Images for %s do not match %s!=%s", c.Name(), c.ImageConfig(), s.serviceConfig.Image) return true, nil } expectedHash := config.GetServiceHash(s.name, s.Config()) if c.Hash() != expectedHash { logrus.Debugf("Hashes for %s do not match %s!=%s", c.Name(), c.Hash(), expectedHash) return true, nil } image, err := image.InspectImage(ctx, s.clientFactory.Create(s), c.ImageConfig()) if err != nil { if client.IsErrImageNotFound(err) { logrus.Debugf("Image %s do not exist, do not know if it's out of sync", c.Image()) return false, nil } return false, err } logrus.Debugf("Checking existing image name vs id: %s == %s", image.ID, c.Image()) return image.ID != c.Image(), err }