Skip to content

Commit

Permalink
sidecar: disable networking if no network dependencies are present
Browse files Browse the repository at this point in the history
The newer version of Compose used with Mutagen Compose v0.18.0 doesn't
like an empty network map and tries to connect the sidecar container to
a network with an empty name if there are no networks present in the
service configuration.

To fix this, we'll disable networking for the sidecar if not needed.

Signed-off-by: Jacob Howard <[email protected]>
  • Loading branch information
xenoscopic committed Nov 11, 2024
1 parent 3c59b77 commit 810dc0e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/mutagen/liaison.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,13 @@ func (l *Liaison) processProject(project *types.Project) error {
}
composeVersion := strings.TrimPrefix(versions.Compose, "v")

// If there are no network dependencies, then disable networking.
var networkMode string
if len(networkDependencies) == 0 {
networkMode = "none"
networkDependencies = nil
}

// Create and record the Mutagen sidecar service definition. The service
// configuration we generate here needs to match (as closely as possible)
// those generated by projectOptions.toProject in Compose. In particular,
Expand All @@ -476,9 +483,10 @@ func (l *Liaison) processProject(project *types.Project) error {
sidecarRoleLabelKey: sidecarRoleLabelValue,
sidecarVersionLabelKey: mutagen.Version,
},
Networks: networkDependencies,
Volumes: serviceVolumeDependencies,
CapAdd: capabilities,
NetworkMode: networkMode,
Networks: networkDependencies,
Volumes: serviceVolumeDependencies,
CapAdd: capabilities,
CustomLabels: types.Labels{
api.ProjectLabel: project.Name,
api.ServiceLabel: sidecarServiceName,
Expand Down

0 comments on commit 810dc0e

Please sign in to comment.