Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ var (
BlockAttempts int
Fields string
SSHPort int
Replace bool
}{}

// used to cache MachineStates
Expand Down Expand Up @@ -595,7 +596,7 @@ func createUnit(name string, uf *unit.UnitFile) (*schema.Unit, error) {
// Any error encountered during these steps is returned immediately (i.e.
// subsequent Jobs are not acted on). An error is also returned if none of the
// above conditions match a given Job.
func lazyCreateUnits(args []string) error {
func lazyCreateUnits(args []string, replace bool) error {
errchan := make(chan error)
var wg sync.WaitGroup
for _, arg := range args {
Expand All @@ -609,7 +610,7 @@ func lazyCreateUnits(args []string) error {
if err != nil {
return fmt.Errorf("error retrieving Unit(%s) from Registry: %v", name, err)
}
if u != nil {
if !replace && u != nil {
log.Debugf("Found Unit(%s) in Registry, no need to recreate it", name)
warnOnDifferentLocalUnit(arg, u)
continue
Expand Down Expand Up @@ -647,7 +648,7 @@ func lazyCreateUnits(args []string) error {
if err != nil {
return fmt.Errorf("failed getting template Unit(%s) from file: %v", uni.Template, err)
}
} else {
} else if !replace {
warnOnDifferentLocalUnit(arg, tmpl)
uf = schema.MapSchemaUnitOptionsToUnitFile(tmpl.Options)
}
Expand Down
5 changes: 3 additions & 2 deletions fleetctl/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
cmdLoadUnits = &Command{
Name: "load",
Summary: "Schedule one or more units in the cluster, first submitting them if necessary.",
Usage: "[--no-block|--block-attempts=N] UNIT...",
Usage: "[--no-block|--block-attempts=N|--replace] UNIT...",
Description: `Load one or many units in the cluster into systemd, but do not start.

Select units to load by glob matching for units in the current working directory
Expand All @@ -43,10 +43,11 @@ func init() {
cmdLoadUnits.Flags.BoolVar(&sharedFlags.Sign, "sign", false, "DEPRECATED - this option cannot be used")
cmdLoadUnits.Flags.IntVar(&sharedFlags.BlockAttempts, "block-attempts", 0, "Wait until the jobs are loaded, performing up to N attempts before giving up. A value of 0 indicates no limit. Does not apply to global units.")
cmdLoadUnits.Flags.BoolVar(&sharedFlags.NoBlock, "no-block", false, "Do not wait until the jobs have been loaded before exiting. Always the case for global units.")
cmdLoadUnits.Flags.BoolVar(&sharedFlags.Replace, "replace", false, "replace (I need help with the text)")
}

func runLoadUnits(args []string) (exit int) {
if err := lazyCreateUnits(args); err != nil {
if err := lazyCreateUnits(args, sharedFlags.Replace); err != nil {
stderr("Error creating units: %v", err)
return 1
}
Expand Down
5 changes: 3 additions & 2 deletions fleetctl/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
cmdStartUnit = &Command{
Name: "start",
Summary: "Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.",
Usage: "[--no-block|--block-attempts=N] UNIT...",
Usage: "[--no-block|--block-attempts=N|--replace] UNIT...",
Description: `Start one or many units on the cluster. Select units to start by glob matching
for units in the current working directory or matching names of previously
submitted units.
Expand All @@ -51,10 +51,11 @@ func init() {
cmdStartUnit.Flags.BoolVar(&sharedFlags.Sign, "sign", false, "DEPRECATED - this option cannot be used")
cmdStartUnit.Flags.IntVar(&sharedFlags.BlockAttempts, "block-attempts", 0, "Wait until the units are launched, performing up to N attempts before giving up. A value of 0 indicates no limit. Does not apply to global units.")
cmdStartUnit.Flags.BoolVar(&sharedFlags.NoBlock, "no-block", false, "Do not wait until the units have launched before exiting. Always the case for global units.")
cmdStartUnit.Flags.BoolVar(&sharedFlags.Replace, "replace", false, "replace (I need help with the text)")
}

func runStartUnit(args []string) (exit int) {
if err := lazyCreateUnits(args); err != nil {
if err := lazyCreateUnits(args, sharedFlags.Replace); err != nil {
stderr("Error creating units: %v", err)
return 1
}
Expand Down
5 changes: 3 additions & 2 deletions fleetctl/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package main
var cmdSubmitUnit = &Command{
Name: "submit",
Summary: "Upload one or more units to the cluster without starting them",
Usage: "UNIT...",
Usage: "[--replace] UNIT...",
Description: `Upload one or more units to the cluster without starting them. Useful
for validating units before they are started.

Expand All @@ -33,10 +33,11 @@ Submit a directory of units with glob matching:

func init() {
cmdSubmitUnit.Flags.BoolVar(&sharedFlags.Sign, "sign", false, "DEPRECATED - this option cannot be used")
cmdSubmitUnit.Flags.BoolVar(&sharedFlags.Replace, "replace", false, "replace (I need help with the text)")
}

func runSubmitUnits(args []string) (exit int) {
if err := lazyCreateUnits(args); err != nil {
if err := lazyCreateUnits(args, sharedFlags.Replace); err != nil {
stderr("Error creating units: %v", err)
exit = 1
}
Expand Down