Skip to content

Commit

Permalink
fix: Key mismatch for registry URL in ModifyContainerRegistry mutat…
Browse files Browse the repository at this point in the history
…ion (#1810)

Backported-from: main
Backported-to: 23.09
  • Loading branch information
rapsealk authored and lizable committed Dec 27, 2023
1 parent 6f7c176 commit 15643ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/1810.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue in the `ModifyContainerRegistry` mutation where the `url` was not updating due to a key mismatch.
2 changes: 2 additions & 0 deletions src/ai/backend/manager/models/etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ async def mutate(
set_if_set(props, input_config, "username")
set_if_set(props, input_config, "password")
set_if_set(props, input_config, "ssl_verify")
if "url" in input_config:
input_config[""] = input_config.pop("url")
log.info(
"ETCD.MODIFY_CONTAINER_REGISTRY (ak:{}, hostname:{}, config:{})",
ctx.access_key,
Expand Down
7 changes: 4 additions & 3 deletions tests/manager/models/test_etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async def test_modify_container_registry(client: Client, context: GraphQueryCont
variables = {
"hostname": "cr.example.com",
"props": {
"url": "http://cr2.example.com",
"type": "harbor2",
"project": ["default", "example"],
},
Expand All @@ -130,7 +131,7 @@ async def test_modify_container_registry(client: Client, context: GraphQueryCont
response = await client.execute_async(query, variables=variables, context_value=context)
container_registry = response["data"]["modify_container_registry"]["container_registry"]
assert container_registry["hostname"] == "cr.example.com"
assert container_registry["config"]["url"] == "http://cr.example.com"
assert container_registry["config"]["url"] == "http://cr2.example.com"
assert container_registry["config"]["type"] == "harbor2"
assert container_registry["config"]["project"] == ["default", "example"]
assert container_registry["config"]["username"] == "username2"
Expand Down Expand Up @@ -162,7 +163,7 @@ async def test_modify_container_registry_allows_empty_string(
response = await client.execute_async(query, variables=variables, context_value=context)
container_registry = response["data"]["modify_container_registry"]["container_registry"]
assert container_registry["hostname"] == "cr.example.com"
assert container_registry["config"]["url"] == "http://cr.example.com"
assert container_registry["config"]["url"] == "http://cr2.example.com"
assert container_registry["config"]["type"] == "harbor2"
assert container_registry["config"]["project"] == ["default", "example"]
assert container_registry["config"]["username"] == "username2"
Expand Down Expand Up @@ -198,7 +199,7 @@ async def test_modify_container_registry_allows_null_for_unset(
response = await client.execute_async(query, variables=variables, context_value=context)
container_registry = response["data"]["modify_container_registry"]["container_registry"]
assert container_registry["hostname"] == "cr.example.com"
assert container_registry["config"]["url"] == "http://cr.example.com"
assert container_registry["config"]["url"] == "http://cr2.example.com"
assert container_registry["config"]["type"] == "harbor2"
assert container_registry["config"]["project"] == ["default", "example"]
assert container_registry["config"]["username"] == "username2"
Expand Down

0 comments on commit 15643ab

Please sign in to comment.