Skip to content

Commit

Permalink
Update the BaseURLs of CSAPI clients when restarting a deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Quah committed Jun 14, 2022
1 parent e5ca691 commit a3bdc87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/docker/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ func (d *Deployer) Restart(hsDep *HomeserverDeployment, cfg *config.Complement)
}

// Wait for the container to be ready.
baseURL, fedBaseURL, err := waitForPorts(ctx, d.Docker, hsDep.ContainerID)
if err != nil {
return fmt.Errorf("Restart: Failed to restart container %s: %s", hsDep.ContainerID, err)
}
hsDep.SetEndpoints(baseURL, fedBaseURL)

stopTime := time.Now().Add(cfg.SpawnHSTimeout)
_, err = waitForContainer(ctx, d.Docker, hsDep, stopTime)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions internal/docker/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ type HomeserverDeployment struct {
CSAPIClients []*client.CSAPI
}

// Updates the client and federation base URLs of the homeserver deployment.
func (hsDep *HomeserverDeployment) SetEndpoints(baseURL string, fedBaseURL string) {
hsDep.BaseURL = baseURL
hsDep.FedBaseURL = fedBaseURL

for _, client := range hsDep.CSAPIClients {
client.BaseURL = baseURL
}
}

// Destroy the entire deployment. Destroys all running containers. If `printServerLogs` is true,
// will print container logs before killing the container.
func (d *Deployment) Destroy(t *testing.T) {
Expand Down

0 comments on commit a3bdc87

Please sign in to comment.