Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/kong] run migration when Kong is updated via Helm #9047

Merged
merged 1 commit into from Nov 7, 2018

Conversation

hbagdi
Copy link
Collaborator

@hbagdi hbagdi commented Nov 6, 2018

Whenever Kong is updated using Helm, we need to ensure that migrations
are run.
For this purpose, a change has been made to run migrations using a
pre-upgrade hook.

The migration Job is being duplicated to avoid a cyclic dependency that
arises with use of pre-install or post-install hooks as detailed below:

Background:

Kong uses a database to store configuration. The migrations for the
database need to be run initially when Kong is installed and then on
every upgrade.
The pre-upgrade hooks solves the problem of running migrations on every
upgrade.

However, to run migrations during an installation has some challanges:

  • pre-install hook doesn't work in our case because, postgres
    deployment is not available in that phase. This means that the migration
    will never succeed and the deployment will always fail.
  • post-install hook introduces a cyclic dependency on the Kong
    container to start. post-install hook is executed only after all the
    deployments are in ready state. But the Kong deployment will not be
    ready till the migrations are run and migrations won't run till Kong
    deployment is ready.

To overcome this, we are going to use two Jobs. One, which is executed
when the Kong is initially installed and then the another one, which is
used on every upgrade.

Signed-off-by: Harry Bagdi harrybagdi@gmail.com

What this PR does / why we need it:

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

Special notes for your reviewer:

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • DCO signed
  • Chart Version bumped

@helm-bot helm-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 6, 2018
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 6, 2018
@hbagdi
Copy link
Collaborator Author

hbagdi commented Nov 6, 2018

ping @shashiranjan84

Whenever Kong is updated using Helm, we need to ensure that migrations
are run.
For this purpose, a change has been made to run migrations using a
pre-upgrade hook.

The migration Job is being duplicated to avoid a cyclic dependency that
arises with use of pre-install or post-install hooks as detailed below:

Background:

Kong uses a database to store configuration. The migrations for the
database need to be run initially when Kong is installed and then on
every upgrade.
The pre-upgrade hooks solves the problem of running migrations on every
upgrade.

However, to run migrations during an installation has some challanges:

- `pre-install` hook doesn't work in our case because, postgres
deployment is not available in that phase. This means that the migration
will never succeed and the deployment will always fail.
- `post-install` hook introduces a cyclic dependency on the Kong
container to start. `post-install` hook is executed only after all the
deployments are in ready state. But the Kong deployment will not be
ready till the migrations are run and migrations won't run till Kong
deployment is ready.

To overcome this, we are going to use two Jobs. One, which is executed
when the Kong is initially installed and then the another one, which is
used on every upgrade.

Signed-off-by: Harry Bagdi <harrybagdi@gmail.com>
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 7, 2018
@hbagdi
Copy link
Collaborator Author

hbagdi commented Nov 7, 2018

/lgtm

@k8s-ci-robot
Copy link
Contributor

@hbagdi: you cannot LGTM your own PR.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Collaborator

@shashiranjan84 shashiranjan84 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hbagdi, shashiranjan84

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 2a5352e into helm:master Nov 7, 2018
@hbagdi hbagdi deleted the kong/migrations-on-upgrade branch November 7, 2018 17:19
wgiddens pushed a commit to wgiddens/charts that referenced this pull request Jan 18, 2019
Whenever Kong is updated using Helm, we need to ensure that migrations
are run.
For this purpose, a change has been made to run migrations using a
pre-upgrade hook.

The migration Job is being duplicated to avoid a cyclic dependency that
arises with use of pre-install or post-install hooks as detailed below:

Background:

Kong uses a database to store configuration. The migrations for the
database need to be run initially when Kong is installed and then on
every upgrade.
The pre-upgrade hooks solves the problem of running migrations on every
upgrade.

However, to run migrations during an installation has some challanges:

- `pre-install` hook doesn't work in our case because, postgres
deployment is not available in that phase. This means that the migration
will never succeed and the deployment will always fail.
- `post-install` hook introduces a cyclic dependency on the Kong
container to start. `post-install` hook is executed only after all the
deployments are in ready state. But the Kong deployment will not be
ready till the migrations are run and migrations won't run till Kong
deployment is ready.

To overcome this, we are going to use two Jobs. One, which is executed
when the Kong is initially installed and then the another one, which is
used on every upgrade.

Signed-off-by: Harry Bagdi <harrybagdi@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants