Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests for the instance admission controller #1442

Merged
merged 10 commits into from
Apr 2, 2020
Merged

Conversation

zen-dog
Copy link
Contributor

@zen-dog zen-dog commented Mar 27, 2020

Summary:
the tests discovered a bug in the instance admission controller (IAC) where IAC was trying to reset PlanExecution.PlanName when a plan becomes terminal. However, it wasn't doing this because:

  1. it wasn't notified when Instance.Status was being updated (Status is a sub-resource) and
  2. even if it would, Instance resource can not be changed upon Status subresource updates (any resource is only allowed to modify itself from the webhook)

To fix this problem we would either need to merge Status back into the Instance resource or duplicate part of the Status information in the Instance.Spec. After long discussions, we decided to introduce a new PlanExecution.Status field which is populated by the instance controller and duplicates the corresponding Status.PlanStatus field.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
The `should clear scheduled plan when it is completed` test is failing: this is a bug in the IAC that needs to be fixed.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
introduced new `PlanExecution.Status` field which is written by IC and read by IAC signalling that a plan is terminal.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog added the release/breaking-change This PR contains breaking changes and is marked in the release notes label Mar 31, 2020
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog marked this pull request as ready for review March 31, 2020 14:58
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Copy link
Member

@ANeumann82 ANeumann82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zen-dog zen-dog requested a review from porridge April 2, 2020 12:42
@zen-dog zen-dog removed the release/breaking-change This PR contains breaking changes and is marked in the release notes label Apr 2, 2020
Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate discussing the logger... others looks good

@@ -9,6 +9,8 @@ require (
github.com/gosuri/uitable v0.0.4
github.com/kudobuilder/kuttl v0.1.0
github.com/manifoldco/promptui v0.6.0
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we previously had these as dependencies and they were removed... now they are back?
I'm not against... but now find myself curious if there are competing mental models

Copy link
Contributor Author

@zen-dog zen-dog Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests do not need it and neither does kuttl. However, instance_admission_integration_test is complex enough that ginkgo becomes necessary. Gomega is not strictly necessary and we could use an existing matcher lib but both seem to be used together everwhere else so I didn't want to break that pattern 🤷‍♂

@@ -183,7 +184,7 @@ func admitUpdate(old, new *kudov1beta1.Instance, ov *kudov1beta1.OperatorVersion
isPlanRetriggered := hadPlan && newPlan == oldPlan && newUID != oldUID
isPlanCancellation := hadPlan && newPlan == ""
isDeleting := new.IsDeleting() // a non-empty meta.deletionTimestamp is a signal to switch to the uninstalling life-cycle phase
isPlanTerminal := isTerminal(new, newPlan, new.Spec.PlanExecution.UID)
isPlanTerminal := new.Spec.PlanExecution.Status.IsTerminal()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

pkg/webhook/instance_admission_integration_test.go Outdated Show resolved Hide resolved
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
@zen-dog zen-dog merged commit 1198582 into master Apr 2, 2020
@zen-dog zen-dog deleted the ad/it-iac branch April 2, 2020 16:49
zen-dog added a commit that referenced this pull request Apr 17, 2020
Summary:
#1442 introduced new `Instance.Spec.PlanExecution.Status` field which duplicates part of the `Instance.Spec.PlanStatus` information . With that, plan execution status is now saved three times: in `planExecution`, `aggregatedStatus` and the corresponding `planStatus` fields e.g.:

```yaml
apiVersion: kudo.dev/v1beta1
kind: Instance
spec:
  planExecution:
    planName: deploy
    status: IN_PROGRESS
status:
  aggregatedStatus:
    activePlanName: deploy
    status: IN_PROGRESS
  planStatus:
    deploy:
      name: deploy
      phases:
      - name: deploy
        status: IN_PROGRESS
        steps:
        - name: app
          status: IN_PROGRESS
      status: IN_PROGRESS
```

`aggregatedStatus` is completely duplicating `planExecution` while `planStatus` provides extended information on individual phases and steps. This PR removes `aggregatedStatus` field in favour of `planExecution`.

The only caveat is that we previously kept `aggregatedStatus.status` value even **after** the plan was finished to signal how _last_ plan execution ended. However, `kudo plan status` already calculates and displays this information from the corresponding `planStatus`. Additionally, having `aggregatedStatus.activePlanName` populated when no plan is active is somewhat broken to begin with.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
zen-dog added a commit that referenced this pull request Apr 20, 2020
Summary:
#1442 introduced new `Instance.Spec.PlanExecution.Status` field which duplicates part of the `Instance.Spec.PlanStatus` information . With that, plan execution status is now saved three times: in `planExecution`, `aggregatedStatus` and the corresponding `planStatus` fields e.g.:

```yaml
apiVersion: kudo.dev/v1beta1
kind: Instance
spec:
  planExecution:
    planName: deploy
    status: IN_PROGRESS
status:
  aggregatedStatus:
    activePlanName: deploy
    status: IN_PROGRESS
  planStatus:
    deploy:
      name: deploy
      phases:
      - name: deploy
        status: IN_PROGRESS
        steps:
        - name: app
          status: IN_PROGRESS
      status: IN_PROGRESS
```

`aggregatedStatus` is completely duplicating `planExecution` while `planStatus` provides extended information on individual phases and steps. This PR removes `aggregatedStatus` field in favour of `planExecution`.

The only caveat is that we previously kept `aggregatedStatus.status` value even **after** the plan was finished to signal how _last_ plan execution ended. However, `kudo plan status` already calculates and displays this information from the corresponding `planStatus`. Additionally, having `aggregatedStatus.activePlanName` populated when no plan is active is somewhat broken to begin with.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
zen-dog pushed a commit that referenced this pull request Apr 30, 2020
Summary:
#1442 introduced new `Instance.Spec.PlanExecution.Status` field which duplicates part of the `Instance.Spec.PlanStatus` information . With that, plan execution status is now saved three times: in `planExecution`, `aggregatedStatus` and the corresponding `planStatus` fields e.g.:

```yaml
apiVersion: kudo.dev/v1beta1
kind: Instance
spec:
  planExecution:
    planName: deploy
    status: IN_PROGRESS
status:
  aggregatedStatus:
    activePlanName: deploy
    status: IN_PROGRESS
  planStatus:
    deploy:
      name: deploy
      phases:
      - name: deploy
        status: IN_PROGRESS
        steps:
        - name: app
          status: IN_PROGRESS
      status: IN_PROGRESS
```

`aggregatedStatus` is completely duplicating `planExecution` while `planStatus` provides extended information on individual phases and steps. This PR removes `aggregatedStatus` field in favor of `planExecution`.

The only caveat is that we previously kept `aggregatedStatus.status` value even **after** the plan was finished to signal how _last_ plan execution ended. However, `kudo plan status` already calculates and displays this information from the corresponding `planStatus`. Additionally, having `aggregatedStatus.activePlanName` populated when no plan is active is somewhat broken, to begin with.

Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants