Skip to content

Commit

Permalink
fix: mongodb upgrade error when upgrading from koa
Browse files Browse the repository at this point in the history
  • Loading branch information
iamCristYe authored and regisb committed Jul 6, 2021
1 parent 4f8f0fe commit db5852e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".

## Unreleased

- [Bugfix] Fix "Invalid command argument" during upgrade from Koa to Lilac.
- [Bugfix] Fix mysql initialisation in docker-compose==2.0.0beta4.
- [Improvement] Tutor is now published on pypi as "tutor".

Expand Down
2 changes: 1 addition & 1 deletion tutor/commands/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def upgrade_from_koa(config: Config) -> None:
your MongoDb cluster from v3.6 to v4.0. You should run something similar to:
tutor k8s stop
tutor config save --set DOCKER_IMAGE_MONGODB=mongo:4.0
tutor config save --set DOCKER_IMAGE_MONGODB=mongo:4.0.25
tutor k8s start
tutor k8s exec mongodb mongo --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.0" })'
tutor config save --unset DOCKER_IMAGE_MONGODB
Expand Down
20 changes: 13 additions & 7 deletions tutor/commands/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ def upgrade_from_ironwood(context: click.Context, config: Config) -> None:
)
return

upgrade_mongodb(context, config, "3.4")
upgrade_mongodb(context, config, "3.4", "3.4")
context.invoke(compose.stop)
upgrade_mongodb(context, config, "3.6")
upgrade_mongodb(context, config, "3.6", "3.6")
context.invoke(compose.stop)


Expand Down Expand Up @@ -183,14 +183,19 @@ def upgrade_from_koa(context: click.Context, config: Config) -> None:
"nothing left to do to upgrade from Koa to Lilac."
)
return
upgrade_mongodb(context, config, "4.0.25")
upgrade_mongodb(context, config, "4.0.25", "4.0")


def upgrade_mongodb(context: click.Context, config: Config, to_version: str) -> None:
click.echo(fmt.title("Upgrading MongoDb to v{}".format(to_version)))
def upgrade_mongodb(
context: click.Context,
config: Config,
to_docker_version: str,
to_compatibility_version: str,
) -> None:
click.echo(fmt.title("Upgrading MongoDb to v{}".format(to_docker_version)))
# Note that the DOCKER_IMAGE_MONGODB value is never saved, because we only save the
# environment, not the configuration.
config["DOCKER_IMAGE_MONGODB"] = "mongo:{}".format(to_version)
config["DOCKER_IMAGE_MONGODB"] = "mongo:{}".format(to_docker_version)
tutor_env.save(context.obj.root, config)
context.invoke(compose.start, detach=True, services=["mongodb"])
context.invoke(
Expand All @@ -199,7 +204,8 @@ def upgrade_mongodb(context: click.Context, config: Config, to_version: str) ->
"mongodb",
"mongo",
"--eval",
'db.adminCommand({ setFeatureCompatibilityVersion: "%s" })' % to_version,
'db.adminCommand({ setFeatureCompatibilityVersion: "%s" })'
% to_compatibility_version,
],
)
context.invoke(compose.stop)
Expand Down

0 comments on commit db5852e

Please sign in to comment.