From a0a52212b97f2622698dfd5a3b23c1dd9984483c Mon Sep 17 00:00:00 2001 From: Zaraki Date: Thu, 12 Dec 2019 12:37:46 +0100 Subject: [PATCH] feat: pwcompose down --with-nginx fix: pwagent daemon now always recreate containers on Up call refactor: renamed pathwarInfos to containersInfo everywhere it's relevant --- api/errcode.proto | 7 +- docs/gen.sum | 2 +- go/cmd/pathwar/main.go | 3 + go/gen.sum | 2 +- go/pkg/errcode/errcode.pb.go | 272 ++++++++++++++++++----------------- go/pkg/pwagent/daemon.go | 16 +-- go/pkg/pwagent/nginx.go | 35 ++--- go/pkg/pwcompose/compose.go | 75 +++++++--- go/pkg/pwcompose/config.go | 8 +- 9 files changed, 230 insertions(+), 190 deletions(-) diff --git a/api/errcode.proto b/api/errcode.proto index 22729884e..acb3ff83b 100644 --- a/api/errcode.proto +++ b/api/errcode.proto @@ -67,7 +67,7 @@ enum ErrCode { ErrWritePWInitConfigFile = 3022; ErrWritePWInitCloseTarWriter = 3023; ErrCopyPWInitToContainer = 3024; - ErrComposeGetPathwarInfo = 3025; + ErrComposeGetContainersInfo = 3025; //// Pathwar API (starting at 4001) @@ -154,7 +154,7 @@ enum ErrCode { //// Pathwar Agent (starting at 7001) - ErrAgentGetPathwarInfo = 7001; + ErrAgentGetContainersInfo = 7001; ErrCheckNginxContainer = 7002; ErrRemoveNginxContainer = 7003; ErrBuildNginxContainer = 7004; @@ -195,7 +195,8 @@ enum ErrCode { ErrDockerAPIImagePull = 8009; ErrDockerAPINetworkList = 8010; ErrDockerAPINetworkCreate = 8011; - ErrDockerAPIExitCode = 8012; + ErrDockerAPINetworkRemove = 8012; + ErrDockerAPIExitCode = 8013; //// Pathwar Init (starting at 9001) diff --git a/docs/gen.sum b/docs/gen.sum index e76111818..ffa561531 100644 --- a/docs/gen.sum +++ b/docs/gen.sum @@ -1,4 +1,4 @@ -3d22ad8b6e564e338f2d8d17e09a90c743c95801 ../api/errcode.proto +320ad79533fd1456c4f9b5e6bcc8b582165c875d ../api/errcode.proto 4362a2715e8c2053c4bec93585b01ca252dae2e7 ../api/pwagent.proto 58eb4b1d9b5be40a69ffdab1a13b9fb90b669839 ../api/pwsso.proto 70d67f1cebb3b7f9e86fd0197d43db4c1f795f65 ../api/pwinit.proto diff --git a/go/cmd/pathwar/main.go b/go/cmd/pathwar/main.go index fb6a87b73..8b95444ab 100644 --- a/go/cmd/pathwar/main.go +++ b/go/cmd/pathwar/main.go @@ -59,6 +59,7 @@ var ( apiDBURN string composeDownKeepVolumes bool composeDownRemoveImages bool + composeDownWithNginx bool composePSDepth int composePrepareNoPush bool composePreparePrefix string @@ -120,6 +121,7 @@ func main() { apiFlags.StringVar(&ssoRealm, "sso-realm", defaultSSORealm, "SSO Realm") composeDownFlags.BoolVar(&composeDownKeepVolumes, "keep-volumes", false, "keep volumes") composeDownFlags.BoolVar(&composeDownRemoveImages, "rmi", false, "remove images as well") + composeDownFlags.BoolVar(&composeDownWithNginx, "with-nginx", false, "down nginx container and proxy network as well") composePSFlags.IntVar(&composePSDepth, "depth", 0, "depth to display") composePrepareFlags.BoolVar(&composePrepareNoPush, "no-push", false, "don't push images") composePrepareFlags.StringVar(&composePreparePrefix, "prefix", defaultDockerPrefix, "docker image prefix") @@ -467,6 +469,7 @@ func main() { args, composeDownRemoveImages, !composeDownKeepVolumes, + composeDownWithNginx, cli, logger, ) diff --git a/go/gen.sum b/go/gen.sum index 01300bdde..a246e7213 100644 --- a/go/gen.sum +++ b/go/gen.sum @@ -1,4 +1,4 @@ -3d22ad8b6e564e338f2d8d17e09a90c743c95801 ../api/errcode.proto +320ad79533fd1456c4f9b5e6bcc8b582165c875d ../api/errcode.proto 4362a2715e8c2053c4bec93585b01ca252dae2e7 ../api/pwagent.proto 58eb4b1d9b5be40a69ffdab1a13b9fb90b669839 ../api/pwsso.proto 70d67f1cebb3b7f9e86fd0197d43db4c1f795f65 ../api/pwinit.proto diff --git a/go/pkg/errcode/errcode.pb.go b/go/pkg/errcode/errcode.pb.go index 5eace6755..807f25998 100644 --- a/go/pkg/errcode/errcode.pb.go +++ b/go/pkg/errcode/errcode.pb.go @@ -72,7 +72,7 @@ const ( ErrWritePWInitConfigFile ErrCode = 3022 ErrWritePWInitCloseTarWriter ErrCode = 3023 ErrCopyPWInitToContainer ErrCode = 3024 - ErrComposeGetPathwarInfo ErrCode = 3025 + ErrComposeGetContainersInfo ErrCode = 3025 ErrGetUserIDFromContext ErrCode = 4001 ErrMissingChallengeValidation ErrCode = 4002 ErrInvalidSeason ErrCode = 4003 @@ -146,7 +146,7 @@ const ( ErrConfigureDB ErrCode = 6013 ErrInitSSOClient ErrCode = 6014 ErrInitService ErrCode = 6015 - ErrAgentGetPathwarInfo ErrCode = 7001 + ErrAgentGetContainersInfo ErrCode = 7001 ErrCheckNginxContainer ErrCode = 7002 ErrRemoveNginxContainer ErrCode = 7003 ErrBuildNginxContainer ErrCode = 7004 @@ -184,7 +184,8 @@ const ( ErrDockerAPIImagePull ErrCode = 8009 ErrDockerAPINetworkList ErrCode = 8010 ErrDockerAPINetworkCreate ErrCode = 8011 - ErrDockerAPIExitCode ErrCode = 8012 + ErrDockerAPINetworkRemove ErrCode = 8012 + ErrDockerAPIExitCode ErrCode = 8013 ErrExecuteOnInitHook ErrCode = 9001 ) @@ -236,7 +237,7 @@ var ErrCode_name = map[int32]string{ 3022: "ErrWritePWInitConfigFile", 3023: "ErrWritePWInitCloseTarWriter", 3024: "ErrCopyPWInitToContainer", - 3025: "ErrComposeGetPathwarInfo", + 3025: "ErrComposeGetContainersInfo", 4001: "ErrGetUserIDFromContext", 4002: "ErrMissingChallengeValidation", 4003: "ErrInvalidSeason", @@ -310,7 +311,7 @@ var ErrCode_name = map[int32]string{ 6013: "ErrConfigureDB", 6014: "ErrInitSSOClient", 6015: "ErrInitService", - 7001: "ErrAgentGetPathwarInfo", + 7001: "ErrAgentGetContainersInfo", 7002: "ErrCheckNginxContainer", 7003: "ErrRemoveNginxContainer", 7004: "ErrBuildNginxContainer", @@ -348,7 +349,8 @@ var ErrCode_name = map[int32]string{ 8009: "ErrDockerAPIImagePull", 8010: "ErrDockerAPINetworkList", 8011: "ErrDockerAPINetworkCreate", - 8012: "ErrDockerAPIExitCode", + 8012: "ErrDockerAPINetworkRemove", + 8013: "ErrDockerAPIExitCode", 9001: "ErrExecuteOnInitHook", } @@ -400,7 +402,7 @@ var ErrCode_value = map[string]int32{ "ErrWritePWInitConfigFile": 3022, "ErrWritePWInitCloseTarWriter": 3023, "ErrCopyPWInitToContainer": 3024, - "ErrComposeGetPathwarInfo": 3025, + "ErrComposeGetContainersInfo": 3025, "ErrGetUserIDFromContext": 4001, "ErrMissingChallengeValidation": 4002, "ErrInvalidSeason": 4003, @@ -474,7 +476,7 @@ var ErrCode_value = map[string]int32{ "ErrConfigureDB": 6013, "ErrInitSSOClient": 6014, "ErrInitService": 6015, - "ErrAgentGetPathwarInfo": 7001, + "ErrAgentGetContainersInfo": 7001, "ErrCheckNginxContainer": 7002, "ErrRemoveNginxContainer": 7003, "ErrBuildNginxContainer": 7004, @@ -512,7 +514,8 @@ var ErrCode_value = map[string]int32{ "ErrDockerAPIImagePull": 8009, "ErrDockerAPINetworkList": 8010, "ErrDockerAPINetworkCreate": 8011, - "ErrDockerAPIExitCode": 8012, + "ErrDockerAPINetworkRemove": 8012, + "ErrDockerAPIExitCode": 8013, "ErrExecuteOnInitHook": 9001, } @@ -531,133 +534,134 @@ func init() { func init() { proto.RegisterFile("errcode.proto", fileDescriptor_4240057316120df7) } var fileDescriptor_4240057316120df7 = []byte{ - // 2047 bytes of a gzipped FileDescriptorProto + // 2056 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x58, 0x59, 0x6f, 0x1c, 0xc7, 0x11, 0x96, 0x80, 0x44, 0x84, 0x26, 0x91, 0x59, 0x1e, 0xd9, 0x5a, 0x5b, 0xb2, 0x39, 0x3e, 0x12, 0x0b, 0xc8, 0xb1, 0x7a,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39, 0xe5, 0x1a, 0xb2, 0x85, 0x6b, 0xc6, 0x81, - 0xbd, 0xff, 0x31, 0xe3, 0xbd, 0x04, 0x4e, 0xbb, 0x5a, 0x19, 0x9e, 0x26, 0x52, 0xdd, 0xb5, 0x07, - 0x9c, 0x09, 0xfc, 0x4f, 0x78, 0xfb, 0xcd, 0xf3, 0xc8, 0x3b, 0x1d, 0x54, 0x28, 0x6c, 0x2c, 0x75, - 0xd4, 0x6b, 0x88, 0x62, 0x51, 0xae, 0xa0, 0x98, 0x10, 0x61, 0x83, 0x69, 0xb6, 0xcc, 0x12, 0x84, - 0xb3, 0x8e, 0xeb, 0x43, 0x92, 0x85, 0x46, 0x31, 0xe3, 0x35, 0x81, 0x73, 0x41, 0x79, 0xf2, 0x94, - 0xef, 0xc2, 0x79, 0x97, 0x45, 0x5e, 0x89, 0x04, 0x2e, 0x04, 0x34, 0xf2, 0xc9, 0xa2, 0x6e, 0x2e, - 0xdf, 0x67, 0xcd, 0x43, 0x7e, 0xd1, 0x75, 0xdd, 0x54, 0x8f, 0xf1, 0x78, 0x22, 0x0c, 0x15, 0x26, - 0x49, 0x4b, 0xea, 0xbb, 0x50, 0xf1, 0x8e, 0x69, 0xcb, 0x4b, 0x05, 0xd3, 0x06, 0x76, 0x58, 0x1a, - 0xbb, 0x36, 0x7e, 0x34, 0x18, 0xcc, 0xc7, 0x1e, 0xcf, 0x6e, 0x94, 0x62, 0x22, 0x61, 0x6d, 0xcb, - 0xce, 0x63, 0x65, 0xe6, 0x26, 0xda, 0x9a, 0xaf, 0x22, 0x99, 0x3e, 0xee, 0x6e, 0x94, 0x9b, 0x8e, - 0xd9, 0xd4, 0x3c, 0x8c, 0x9a, 0x85, 0x4c, 0x33, 0xd8, 0x70, 0xa9, 0xb7, 0xa4, 0xa5, 0x65, 0x4e, - 0xc9, 0x55, 0x1e, 0x62, 0x08, 0x97, 0x0b, 0x6d, 0x66, 0x91, 0x23, 0x5c, 0x77, 0x89, 0xf3, 0x27, - 0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33, 0x13, 0xf8, 0x71, 0x40, 0xf3, 0x33, 0x07, 0xe1, + 0x27, 0x01, 0xdd, 0xb4, 0xec, 0xff, 0x06, 0x0a, 0x8e, 0x21, 0xfc, 0x34, 0xa0, 0x8b, 0x41, 0xf4, + 0xec, 0x67, 0x49, 0xf9, 0x98, 0x9f, 0x39, 0xb3, 0x79, 0x4c, 0x50, 0xad, 0x62, 0xd8, 0x62, 0x3d, + 0x84, 0x9f, 0xe7, 0xd4, 0x75, 0xb1, 0xbd, 0x52, 0xa4, 0x65, 0x49, 0xf0, 0xbb, 0x53, 0xb4, 0x4a, + 0xbf, 0x08, 0xdc, 0x44, 0xb1, 0xfc, 0x16, 0xb5, 0xe0, 0x97, 0x81, 0xff, 0x49, 0xef, 0x8e, 0x29, + 0xa5, 0x8a, 0xd2, 0xab, 0xc5, 0x70, 0x7f, 0x30, 0x18, 0x07, 0x25, 0x2f, 0x0f, 0xb8, 0x13, 0x36, + 0x72, 0x00, 0x0f, 0xba, 0x13, 0x26, 0x99, 0x10, 0x52, 0xbb, 0x91, 0x95, 0xf9, 0x95, 0xb1, 0x2c, + 0x39, 0x7a, 0xc8, 0x15, 0xc9, 0x90, 0x6d, 0xbb, 0xbf, 0x04, 0x3f, 0x1c, 0xd0, 0x5b, 0x36, 0xf0, + 0x02, 0x8f, 0x04, 0xfe, 0xa8, 0xe7, 0x65, 0x67, 0x5b, 0xc1, 0xa3, 0x01, 0x6d, 0x0d, 0x24, 0x48, + 0xe0, 0xb1, 0x82, 0x8a, 0x71, 0x0c, 0x47, 0x9c, 0x9f, 0xec, 0x4a, 0x58, 0xd9, 0xd1, 0xb2, 0xcc, + 0xba, 0x3a, 0xe6, 0xf2, 0xca, 0x64, 0xa5, 0x58, 0x8e, 0xbb, 0x86, 0x6c, 0xe1, 0x9a, 0x71, 0x60, + 0xef, 0x7f, 0xcc, 0x78, 0x2f, 0x81, 0x13, 0xae, 0x56, 0x86, 0xa7, 0x89, 0x54, 0x77, 0xed, 0x01,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ent/daemon.go b/go/pkg/pwagent/daemon.go index cc1763f1a..3c1ca9f61 100644 --- a/go/pkg/pwagent/daemon.go +++ b/go/pkg/pwagent/daemon.go @@ -59,7 +59,7 @@ func Daemon(ctx context.Context, clean bool, runOnce bool, loopDelay time.Durati } if clean { - err := pwcompose.Down(ctx, []string{}, true, true, cli, logger) + err := pwcompose.Down(ctx, []string{}, true, true, true, cli, logger) if err != nil { return errcode.ErrCleanPathwarInstances.Wrap(err) } @@ -83,9 +83,9 @@ func Daemon(ctx context.Context, clean bool, runOnce bool, loopDelay time.Durati func run(ctx context.Context, apiInstances *pwapi.AgentListInstances_Output, cli *client.Client, logger *zap.Logger) error { // fetch local info from docker daemon - pathwarInfo, err := pwcompose.GetPathwarInfo(ctx, cli) + containersInfo, err := pwcompose.GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrComposeGetPathwarInfo.Wrap(err) + return errcode.ErrComposeGetContainersInfo.Wrap(err) } agentOpts := AgentOpts{ @@ -103,7 +103,7 @@ func run(ctx context.Context, apiInstances *pwapi.AgentListInstances_Output, cli for _, apiInstance := range apiInstances.GetInstances() { found := false needRedump := false - for _, flavor := range pathwarInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { if apiInstanceFlavor := apiInstance.GetFlavor(); apiInstanceFlavor != nil { if apiInstanceFlavorChallenge := apiInstanceFlavor.GetChallenge(); apiInstanceFlavorChallenge != nil { if flavor.InstanceKey == strconv.FormatInt(apiInstance.GetID(), 10) { @@ -123,7 +123,7 @@ func run(ctx context.Context, apiInstances *pwapi.AgentListInstances_Output, cli return errcode.ErrParseInitConfig.Wrap(err) } - err = pwcompose.Up(ctx, apiInstance.GetFlavor().GetComposeBundle(), strconv.FormatInt(apiInstance.GetID(), 10), needRedump, &configData, cli, logger) + err = pwcompose.Up(ctx, apiInstance.GetFlavor().GetComposeBundle(), strconv.FormatInt(apiInstance.GetID(), 10), true, &configData, cli, logger) if err != nil { return errcode.ErrUpPathwarInstance.Wrap(err) } @@ -131,9 +131,9 @@ func run(ctx context.Context, apiInstances *pwapi.AgentListInstances_Output, cli } // update pathwar infos - pathwarInfo, err = pwcompose.GetPathwarInfo(ctx, cli) + containersInfo, err = pwcompose.GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrComposeGetPathwarInfo.Wrap(err) + return errcode.ErrComposeGetContainersInfo.Wrap(err) } // update nginx configuration @@ -146,7 +146,7 @@ func run(ctx context.Context, apiInstances *pwapi.AgentListInstances_Output, cli if team := subscription.GetTeam(); team != nil { if members := team.GetMembers(); members != nil { for _, member := range members { - for _, flavor := range pathwarInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { if flavor.InstanceKey == strconv.FormatInt(apiInstance.GetID(), 10) { for _, instance := range flavor.Instances { for _, port := range instance.Ports { diff --git a/go/pkg/pwagent/nginx.go b/go/pkg/pwagent/nginx.go index 13217474b..4b0e4324e 100644 --- a/go/pkg/pwagent/nginx.go +++ b/go/pkg/pwagent/nginx.go @@ -25,11 +25,6 @@ import ( "pathwar.land/go/pkg/pwcompose" ) -const ( - nginxContainerName = "pathwar-agent-nginx" - proxyNetworkName = "pathwar-proxy-network" -) - const nginxConfigTemplate = ` {{$root := .}} #user www www; @@ -125,13 +120,13 @@ func Nginx(ctx context.Context, opts AgentOpts, cli *client.Client, logger *zap. return errcode.ErrDockerAPINetworkList.Wrap(err) } for _, networkResource := range networkResources { - if networkResource.Name == proxyNetworkName { + if networkResource.Name == pwcompose.ProxyNetworkName { proxyNetworkID = networkResource.ID } } if proxyNetworkID == "" { - logger.Debug("proxy network create", zap.String("name", proxyNetworkName)) - response, err := cli.NetworkCreate(ctx, proxyNetworkName, types.NetworkCreate{ + logger.Debug("proxy network create", zap.String("name", pwcompose.ProxyNetworkName)) + response, err := cli.NetworkCreate(ctx, pwcompose.ProxyNetworkName, types.NetworkCreate{ CheckDuplicate: true, }) proxyNetworkID = response.ID @@ -187,7 +182,7 @@ func Nginx(ctx context.Context, opts AgentOpts, cli *client.Client, logger *zap. } // connect nginx container to proxy network - if _, onProxyNetwork := nginxContainer.NetworkSettings.Networks[proxyNetworkName]; !onProxyNetwork { + if _, onProxyNetwork := nginxContainer.NetworkSettings.Networks[pwcompose.ProxyNetworkName]; !onProxyNetwork { logger.Debug("connect nginx to proxy network", zap.String("nginx-id", nginxContainer.ID), zap.String("network-id", proxyNetworkID)) err = cli.NetworkConnect(ctx, proxyNetworkID, nginxContainer.ID, nil) if err != nil { @@ -201,18 +196,18 @@ func Nginx(ctx context.Context, opts AgentOpts, cli *client.Client, logger *zap. } // update proxy network nginx container IP - proxyNetworkIP := nginxContainer.NetworkSettings.Networks[proxyNetworkName].IPAddress + proxyNetworkIP := nginxContainer.NetworkSettings.Networks[pwcompose.ProxyNetworkName].IPAddress // make sure that exposed containers are connected to proxy network - pwInfo, err := pwcompose.GetPathwarInfo(ctx, cli) + containersInfo, err := pwcompose.GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrAgentGetPathwarInfo.Wrap(err) + return errcode.ErrAgentGetContainersInfo.Wrap(err) } - for _, flavor := range pwInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { for _, instance := range flavor.Instances { for _, port := range instance.Ports { if port.PrivatePort != 0 { - if _, onProxyNetwork := instance.NetworkSettings.Networks[proxyNetworkName]; !onProxyNetwork { + if _, onProxyNetwork := instance.NetworkSettings.Networks[pwcompose.ProxyNetworkName]; !onProxyNetwork { logger.Debug("connect container to proxy network", zap.String("container-id", instance.ID), zap.String("network-id", proxyNetworkID)) err = cli.NetworkConnect(ctx, proxyNetworkID, instance.ID, nil) if err != nil { @@ -236,11 +231,11 @@ func Nginx(ctx context.Context, opts AgentOpts, cli *client.Client, logger *zap. } // update config data with containers infos - pwInfo, err = pwcompose.GetPathwarInfo(ctx, cli) + containersInfo, err = pwcompose.GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrAgentGetPathwarInfo.Wrap(err) + return errcode.ErrAgentGetContainersInfo.Wrap(err) } - for _, flavor := range pwInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { for _, instance := range flavor.Instances { for _, port := range instance.Ports { // FIXME: support non-standard ports using labels (later) @@ -249,7 +244,7 @@ func Nginx(ctx context.Context, opts AgentOpts, cli *client.Client, logger *zap. } if port.PrivatePort != 0 { upstream.Name = instance.Names[0][1:] - upstream.Host = instance.NetworkSettings.Networks[proxyNetworkName].IPAddress + upstream.Host = instance.NetworkSettings.Networks[pwcompose.ProxyNetworkName].IPAddress upstream.Port = strconv.Itoa(int(port.PrivatePort)) // add hash per users to proxy configuration @@ -369,7 +364,7 @@ func buildNginxContainer(ctx context.Context, cli *client.Client, opts AgentOpts }, &container.HostConfig{ PortBindings: portBinding, - }, nil, nginxContainerName) + }, nil, pwcompose.NginxContainerName) if err != nil { return "", errcode.ErrDockerAPIContainerCreate.Wrap(err) } @@ -386,7 +381,7 @@ func checkNginxContainer(ctx context.Context, cli *client.Client) (*types.Contai } for _, container := range containers { for _, name := range container.Names { - if name[1:] == nginxContainerName { + if name[1:] == pwcompose.NginxContainerName { return &container, nil } } diff --git a/go/pkg/pwcompose/compose.go b/go/pkg/pwcompose/compose.go index 63b73a4ea..29082ba0f 100644 --- a/go/pkg/pwcompose/compose.go +++ b/go/pkg/pwcompose/compose.go @@ -33,6 +33,8 @@ const ( challengeNameLabel = labelPrefix + "challenge-name" challengeVersionLabel = labelPrefix + "challenge-version" instanceKeyLabel = labelPrefix + "instance-key" + NginxContainerName = "pathwar-agent-nginx" + ProxyNetworkName = "pathwar-proxy-network" ) func Prepare(challengeDir string, prefix string, noPush bool, version string, logger *zap.Logger) (string, error) { @@ -242,7 +244,7 @@ func Up( // down instances if force recreate if forceRecreate { - err = Down(ctx, []string{challengeID}, false, false, cli, logger) + err = Down(ctx, []string{challengeID}, false, false, false, cli, logger) if err != nil { return errcode.ErrComposeForceRecreateDown.Wrap(err) } @@ -260,12 +262,12 @@ func Up( } // copy pathwar binary inside all containers - pwInfo, err := GetPathwarInfo(ctx, cli) + containersInfo, err := GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrComposeGetPathwarInfo.Wrap(err) + return errcode.ErrComposeGetContainersInfo.Wrap(err) } - for _, container := range pwInfo.RunningInstances { + for _, container := range containersInfo.RunningInstances { if challengeID == challengeIDFormatted(container.Labels[challengeNameLabel], container.Labels[challengeVersionLabel]) { if pwinitConfig == nil { pwinitConfig = &pwinit.InitConfig{ @@ -318,14 +320,15 @@ func Down( ids []string, removeImages bool, removeVolumes bool, + withNginx bool, cli *client.Client, logger *zap.Logger, ) error { - logger.Debug("down", zap.Strings("ids", ids), zap.Bool("rmi", removeImages), zap.Bool("rm -v", removeVolumes)) + logger.Debug("down", zap.Strings("ids", ids), zap.Bool("rmi", removeImages), zap.Bool("rm -v", removeVolumes), zap.Bool("with-nginx", withNginx)) - pwInfo, err := GetPathwarInfo(ctx, cli) + containersInfo, err := GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrComposeGetPathwarInfo.Wrap(err) + return errcode.ErrComposeGetContainersInfo.Wrap(err) } var ( @@ -333,8 +336,12 @@ func Down( imagesToRemove []string ) + if withNginx && containersInfo.NginxProxyInstance.ID != "" { + ids = append(ids, containersInfo.NginxProxyInstance.ID) + } + if len(ids) == 0 { - for _, container := range pwInfo.RunningInstances { + for _, container := range containersInfo.RunningInstances { containersToRemove = append(containersToRemove, container.ID) if removeImages == true { imagesToRemove = append(imagesToRemove, container.ImageID) @@ -343,7 +350,7 @@ func Down( } for _, id := range ids { - for _, flavor := range pwInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { if id == flavor.Name || id == challengeIDFormatted(flavor.Name, flavor.Version) { for _, instance := range flavor.Instances { containersToRemove = append(containersToRemove, instance.ID) @@ -353,7 +360,7 @@ func Down( } } } - for _, container := range pwInfo.RunningInstances { + for _, container := range containersInfo.RunningInstances { if id == container.ID || id == container.ID[0:7] { containersToRemove = append(containersToRemove, container.ID) if removeImages == true { @@ -385,20 +392,28 @@ func Down( fmt.Println("removed image " + imageID) } + if withNginx && containersInfo.NginxProxyNetwork.ID != "" { + err = cli.NetworkRemove(ctx, containersInfo.NginxProxyNetwork.ID) + if err != nil { + return errcode.ErrDockerAPINetworkRemove.Wrap(err) + } + fmt.Println("removed proxy network " + containersInfo.NginxProxyNetwork.ID) + } + return nil } func PS(ctx context.Context, depth int, cli *client.Client, logger *zap.Logger) error { logger.Debug("ps", zap.Int("depth", depth)) - pwInfo, err := GetPathwarInfo(ctx, cli) + containersInfo, err := GetContainersInfo(ctx, cli) if err != nil { - return errcode.ErrComposeGetPathwarInfo.Wrap(err) + return errcode.ErrComposeGetContainersInfo.Wrap(err) } table := tablewriter.NewWriter(os.Stdout) table.SetHeader([]string{"ID", "CHALLENGE", "SVC", "PORTS", "STATUS", "CREATED"}) - for _, flavor := range pwInfo.RunningFlavors { + for _, flavor := range containersInfo.RunningFlavors { for uid, container := range flavor.Instances { ports := []string{} @@ -472,7 +487,7 @@ func buildPWInitTar(config pwinit.InitConfig) (*bytes.Buffer, error) { return &buf, nil } -func GetPathwarInfo(ctx context.Context, cli *client.Client) (*PathwarInfo, error) { +func GetContainersInfo(ctx context.Context, cli *client.Client) (*ContainersInfo, error) { containers, err := cli.ContainerList(ctx, types.ContainerListOptions{ All: true, }) @@ -480,34 +495,54 @@ func GetPathwarInfo(ctx context.Context, cli *client.Client) (*PathwarInfo, erro return nil, errcode.ErrDockerAPIContainerList.Wrap(err) } - pwInfo := PathwarInfo{ + containersInfo := ContainersInfo{ RunningFlavors: map[string]challengeFlavors{}, RunningInstances: map[string]types.Container{}, } for _, container := range containers { + // find nginx proxy + for _, name := range container.Names { + if name[1:] == NginxContainerName { + containersInfo.NginxProxyInstance = container + } + } + // continue if container is not a challenge if _, pwcontainer := container.Labels[challengeNameLabel]; !pwcontainer { continue } + // handle and sort challenge flavor := fmt.Sprintf( "%s:%s", container.Labels[challengeNameLabel], container.Labels[challengeVersionLabel], ) - if _, found := pwInfo.RunningFlavors[flavor]; !found { + if _, found := containersInfo.RunningFlavors[flavor]; !found { challengeFlavor := challengeFlavors{ Instances: map[string]types.Container{}, } challengeFlavor.Name = container.Labels[challengeNameLabel] challengeFlavor.Version = container.Labels[challengeVersionLabel] challengeFlavor.InstanceKey = container.Labels[instanceKeyLabel] - pwInfo.RunningFlavors[flavor] = challengeFlavor + containersInfo.RunningFlavors[flavor] = challengeFlavor + } + containersInfo.RunningFlavors[flavor].Instances[container.ID] = container + containersInfo.RunningInstances[container.ID] = container + } + + // find proxy network + networks, err := cli.NetworkList(ctx, types.NetworkListOptions{}) + if err != nil { + return nil, errcode.ErrDockerAPINetworkList.Wrap(err) + } + for _, networkResource := range networks { + if networkResource.Name == ProxyNetworkName { + containersInfo.NginxProxyNetwork = networkResource + break } - pwInfo.RunningFlavors[flavor].Instances[container.ID] = container - pwInfo.RunningInstances[container.ID] = container } - return &pwInfo, nil + return &containersInfo, nil } func challengeIDFormatted(challengeNameLabel string, challengeVersionLabel string) string { diff --git a/go/pkg/pwcompose/config.go b/go/pkg/pwcompose/config.go index 09859a63b..8d59284ea 100644 --- a/go/pkg/pwcompose/config.go +++ b/go/pkg/pwcompose/config.go @@ -43,9 +43,11 @@ type dabservice struct { Image string } -type PathwarInfo struct { - RunningFlavors map[string]challengeFlavors - RunningInstances map[string]types.Container +type ContainersInfo struct { + RunningFlavors map[string]challengeFlavors + RunningInstances map[string]types.Container + NginxProxyInstance types.Container + NginxProxyNetwork types.NetworkResource } type challengeFlavors struct {