diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go index 6d9b3ff64d..42c38c3cc9 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/controller_test.go @@ -26,7 +26,6 @@ import ( "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" appsv1 "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" @@ -202,45 +201,6 @@ func TestKeptnWorkloadVersionReconciler_reconcileDeployment_UnsupportedReference require.Equal(t, apicommon.StateUnknown, keptnState) } -func TestKeptnWorkloadVersionReconciler_IsPodRunning(t *testing.T) { - p1 := makeNominatedPod("pod1", "node1", v1.PodRunning) - p2 := makeNominatedPod("pod2", "node1", v1.PodPending) - podList := &v1.PodList{Items: []v1.Pod{p1, p2}} - podList2 := &v1.PodList{Items: []v1.Pod{p2}} - r := &KeptnWorkloadVersionReconciler{ - Client: k8sfake.NewClientBuilder().WithLists(podList).Build(), - } - isPodRunning, err := r.isPodRunning(context.TODO(), klcv1beta1.ResourceReference{UID: "pod1"}, "node1") - require.Nil(t, err) - if !isPodRunning { - t.Errorf("Wrong!") - } - - r2 := &KeptnWorkloadVersionReconciler{ - Client: k8sfake.NewClientBuilder().WithLists(podList2).Build(), - } - isPodRunning, err = r2.isPodRunning(context.TODO(), klcv1beta1.ResourceReference{UID: "pod1"}, "node1") - require.Nil(t, err) - if isPodRunning { - t.Errorf("Wrong!") - } - -} - -func makeNominatedPod(podName string, nodeName string, phase v1.PodPhase) v1.Pod { - return v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: nodeName, - Name: podName, - UID: types.UID(podName), - }, - Status: v1.PodStatus{ - Phase: phase, - NominatedNodeName: nodeName, - }, - } -} - func makeReplicaSet(name string, namespace string, wanted *int32, available int32) *appsv1.ReplicaSet { return &appsv1.ReplicaSet{ diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go index 027d8ef705..20d132d379 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_deploymentstate.go @@ -8,9 +8,7 @@ import ( apicommon "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1/common" controllererrors "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/errors" appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" ) func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context, workloadVersion *klcv1beta1.KeptnWorkloadVersion) (apicommon.KeptnState, error) { @@ -18,8 +16,6 @@ func (r *KeptnWorkloadVersionReconciler) reconcileDeployment(ctx context.Context var err error switch workloadVersion.Spec.ResourceReference.Kind { - case "Pod": - isRunning, err = r.isPodRunning(ctx, workloadVersion.Spec.ResourceReference, workloadVersion.Namespace) case "ReplicaSet": isRunning, err = r.isReplicaSetRunning(ctx, workloadVersion.Spec.ResourceReference, workloadVersion.Namespace) case "StatefulSet": @@ -71,22 +67,6 @@ func (r *KeptnWorkloadVersionReconciler) isDaemonSetRunning(ctx context.Context, return daemonSet.Status.DesiredNumberScheduled == daemonSet.Status.NumberReady, nil } -func (r *KeptnWorkloadVersionReconciler) isPodRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { - podList := &corev1.PodList{} - if err := r.Client.List(ctx, podList, client.InNamespace(namespace)); err != nil { - return false, err - } - for _, p := range podList.Items { - if p.UID == resource.UID { - if p.Status.Phase == corev1.PodRunning { - return true, nil - } - return false, nil - } - } - return false, nil -} - func (r *KeptnWorkloadVersionReconciler) isStatefulSetRunning(ctx context.Context, resource klcv1beta1.ResourceReference, namespace string) (bool, error) { sts := appsv1.StatefulSet{} err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &sts) diff --git a/lifecycle-operator/test/component/workload/workload_test.go b/lifecycle-operator/test/component/workload/workload_test.go index 61260780b6..d4ca919427 100644 --- a/lifecycle-operator/test/component/workload/workload_test.go +++ b/lifecycle-operator/test/component/workload/workload_test.go @@ -77,7 +77,7 @@ func createWorkloadInCluster(name string, namespace string, version string, appl Spec: klcv1beta1.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1beta1.ResourceReference{UID: types.UID("uid"), Kind: "Pod", Name: "pod1"}, + ResourceReference: klcv1beta1.ResourceReference{UID: types.UID("uid"), Kind: "ReplicaSet", Name: "replicaset1"}, }, } By("Invoking Reconciling for Create")