-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/gomote: add -firewall flag to run, defaulting to off
While debugging golang/go#25386 I found that the firewall defaulting to on made debugging modules hard. So make gomote default to no outbound firewall and make it opt-in for people who want to reproduce the builder more. Also in this CL: start to use server's builder config, not local state (follow up to CL 169678 which was incomplete). It's still incomplete in this CL, but there's now a panic with more useful information to users telling them to update their binary. Updates golang/go#30929 Change-Id: I17bded71919af1e7a9181866a1349eb72da40051 Reviewed-on: https://go-review.googlesource.com/c/build/+/170397 Reviewed-by: Dmitri Shuralyov <[email protected]>
- Loading branch information
Showing
9 changed files
with
43 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,27 +43,43 @@ func list(args []string) error { | |
return nil | ||
} | ||
|
||
// clientAndConfig returns a buildlet.Client and its build config for | ||
// remoteClient returns a buildlet.Client for a named remote buildlet | ||
// (a buildlet connection owned by the build coordinator). | ||
// | ||
// As a special case, if name contains '@', the name is expected to be | ||
// of the form <build-config-name>@ip[:port]. For example, | ||
// "[email protected]". | ||
func remoteClient(name string) (*buildlet.Client, error) { | ||
bc, _, err := clientAndCondConf(name, false) | ||
return bc, err | ||
} | ||
|
||
// clientAndConf returns a buildlet.Client and its build config for | ||
// a named remote buildlet (a buildlet connection owned by the build | ||
// coordinator). | ||
// | ||
// As a special case, if name contains '@', the name is expected to be | ||
// of the form <build-config-name>@ip[:port]. For example, | ||
// "[email protected]". | ||
func clientAndConf(name string) (bc *buildlet.Client, conf *dashboard.BuildConfig, err error) { | ||
var ok bool | ||
return clientAndCondConf(name, true) | ||
} | ||
|
||
func clientAndCondConf(name string, withConf bool) (bc *buildlet.Client, conf *dashboard.BuildConfig, err error) { | ||
if strings.Contains(name, "@") { | ||
f := strings.SplitN(name, "@", 2) | ||
if len(f) != 2 { | ||
err = fmt.Errorf("unsupported name %q; for @ form expect <build-config-name>@host[:port]", name) | ||
return | ||
} | ||
builderType := f[0] | ||
conf, ok = dashboard.Builders[builderType] | ||
if !ok { | ||
err = fmt.Errorf("unknown builder type %q (name %q)", builderType, name) | ||
return | ||
if withConf { | ||
var ok bool | ||
conf, ok = dashboard.Builders[builderType] | ||
if !ok { | ||
err = fmt.Errorf("unknown builder type %q (name %q)", builderType, name) | ||
return | ||
} | ||
} | ||
ipPort := f[1] | ||
if !strings.Contains(ipPort, ":") { | ||
|
@@ -82,14 +98,12 @@ func clientAndConf(name string) (bc *buildlet.Client, conf *dashboard.BuildConfi | |
if err != nil { | ||
return | ||
} | ||
var builderType string | ||
var ok bool | ||
for _, rb := range rbs { | ||
if rb.Name == name { | ||
conf, ok = dashboard.Builders[rb.BuilderType] | ||
if !ok { | ||
err = fmt.Errorf("builder %q exists, but unknown builder type %q", name, rb.BuilderType) | ||
return | ||
} | ||
break | ||
ok = true | ||
builderType = rb.BuilderType | ||
} | ||
} | ||
if !ok { | ||
|
@@ -101,5 +115,11 @@ func clientAndConf(name string) (bc *buildlet.Client, conf *dashboard.BuildConfi | |
if err != nil { | ||
return | ||
} | ||
|
||
conf, ok = dashboard.Builders[builderType] | ||
if !ok { | ||
log.Fatalf("Builder type %q not known to this gomote binary. Update your gomote binary. TODO: teach gomote to fetch build configs from the server (Issue 30929)", builderType) | ||
} | ||
|
||
return bc, conf, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters