feat: ensure network exists before attempting to attach it to a container

This will give better feedback to developers than a potentially generic error.
This commit is contained in:
Jose Diaz-Gonzalez
2020-02-09 01:21:42 -05:00
parent 52ef7e7cdc
commit ab509a7424

View File

@@ -174,6 +174,15 @@ func TriggerPostContainerCreate(containerType string, containerID string, appNam
return
}
exists, err := networkExists(networkName)
if err != nil {
common.LogFail(err.Error())
}
if !exists {
common.LogFail(fmt.Sprintf("Network %v does not exist", networkName))
}
attachAppToNetwork(containerID, networkName, appName, phase, processType)
}
@@ -208,6 +217,15 @@ func TriggerCorePostDeploy(appName string) {
common.LogFail(err.Error())
}
exists, err := networkExists(networkName)
if err != nil {
common.LogFail(err.Error())
}
if !exists {
common.LogFail(fmt.Sprintf("Network %v does not exist", networkName))
}
for _, containerID := range containerIDs {
processType, err := common.DockerInspect(containerID, "{{ index .Config.Labels \"com.dokku.process-type\"}}")
if err != nil {