From 46524a72e44afb9089c6939a86481a99f8465da0 Mon Sep 17 00:00:00 2001 From: RealAnna <89971034+RealAnna@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:46:11 +0100 Subject: [PATCH] fix(operator): Changed checks on pod owner replicas (#412) Signed-off-by: RealAnna --- kuttl-test.yaml | 2 - operator/api/v1alpha1/keptnworkload_types.go | 1 + ...cycle.keptn.sh_keptnworkloadinstances.yaml | 3 + .../lifecycle.keptn.sh_keptnworkloads.yaml | 3 + .../keptnworkloadinstance/controller_test.go | 88 ++++++++++++++++++- .../reconcile_deploymentstate.go | 65 +++++--------- operator/webhooks/pod_mutating_webhook.go | 2 +- .../e2e/fake/v1alpha1/keptnworkload_types.go | 1 + scheduler/test/e2e/scheduler_test.go | 7 +- test/.build/install.yaml | 16 ---- .../00-assert.yaml | 3 +- .../00-install.yaml | 4 +- .../00-teststep.yaml | 4 + .../01-assert.yaml | 3 - .../simple-deployment/00-assert.yaml | 1 - .../simple-deployment/00-install.yaml | 3 - .../simple-deployment/00-teststep.yaml | 4 + .../simple-deployment/01-assert.yaml | 2 - .../00-assert.yaml | 10 +++ .../00-install.yaml | 45 ++++++++++ .../00-teststep.yaml | 4 + .../01-assert.yaml | 22 +++++ .../02-assert.yaml | 16 ++++ .../02-install.yaml | 33 +++++++ 24 files changed, 264 insertions(+), 78 deletions(-) delete mode 100644 test/.build/install.yaml create mode 100644 test/integration/simple-deployment-annotated/00-teststep.yaml create mode 100644 test/integration/simple-deployment/00-teststep.yaml create mode 100644 test/integration/simple-statefulset-annotated/00-assert.yaml create mode 100644 test/integration/simple-statefulset-annotated/00-install.yaml create mode 100644 test/integration/simple-statefulset-annotated/00-teststep.yaml create mode 100644 test/integration/simple-statefulset-annotated/01-assert.yaml create mode 100644 test/integration/simple-statefulset-annotated/02-assert.yaml create mode 100644 test/integration/simple-statefulset-annotated/02-install.yaml diff --git a/kuttl-test.yaml b/kuttl-test.yaml index 3514ed514d..4cef0d4ec5 100644 --- a/kuttl-test.yaml +++ b/kuttl-test.yaml @@ -1,8 +1,6 @@ apiVersion: kuttl.dev/v1beta1 kind: TestSuite crdDir: ./operator/config/crd/bases -commands: - - command: kubectl apply -f ./test/.build/install.yaml --wait testDirs: - ./test/integration/ timeout: 150 diff --git a/operator/api/v1alpha1/keptnworkload_types.go b/operator/api/v1alpha1/keptnworkload_types.go index f032312216..0c41577b33 100644 --- a/operator/api/v1alpha1/keptnworkload_types.go +++ b/operator/api/v1alpha1/keptnworkload_types.go @@ -71,6 +71,7 @@ type KeptnWorkloadList struct { type ResourceReference struct { UID types.UID `json:"uid"` Kind string `json:"kind"` + Name string `json:"name"` } func init() { diff --git a/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml b/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml index 7f641baa2a..5b72b0bda0 100644 --- a/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml +++ b/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloadinstances.yaml @@ -95,6 +95,8 @@ spec: properties: kind: type: string + name: + type: string uid: description: UID is a type that holds unique ID values, including UUIDs. Because we don't ONLY use UUIDs, this is an alias to @@ -103,6 +105,7 @@ spec: type: string required: - kind + - name - uid type: object traceId: diff --git a/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml b/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml index ba8ef74c56..a41fe78ff6 100644 --- a/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml +++ b/operator/config/crd/bases/lifecycle.keptn.sh_keptnworkloads.yaml @@ -64,6 +64,8 @@ spec: properties: kind: type: string + name: + type: string uid: description: UID is a type that holds unique ID values, including UUIDs. Because we don't ONLY use UUIDs, this is an alias to @@ -72,6 +74,7 @@ spec: type: string required: - kind + - name - uid type: object version: diff --git a/operator/controllers/keptnworkloadinstance/controller_test.go b/operator/controllers/keptnworkloadinstance/controller_test.go index 7b1206b66c..2adf2c37c2 100644 --- a/operator/controllers/keptnworkloadinstance/controller_test.go +++ b/operator/controllers/keptnworkloadinstance/controller_test.go @@ -5,6 +5,7 @@ import ( klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" "github.com/stretchr/testify/require" testrequire "github.com/stretchr/testify/require" + 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" @@ -12,6 +13,47 @@ import ( "testing" ) +func TestKeptnWorkloadInstanceReconciler_isReferencedWorkloadRunning(t *testing.T) { + + rep := int32(1) + replicasetFail := makeReplicaSet("myrep", "default", &rep, 0) + statefulsetFail := makeStatefulSet("mystat", "default", &rep, 0) + + r := &KeptnWorkloadInstanceReconciler{ + Client: fake.NewClientBuilder().WithObjects(replicasetFail, statefulsetFail).Build(), + } + isOwnerRunning, err := r.isReferencedWorkloadRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "myrep", Name: "myrep", Kind: "ReplicaSet"}, "default") + testrequire.Nil(t, err) + if isOwnerRunning { + t.Errorf("Should fail!") + } + + isOwnerRunning, err = r.isReferencedWorkloadRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "mystat", Name: "mystat", Kind: "StatefulSet"}, "default") + testrequire.Nil(t, err) + if isOwnerRunning { + t.Errorf("Should fail!") + } + + replicasetPass := makeReplicaSet("myrep", "default", &rep, 1) + statefulsetPass := makeStatefulSet("mystat", "default", &rep, 1) + + r2 := &KeptnWorkloadInstanceReconciler{ + Client: fake.NewClientBuilder().WithObjects(replicasetPass, statefulsetPass).Build(), + } + isOwnerRunning, err = r2.isReferencedWorkloadRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "myrep", Name: "myrep", Kind: "ReplicaSet"}, "default") + testrequire.Nil(t, err) + if !isOwnerRunning { + t.Errorf("Should find a replica owner!") + } + + isOwnerRunning, err = r2.isReferencedWorkloadRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "mystat", Name: "mystat", Kind: "StatefulSet"}, "default") + testrequire.Nil(t, err) + if !isOwnerRunning { + t.Errorf("Should find a stateful set owner!") + } + +} + func TestKeptnWorkloadInstanceReconciler_IsPodRunning(t *testing.T) { p1 := makeNominatedPod("pod1", "node1", v1.PodRunning) p2 := makeNominatedPod("pod2", "node1", v1.PodPending) @@ -20,7 +62,7 @@ func TestKeptnWorkloadInstanceReconciler_IsPodRunning(t *testing.T) { r := &KeptnWorkloadInstanceReconciler{ Client: fake.NewClientBuilder().WithLists(podList).Build(), } - isPodRunning, err := r.isPodRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: types.UID("pod1")}, "node1") + isPodRunning, err := r.isPodRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "pod1"}, "node1") testrequire.Nil(t, err) if !isPodRunning { t.Errorf("Wrong!") @@ -29,7 +71,7 @@ func TestKeptnWorkloadInstanceReconciler_IsPodRunning(t *testing.T) { r2 := &KeptnWorkloadInstanceReconciler{ Client: fake.NewClientBuilder().WithLists(podList2).Build(), } - isPodRunning, err = r2.isPodRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: types.UID("pod1")}, "node1") + isPodRunning, err = r2.isPodRunning(context.TODO(), klcv1alpha1.ResourceReference{UID: "pod1"}, "node1") testrequire.Nil(t, err) if isPodRunning { t.Errorf("Wrong!") @@ -51,6 +93,48 @@ func makeNominatedPod(podName string, nodeName string, phase v1.PodPhase) v1.Pod } } +func makeReplicaSet(name string, namespace string, wanted *int32, available int32) *appsv1.ReplicaSet { + + return &appsv1.ReplicaSet{ + TypeMeta: metav1.TypeMeta{ + Kind: "ReplicaSet", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + UID: types.UID(name), + }, + Spec: appsv1.ReplicaSetSpec{ + Replicas: wanted, + }, + Status: appsv1.ReplicaSetStatus{ + AvailableReplicas: available, + }, + } + +} + +func makeStatefulSet(name string, namespace string, wanted *int32, available int32) *appsv1.StatefulSet { + + return &appsv1.StatefulSet{ + TypeMeta: metav1.TypeMeta{ + Kind: "StatefulSet", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + UID: types.UID(name), + }, + Spec: appsv1.StatefulSetSpec{ + Replicas: wanted, + }, + Status: appsv1.StatefulSetStatus{ + AvailableReplicas: available, + }, + } + +} + func Test_getLatestAppVersion(t *testing.T) { type args struct { apps *klcv1alpha1.KeptnAppVersionList diff --git a/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go b/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go index 447d9ac5b3..fcba34fddf 100644 --- a/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go +++ b/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go @@ -2,12 +2,10 @@ package keptnworkloadinstance import ( "context" - klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -24,7 +22,7 @@ func (r *KeptnWorkloadInstanceReconciler) reconcileDeployment(ctx context.Contex workloadInstance.Status.DeploymentStatus = common.StateProgressing } } else { - isReplicaRunning, err := r.isReplicaSetRunning(ctx, workloadInstance.Spec.ResourceReference, workloadInstance.Namespace) + isReplicaRunning, err := r.isReferencedWorkloadRunning(ctx, workloadInstance.Spec.ResourceReference, workloadInstance.Namespace) if err != nil { return common.StateUnknown, err } @@ -42,24 +40,30 @@ func (r *KeptnWorkloadInstanceReconciler) reconcileDeployment(ctx context.Contex return workloadInstance.Status.DeploymentStatus, nil } -func (r *KeptnWorkloadInstanceReconciler) isReplicaSetRunning(ctx context.Context, resource klcv1alpha1.ResourceReference, namespace string) (bool, error) { - replica := &appsv1.ReplicaSetList{} - if err := r.Client.List(ctx, replica, client.InNamespace(namespace)); err != nil { - return false, err - } - for _, re := range replica.Items { - if re.UID == resource.UID { - replicas, err := r.getDesiredReplicas(ctx, re.OwnerReferences[0], namespace) - if err != nil { - return false, err - } - if re.Status.ReadyReplicas == replicas { - return true, nil - } - return false, nil +func (r *KeptnWorkloadInstanceReconciler) isReferencedWorkloadRunning(ctx context.Context, resource klcv1alpha1.ResourceReference, namespace string) (bool, error) { + + var replicas *int32 + var desiredReplicas int32 + switch resource.Kind { + case "ReplicaSet": + rep := appsv1.ReplicaSet{} + err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &rep) + if err != nil { + return false, err } + replicas = rep.Spec.Replicas + desiredReplicas = rep.Status.AvailableReplicas + case "StatefulSet": + sts := appsv1.StatefulSet{} + err := r.Client.Get(ctx, types.NamespacedName{Name: resource.Name, Namespace: namespace}, &sts) + if err != nil { + return false, err + } + replicas = sts.Spec.Replicas + desiredReplicas = sts.Status.AvailableReplicas } - return false, nil + + return *replicas == desiredReplicas, nil } @@ -78,26 +82,3 @@ func (r *KeptnWorkloadInstanceReconciler) isPodRunning(ctx context.Context, reso } return false, nil } - -func (r *KeptnWorkloadInstanceReconciler) getDesiredReplicas(ctx context.Context, reference v1.OwnerReference, namespace string) (int32, error) { - var replicas *int32 - switch reference.Kind { - case "Deployment": - dep := appsv1.Deployment{} - err := r.Client.Get(ctx, types.NamespacedName{Name: reference.Name, Namespace: namespace}, &dep) - if err != nil { - return 0, err - } - replicas = dep.Spec.Replicas - case "StatefulSet": - sts := appsv1.StatefulSet{} - err := r.Client.Get(ctx, types.NamespacedName{Name: reference.Name, Namespace: namespace}, &sts) - if err != nil { - return 0, err - } - replicas = sts.Spec.Replicas - } - - return *replicas, nil - -} diff --git a/operator/webhooks/pod_mutating_webhook.go b/operator/webhooks/pod_mutating_webhook.go index 01504bbf5d..e478fdbc81 100644 --- a/operator/webhooks/pod_mutating_webhook.go +++ b/operator/webhooks/pod_mutating_webhook.go @@ -429,7 +429,7 @@ func (a *PodMutatingWebhook) generateWorkload(ctx context.Context, pod *corev1.P Spec: klcv1alpha1.KeptnWorkloadSpec{ AppName: applicationName, Version: version, - ResourceReference: klcv1alpha1.ResourceReference{UID: ownerRef.UID, Kind: ownerRef.Kind}, + ResourceReference: klcv1alpha1.ResourceReference{UID: ownerRef.UID, Kind: ownerRef.Kind, Name: ownerRef.Name}, PreDeploymentTasks: preDeploymentTasks, PostDeploymentTasks: postDeploymentTasks, PreDeploymentEvaluations: preDeploymentEvaluation, diff --git a/scheduler/test/e2e/fake/v1alpha1/keptnworkload_types.go b/scheduler/test/e2e/fake/v1alpha1/keptnworkload_types.go index 3c977b3efb..f1265868bf 100644 --- a/scheduler/test/e2e/fake/v1alpha1/keptnworkload_types.go +++ b/scheduler/test/e2e/fake/v1alpha1/keptnworkload_types.go @@ -68,6 +68,7 @@ type KeptnWorkloadList struct { type ResourceReference struct { UID types.UID `json:"uid"` Kind string `json:"kind"` + Name string `json:"name"` } func init() { diff --git a/scheduler/test/e2e/scheduler_test.go b/scheduler/test/e2e/scheduler_test.go index eaa4b1f0a9..ea64a26fc1 100644 --- a/scheduler/test/e2e/scheduler_test.go +++ b/scheduler/test/e2e/scheduler_test.go @@ -146,7 +146,12 @@ func initWorkloadInstance() *testv1alpha1.KeptnWorkloadInstance { APIVersion: "lifecycle.keptn.sh/v1alpha1", }, ObjectMeta: metav1.ObjectMeta{Name: "myapp-myworkload-1.0.0", Namespace: "default"}, - Status: testv1alpha1.KeptnWorkloadInstanceStatus{PreDeploymentEvaluationStatus: "Succeeded"}, + Spec: testv1alpha1.KeptnWorkloadInstanceSpec{ + KeptnWorkloadSpec: testv1alpha1.KeptnWorkloadSpec{ + ResourceReference: testv1alpha1.ResourceReference{Name: "myfakeres"}, + }, + }, + Status: testv1alpha1.KeptnWorkloadInstanceStatus{}, } return &fakeInstance diff --git a/test/.build/install.yaml b/test/.build/install.yaml deleted file mode 100644 index c5bcbebb89..0000000000 --- a/test/.build/install.yaml +++ /dev/null @@ -1,16 +0,0 @@ - ---- -apiVersion: v1 -kind: Namespace -metadata: - name: test - annotations: - keptn.sh/lifecycle-toolkit: "enabled" - ---- -apiVersion: v1 -kind: Namespace -metadata: - name: test-annotation - annotations: - keptn.sh/lifecycle-toolkit: "enabled" \ No newline at end of file diff --git a/test/integration/simple-deployment-annotated/00-assert.yaml b/test/integration/simple-deployment-annotated/00-assert.yaml index 51e44e28d4..fadaaa4a22 100644 --- a/test/integration/simple-deployment-annotated/00-assert.yaml +++ b/test/integration/simple-deployment-annotated/00-assert.yaml @@ -4,6 +4,5 @@ metadata: labels: app: test name: test - namespace: test-annotation status: - readyReplicas: 1 + readyReplicas: 2 diff --git a/test/integration/simple-deployment-annotated/00-install.yaml b/test/integration/simple-deployment-annotated/00-install.yaml index 67404844d7..33a4366e7d 100644 --- a/test/integration/simple-deployment-annotated/00-install.yaml +++ b/test/integration/simple-deployment-annotated/00-install.yaml @@ -5,7 +5,6 @@ apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello - namespace: test-annotation spec: function: inline: @@ -20,14 +19,13 @@ metadata: labels: app: test name: test - namespace: test-annotation annotations: keptn.sh/workload: waiter keptn.sh/version: "0.4" keptn.sh/pre-deployment-tasks: pre-deployment-hello keptn.sh/post-deployment-tasks: pre-deployment-hello spec: - replicas: 1 + replicas: 2 selector: matchLabels: app: test diff --git a/test/integration/simple-deployment-annotated/00-teststep.yaml b/test/integration/simple-deployment-annotated/00-teststep.yaml new file mode 100644 index 0000000000..a96f3a8d8f --- /dev/null +++ b/test/integration/simple-deployment-annotated/00-teststep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl annotate ns $NAMESPACE keptn.sh/lifecycle-toolkit='enabled' \ No newline at end of file diff --git a/test/integration/simple-deployment-annotated/01-assert.yaml b/test/integration/simple-deployment-annotated/01-assert.yaml index cc669f7076..066a9b6297 100644 --- a/test/integration/simple-deployment-annotated/01-assert.yaml +++ b/test/integration/simple-deployment-annotated/01-assert.yaml @@ -2,15 +2,12 @@ apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnWorkload metadata: name: waiter-waiter - namespace: test-annotation - --- apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnWorkloadInstance metadata: name: waiter-waiter-0.4 - namespace: test-annotation status: currentPhase: Completed deploymentStatus: Succeeded diff --git a/test/integration/simple-deployment/00-assert.yaml b/test/integration/simple-deployment/00-assert.yaml index d736f0c458..e6f7dd679b 100644 --- a/test/integration/simple-deployment/00-assert.yaml +++ b/test/integration/simple-deployment/00-assert.yaml @@ -4,6 +4,5 @@ metadata: labels: app: test name: test - namespace: test status: readyReplicas: 1 diff --git a/test/integration/simple-deployment/00-install.yaml b/test/integration/simple-deployment/00-install.yaml index 9a15277876..d16150bc4e 100644 --- a/test/integration/simple-deployment/00-install.yaml +++ b/test/integration/simple-deployment/00-install.yaml @@ -1,11 +1,9 @@ ---- apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnTaskDefinition metadata: name: pre-deployment-hello - namespace: test spec: function: inline: @@ -20,7 +18,6 @@ metadata: labels: app: test name: test - namespace: test spec: replicas: 1 selector: diff --git a/test/integration/simple-deployment/00-teststep.yaml b/test/integration/simple-deployment/00-teststep.yaml new file mode 100644 index 0000000000..a96f3a8d8f --- /dev/null +++ b/test/integration/simple-deployment/00-teststep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl annotate ns $NAMESPACE keptn.sh/lifecycle-toolkit='enabled' \ No newline at end of file diff --git a/test/integration/simple-deployment/01-assert.yaml b/test/integration/simple-deployment/01-assert.yaml index 6f70e96281..c89bc51c67 100644 --- a/test/integration/simple-deployment/01-assert.yaml +++ b/test/integration/simple-deployment/01-assert.yaml @@ -2,7 +2,6 @@ apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnWorkload metadata: name: waiter-waiter - namespace: test --- @@ -10,7 +9,6 @@ apiVersion: lifecycle.keptn.sh/v1alpha1 kind: KeptnWorkloadInstance metadata: name: waiter-waiter-0.4 - namespace: test status: currentPhase: Completed deploymentStatus: Succeeded diff --git a/test/integration/simple-statefulset-annotated/00-assert.yaml b/test/integration/simple-statefulset-annotated/00-assert.yaml new file mode 100644 index 0000000000..f9f5ddebdc --- /dev/null +++ b/test/integration/simple-statefulset-annotated/00-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: statefultest + name: statefultest +status: + replicas: 2 + availableReplicas: 2 + readyReplicas: 2 diff --git a/test/integration/simple-statefulset-annotated/00-install.yaml b/test/integration/simple-statefulset-annotated/00-install.yaml new file mode 100644 index 0000000000..cb41a5b61e --- /dev/null +++ b/test/integration/simple-statefulset-annotated/00-install.yaml @@ -0,0 +1,45 @@ +--- + +apiVersion: lifecycle.keptn.sh/v1alpha1 +kind: KeptnTaskDefinition +metadata: + name: pre-deployment-hello +spec: + function: + inline: + code: | + console.log("Pre-Deployment Task has been executed"); + +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: statefultest + name: statefultest + annotations: + keptn.sh/workload: work + keptn.sh/version: "0.4" + keptn.sh/pre-deployment-tasks: pre-deployment-hello +spec: + serviceName: statefultest + replicas: 2 + selector: + matchLabels: + app: statefultest + template: + metadata: + labels: + app: statefultest + annotations: + rollme: what + spec: + containers: + - image: busybox + name: busybox + command: ['sh', '-c', 'echo The app is running! && sleep infinity'] + initContainers: + - name: init-myservice + image: busybox:1.28 + command: ['sh', '-c', 'sleep 30'] + diff --git a/test/integration/simple-statefulset-annotated/00-teststep.yaml b/test/integration/simple-statefulset-annotated/00-teststep.yaml new file mode 100644 index 0000000000..a96f3a8d8f --- /dev/null +++ b/test/integration/simple-statefulset-annotated/00-teststep.yaml @@ -0,0 +1,4 @@ +apiVersion: kuttl.dev/v1beta1 +kind: TestStep +commands: + - script: kubectl annotate ns $NAMESPACE keptn.sh/lifecycle-toolkit='enabled' \ No newline at end of file diff --git a/test/integration/simple-statefulset-annotated/01-assert.yaml b/test/integration/simple-statefulset-annotated/01-assert.yaml new file mode 100644 index 0000000000..89d83bd352 --- /dev/null +++ b/test/integration/simple-statefulset-annotated/01-assert.yaml @@ -0,0 +1,22 @@ +apiVersion: lifecycle.keptn.sh/v1alpha1 +kind: KeptnWorkload +metadata: + name: work-work + +--- + +apiVersion: lifecycle.keptn.sh/v1alpha1 +kind: KeptnWorkloadInstance +metadata: + name: work-work-0.4 +status: + currentPhase: Completed + deploymentStatus: Succeeded + postDeploymentEvaluationStatus: Succeeded + postDeploymentStatus: Succeeded + preDeploymentEvaluationStatus: Succeeded + preDeploymentStatus: Succeeded + preDeploymentTaskStatus: + - status: Succeeded + taskDefinitionName: pre-deployment-hello + status: Succeeded \ No newline at end of file diff --git a/test/integration/simple-statefulset-annotated/02-assert.yaml b/test/integration/simple-statefulset-annotated/02-assert.yaml new file mode 100644 index 0000000000..0e584446e0 --- /dev/null +++ b/test/integration/simple-statefulset-annotated/02-assert.yaml @@ -0,0 +1,16 @@ + +apiVersion: lifecycle.keptn.sh/v1alpha1 +kind: KeptnWorkloadInstance +metadata: + name: work-work-0.5 +status: + currentPhase: Completed + deploymentStatus: Succeeded + postDeploymentEvaluationStatus: Succeeded + postDeploymentStatus: Succeeded + preDeploymentEvaluationStatus: Succeeded + preDeploymentStatus: Succeeded + preDeploymentTaskStatus: + - status: Succeeded + taskDefinitionName: pre-deployment-hello + status: Succeeded \ No newline at end of file diff --git a/test/integration/simple-statefulset-annotated/02-install.yaml b/test/integration/simple-statefulset-annotated/02-install.yaml new file mode 100644 index 0000000000..0ee3025d3b --- /dev/null +++ b/test/integration/simple-statefulset-annotated/02-install.yaml @@ -0,0 +1,33 @@ + +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: statefultest + name: statefultest + annotations: + keptn.sh/workload: work + keptn.sh/version: "0.5" + keptn.sh/pre-deployment-tasks: pre-deployment-hello +spec: + serviceName: statefultest + replicas: 2 + selector: + matchLabels: + app: statefultest + template: + metadata: + labels: + app: statefultest + annotations: + rollme: eSoWV + spec: + containers: + - image: busybox + name: busybox + command: ['sh', '-c', 'echo The app is running! && sleep infinity'] + initContainers: + - name: init-myservice + image: busybox:1.28 + command: ['sh', '-c', 'sleep 30'] +