-
Notifications
You must be signed in to change notification settings - Fork 92
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
Local publisher address tf #3660
Merged
+39
−29
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
816ee7d
Configurable IP address
rossjones 67316fb
Update values
rossjones c2f8733
ensure publisher accepts non-name address
rossjones a89cb64
Handle error case with address lookup
rossjones 485cf14
Local publisher server listen on all interfaces
rossjones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -28,12 +28,12 @@ type Publisher struct { | |
func NewLocalPublisher(ctx context.Context, directory string, host string, port int) *Publisher { | ||
p := &Publisher{ | ||
baseDirectory: directory, | ||
host: resolveAddress(ctx, host), | ||
host: ResolveAddress(ctx, host), | ||
port: port, | ||
urlPrefix: fmt.Sprintf("http://%s:%d", host, port), | ||
} | ||
|
||
p.server = NewLocalPublisherServer(ctx, p.baseDirectory, p.host, p.port) | ||
p.server = NewLocalPublisherServer(ctx, p.baseDirectory, p.port) | ||
go p.server.Run(ctx) | ||
|
||
return p | ||
|
@@ -93,20 +93,17 @@ func (p *Publisher) PublishResult( | |
|
||
var _ publisher.Publisher = (*Publisher)(nil) | ||
|
||
func resolveAddress(ctx context.Context, address string) string { | ||
func ResolveAddress(ctx context.Context, address string) string { | ||
addressType, ok := network.AddressTypeFromString(address) | ||
if !ok { | ||
log.Ctx(ctx).Debug().Stringer("AddressType", addressType).Msgf("unable to find address type: %s, binding to 0.0.0.0", address) | ||
return "0.0.0.0" | ||
} | ||
|
||
// If we were provided with an address type and not an address, so we should look up | ||
// an address from the type. | ||
addrs, err := network.GetNetworkAddress(addressType, network.AllAddresses) | ||
if err == nil && len(addrs) > 0 { | ||
return addrs[0] | ||
if ok { | ||
addrs, err := network.GetNetworkAddress(addressType, network.AllAddresses) | ||
if err == nil && len(addrs) > 0 { | ||
return addrs[0] | ||
} else { | ||
log.Ctx(ctx).Error().Err(err).Msg("failed to resolve network address by type, using 127.0.0.1") | ||
return "127.0.0.1" | ||
} | ||
} | ||
|
||
log.Ctx(ctx).Error().Err(err).Stringer("AddressType", addressType).Msgf("unable to find address for type, using 127.0.0.1") | ||
return "127.0.0.1" | ||
return address | ||
Comment on lines
+96
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just tries to resolve a name (public etc) to an address, and leaves IP addresses untouched. We might want to re-assess whether the name (public, local, etc) lookup is worthwhile as it doesn't solve the actual problem of potentially not having a public address. |
||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: redundant to pass the cli flag as
BACALHAU_LOCAL_PUBLISHER_ADDRESS
env variable translates to the same configThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this flag actually expects an IP address, it expects one of these values: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/lib/network/network.go#L111
via: https://github.com/bacalhau-project/bacalhau/blob/main/pkg/publisher/local/publisher.go#L31 -> https://github.com/bacalhau-project/bacalhau/blob/main/pkg/publisher/local/publisher.go#L97
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it can be an IP address as well. The problem here is that 'public' won't resolve to anything for google cloud as it doesn't give out public addresses to the VMs at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have pushed a code change, will redeploy to staging this evening.