timflannagan/rukpak

bundle unpack failing silently when pod log stream is empty (e.g. `{}`)

github-actions opened this issue · 1 comments

// TODO: bundle unpack failing silently when pod log stream is empty (e.g. `{}`)

		pod.Spec.AutomountServiceAccountToken = &automountServiceAccountToken
		pod.Spec.Volumes = []corev1.Volume{
			{Name: "util", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
			{Name: "manifests", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
		}
		pod.Spec.RestartPolicy = corev1.RestartPolicyNever
		if bundle.Spec.Source.Type == "git" {
			// Note: use host networking (hack) so we can resolve https://github.com references in the
			// Bundle's spec.Source.Git.Repository. Maybe we should revisit having the user inline https://github.com?
			pod.Spec.HostNetwork = true
		}

		targetInitContainers := 1
		if bundle.Spec.Source.Type == "git" {
			targetInitContainers = 2
		}
		if len(pod.Spec.InitContainers) != targetInitContainers {
			pod.Spec.InitContainers = make([]corev1.Container, targetInitContainers)
		}
		pod.Spec.InitContainers[0].Name = "install-unpack"
		pod.Spec.InitContainers[0].Image = r.UnpackImage
		pod.Spec.InitContainers[0].ImagePullPolicy = corev1.PullIfNotPresent
		pod.Spec.InitContainers[0].Command = []string{"cp", "-Rv", "/unpack", "/util/unpack"}
		pod.Spec.InitContainers[0].VolumeMounts = []corev1.VolumeMount{{Name: "util", MountPath: "/util"}}

		// Note: initContainer so we can ensure the repository has been cloned
		// at the bundle.Spec.Source.Git.Ref before we unpack the Bundle contents
		// that are stored in the repository.
		if bundle.Spec.Source.Type == "git" {
			pod.Spec.InitContainers[1].Name = "clone-repository"
			pod.Spec.InitContainers[1].Image = "bitnami/git:latest"
			pod.Spec.InitContainers[1].ImagePullPolicy = corev1.PullIfNotPresent
			// TODO: length check
			// TODO: function responsible for determine which ref to use
			// TODO: bundle unpack failing silently when pod log stream is empty (e.g. `{}`)
			// TODO: bundle has an image custom column -- maybe we need a source type configuration instead?
			// TODO: bundleinstance reporting a successful installation state despite installing nothing.
			source := bundle.Spec.Source.Git
			repository := source.Repository
			directory := "./manifests"
			if source.Directory != "" {
				directory = source.Directory
			}
			checkedCommand := fmt.Sprintf("git clone %s && cd %s && git checkout %s && cp -r %s/* /manifests", repository, strings.Split(repository, "/")[4], source.Ref.Commit, directory)
			pod.Spec.InitContainers[1].Command = []string{"/bin/bash", "-c", checkedCommand}
			pod.Spec.InitContainers[1].VolumeMounts = []corev1.VolumeMount{{Name: "util", MountPath: "/util"}, {Name: "manifests", MountPath: "/manifests"}}
		}

		if len(pod.Spec.Containers) != 1 {
			pod.Spec.Containers = make([]corev1.Container, 1)
		}

		if bundle.Spec.Source.Type == "image" {
			pod.Spec.Containers[0].Name = bundleUnpackContainerName
			pod.Spec.Containers[0].Image = bundle.Spec.Source.Image.Ref
			pod.Spec.Containers[0].ImagePullPolicy = corev1.PullAlways
			pod.Spec.Containers[0].Command = []string{"/util/unpack", "--bundle-dir", "/manifests"}
			pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{{Name: "util", MountPath: "/util"}}
			return nil
		}
		if bundle.Spec.Source.Type == "git" {
			pod.Spec.Containers[0].Name = bundleUnpackContainerName
			pod.Spec.Containers[0].Image = "bitnami/git:latest"
			pod.Spec.Containers[0].ImagePullPolicy = corev1.PullAlways
			pod.Spec.Containers[0].Command = []string{"/util/unpack", "--bundle-dir", "/manifests"}
			pod.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{{Name: "util", MountPath: "/util"}, {Name: "manifests", MountPath: "/manifests"}}
			return nil
		}
		return nil
	})
}

This issue has become stale because it has been open 60 days with no activity. The maintainers of this repo will remove this label during issue triage or it will be removed automatically after an update. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.