Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace swarm script with AMP CLI #455

Merged
merged 1 commit into from
Nov 16, 2016
Merged

Replace swarm script with AMP CLI #455

merged 1 commit into from
Nov 16, 2016

Conversation

freignat91
Copy link
Contributor

@freignat91 freignat91 commented Nov 14, 2016

related to  #437

add amp platform commands: ([-v]: verbose, [-s]:silence, [f]: force

  • amp platform pull |-v] [-s]
  • amp platform start [-v] [-s] [-f]
  • amp platform stop [-v] [-s]
  • amp platform status [-v] [-s]
  • amp platform monitor

or using alias pf as:

  • amp pf start -v
  • amp pf stop
  • ...

tested on ubuntu and os/x

tests:

  • make install
  • stop amp: amp platform stop
  • remove all images and containers
  • execute: amp platform pull -v : pull all images needed for amp (-v: to have details)
  • execute: amp platform monitor in another console to monitor amp
  • execute: amp platform start -v in the first console
    -execute: amp platform status it returns 'running'
  • execute: make test
  • execute: amp platform stop

@freignat91 freignat91 force-pushed the cmd-start branch 2 times, most recently from 23842b1 to a178652 Compare November 14, 2016 12:15
@ndegory ndegory self-assigned this Nov 14, 2016
Aliases: []string{"amp-agent"},
},
},
}, "nats", "influxdb")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nats is not an upstream dependency of telegraf-agent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -0,0 +1,41 @@
package main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename the file to platform_status.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if s.force {
s.printf(colWarn, "Force mode: on\n")
}
defaultHeaders := map[string]string{"User-Agent": "amplifier-1.0"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we use the version from the binary instead? (at build time there's a VERSION env variable available)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, it should have version here

for _, name := range stack.volumesToRemove {
s.removeVolume(name)
}
for {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a risk of infinite loop, should't we limit the retries and fail if it wasn't able to start all the services?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if err != nil {
return err
}
//Verify fist that it exists at least one container running
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/it exists/there's/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

}
}
service.failed = false
//No container running and failling then service is still starting without error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/failling/failing/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

}

func (s *ampManager) forceService(service *ampService) {
s.printf(colWarn, "Force mode: service %s is concidered as ready\n", service.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/concidered/considered/
and I think it would be better to say "status of service %s is forced to 'ready'\n"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

s.docker.VolumeRemove(s.ctx, name, true)
ret, err := s.docker.VolumeList(s.ctx, filter)
if err == nil {
return fmt.Errorf("Impossible to get volume list: %v\n", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Impossible/Failed/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

if err != nil {
s.printf(colError, "image %s pull error: %v\n", image, err)
}
data := make([]byte, 1000, 1000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the stack is big enough to fill the array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not possible, it's not related to stack but to the reader which adjust data to the array size

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

RootCmd.AddCommand(PlatformPull)
}

func pullAMPImages(cmd *cobra.Command, args []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amp pull --server=remote-server:8080 pulls images locally, which doesn't make any sense

Copy link
Contributor Author

@freignat91 freignat91 Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be improved later, --server is a amp persistent flag which have nothing to do with pull for this PR concidering we wanted to have commands separated from amp code and so from amplifier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, the --server (or the .amp.yaml config) is a configuration for all command of this binary. It should apply to the pull command. If I configure the CLI to manage an infra stack on a remote swarm manager, I don't want it to pull images locally.

Copy link
Contributor Author

@freignat91 freignat91 Nov 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i got that, but it's not the target of the PR for now. Added error when --server is used with pull

- ./swarm pull --min
- ./swarm start --min
- amp pull
- appp start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it amp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -214,8 +214,8 @@ func (s *ampManager) monitor(stack *ampStack) {
cols[2] = len(serv.status) + 2
}
}
fmt.Printf("%s%s%s%s%s\n", col("ID", cols[0]), col("SERVICE", cols[1]), col("STATUS", cols[2]), col("MODE", cols[3]), col("REPLICAS", cols[4]))
fmt.Printf("%s%s%s%s%s\n", col("-", cols[0]), col("-", cols[1]), col("-", cols[2]), col("-", cols[3]), col("-", cols[4]))
fmt.Printf("%s%s%s%s%s%s\n", col("ID", cols[0]), col("SERVICE", cols[1]), col("STATUS", cols[2]), col("MODE", cols[3]), col("REPLICAS", cols[4]), col("TASK FAILED", cols[5]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/TASK FAILED/FAILED TASKS/

@freignat91 freignat91 force-pushed the cmd-start branch 4 times, most recently from dfc2ebd to 1358adc Compare November 14, 2016 14:07
- ./swarm start --min
- make install
- amp pull
- app start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is app? Shouldn't it be amp?

@freignat91 freignat91 force-pushed the cmd-start branch 14 times, most recently from d1cf1ce to 86d56ff Compare November 15, 2016 15:20
@freignat91 freignat91 force-pushed the cmd-start branch 3 times, most recently from 126c593 to 8575c37 Compare November 16, 2016 06:41
@generalhenry generalhenry merged commit 50a1cef into master Nov 16, 2016
@generalhenry generalhenry deleted the cmd-start branch November 16, 2016 18:37
@ndegory ndegory changed the title Cmd start Replace swarm script with AMP CLI Dec 12, 2016
@ndegory ndegory added this to the 0.4.0 milestone Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants