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

Infra: Write static topology updates to file system #2430

Merged
merged 6 commits into from
Feb 8, 2019

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Feb 7, 2019

Infra services can be instructed to write topology updates to file system by configuring the discovery.static.Filename.
In case of an empty string, the updated topology is not written.


This change is Reviewable

@oncilla oncilla added this to the Q1S2 milestone Feb 7, 2019
@oncilla oncilla requested a review from scrye February 7, 2019 16:50
@oncilla
Copy link
Contributor Author

oncilla commented Feb 7, 2019

a discussion (no related file):
Disregard first commit. (cherry-pick of pr #2429 )


@oncilla
Copy link
Contributor Author

oncilla commented Feb 7, 2019

a discussion (no related file):
full run: https://buildkite.com/scionproto/scionproto/builds/1891


Call raw callback with raw bytes and the parsed topology
to give the caller access without reparsing.
Add library support for atomically writing to file on disk.
Add filename parameter to static discovery parameters.
The filename indicates where an updated static topology
shall be written to. In case of the empty string, the topology
is not written.
Enable the idiscovery library to write static topology
updates to the filesystem. This can be enabled by setting
the filename in the StaticConfig.
Check that the static topology update is written to disk,
and that it does not differ from the version served by
the discovery service.
Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 9 files at r1, 2 of 2 files at r2, 1 of 1 files at r3, 5 of 5 files at r4, 1 of 1 files at r5.
Reviewable status: 2 of 10 files reviewed, 6 unresolved discussions (waiting on @oncilla and @scrye)


go/lib/discovery/topofetcher/fetcher.go, line 33 at r2 (raw file):

type Callbacks struct {
	// Raw is called with the raw body from the discovery service response and the parsed topology.
	Raw func(common.RawBytes, *topology.Topo)

Isn't there a large amount of overlap between the content of the two arguments? Why are they both needed?


go/lib/infra/modules/idiscovery/idiscovery.go, line 136 at r5 (raw file):

}

// startPeriodicFetcherWriter starts a runner that periodically fetches the topology.

There's quite a bit of duplication here that might become awkward to maintain. I'm wondering if we can halve the number of types/implementations.

Is there a reason why the periodic runner/fetcher task of a dynamic topology can't have the same behavior/implementation as the static one? Sure, it's never useful to dump the dynamic to disk, so callers will never set the Filename field.

Would something like this work?


go/lib/infra/modules/idiscovery/idiscovery.go, line 230 at r5 (raw file):

// NewWriteFetcher creates a periodic.Task that fetches the topology from the discovery
// service and calls the provided handler on the received topology. If the handler indiacates

s/indiacates/indicates.


go/lib/infra/modules/idiscovery/idiscovery.go, line 232 at r5 (raw file):

// service and calls the provided handler on the received topology. If the handler indiacates
// an update, the topology is written to filename.
func NewWriteFetcher(handler TopoHandler, params discovery.FetchParams, filename string,

WriteFetcher parses oddly (it sounds like it fetches writes).

Maybe NewWritingFetcher?

Or, for such a specialized object, we can bite the bullet and go full Java with NewFetchThenWriteTask. Overall in the codebase it's going to be called rarely, so a bit of extra verbosity is not that big of an issue.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r6.
Reviewable status: 2 of 10 files reviewed, 6 unresolved discussions (waiting on @oncilla and @scrye)

Reduce code duplication
Copy link
Contributor Author

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 10 files reviewed, 5 unresolved discussions (waiting on @scrye)


go/lib/discovery/topofetcher/fetcher.go, line 33 at r2 (raw file):

Previously, scrye (Sergiu Costea) wrote…

Isn't there a large amount of overlap between the content of the two arguments? Why are they both needed?

We want to avoid the callback from having to re-parse the topology unnecessarily.


go/lib/infra/modules/idiscovery/idiscovery.go, line 136 at r5 (raw file):

Previously, scrye (Sergiu Costea) wrote…

There's quite a bit of duplication here that might become awkward to maintain. I'm wondering if we can halve the number of types/implementations.

Is there a reason why the periodic runner/fetcher task of a dynamic topology can't have the same behavior/implementation as the static one? Sure, it's never useful to dump the dynamic to disk, so callers will never set the Filename field.

Would something like this work?

Refactored to reduced code duplication.
However, the two different types for StaticConfig and FetchConfig makes initialization cleaner IMO.


go/lib/infra/modules/idiscovery/idiscovery.go, line 230 at r5 (raw file):

Previously, scrye (Sergiu Costea) wrote…

s/indiacates/indicates.

Done.


go/lib/infra/modules/idiscovery/idiscovery.go, line 232 at r5 (raw file):

Previously, scrye (Sergiu Costea) wrote…

WriteFetcher parses oddly (it sounds like it fetches writes).

Maybe NewWritingFetcher?

Or, for such a specialized object, we can bite the bullet and go full Java with NewFetchThenWriteTask. Overall in the codebase it's going to be called rarely, so a bit of extra verbosity is not that big of an issue.

Removed during refactor.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 9 files at r7, 1 of 1 files at r12.
Reviewable status: 3 of 10 files reviewed, all discussions resolved (waiting on @scrye)

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 9 files at r7.
Reviewable status: 3 of 10 files reviewed, all discussions resolved (waiting on @scrye)

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r8, 5 of 5 files at r9, 1 of 1 files at r11.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@oncilla oncilla merged commit 49c7b25 into scionproto:master Feb 8, 2019
@oncilla oncilla deleted the infra-write-static branch February 8, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants