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

[GOBBLIN-204] Add a service that fetches GaaS flow configs from a git… #2055

Closed
wants to merge 3 commits into from

Conversation

htran1
Copy link
Contributor

@htran1 htran1 commented Aug 11, 2017

… repository

Dear Gobblin maintainers,

Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!

JIRA

Description

  • Here are some details about my PR, including screenshots (if applicable):
    Add a service that fetches GaaS flow configs from a git repository.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:

Commits

  • My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

@htran1
Copy link
Contributor Author

htran1 commented Aug 11, 2017

@abti, please review.

@@ -258,7 +258,7 @@ protected Spec readSpecFromFile(Path path) throws IOException {
Spec spec = null;

try (FSDataInputStream fis = fs.open(path);) {
spec = this.specSerDe.deserialize(IOUtils.toByteArray(fis));
spec = this.specSerDe.deserialize(ByteStreams.toByteArray(fis));
Copy link
Member

Choose a reason for hiding this comment

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

why choose ByteStreams over IOUtils?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is due to toByteArray() being removed in v1.4 of apache-commons-codec, so I switched to the equivalent Guava method to avoid issues in the IDE with method not found errors

void processGitConfigChanges() throws GitAPIException, IOException {
// if not active or if the flow catalog is not up yet then can't process config changes
if (!isActive || !this.flowCatalog.isRunning()) {
return;
Copy link
Member

Choose a reason for hiding this comment

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

nit: An info log might be helpful in debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added info log.

switch (change.getChangeType()) {
case ADD:
case MODIFY:
addSpec(change);
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't MODIFY be delete and create?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MODIFY is the update case. The FlowCatalog handles update in the put() call like add.

if (specStore.exists(spec.getUri())) {
        specStore.updateSpec(spec);
        this.listeners.onUpdateSpec(spec);
      } else {

// if the repository was not found then clone a new one
this.git = Git.cloneRepository()
.setDirectory(repoDirFile)
.setURI(this.repoUri)
Copy link
Member

Choose a reason for hiding this comment

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

so its always on master branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added config for setting branch.

latestGitHash = head.getName();

// diff old and new heads to find changes
ObjectReader reader = this.git.getRepository().newObjectReader();
Copy link
Member

Choose a reason for hiding this comment

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

what happens if there is a conflict?

if someone force pushes, can this run into a detached head state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No changes are made locally, so there should be no conflicts other than issues due to forced pushes going back in time.

I changed the code to do a hard reset instead of pull to avoid any issues.

private void addSpec(DiffEntry change) throws IOException {
if (checkConfigFilePath(change.getNewPath())) {
Path configFilePath = new Path(this.repositoryDir, change.getNewPath());
Config flowConfig = loadConfigFileWithFlowNameOverrides(configFilePath);
Copy link
Member

Choose a reason for hiding this comment

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

Should we handle exception here if the config file is malformed and simply log the error instead of bubbling up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added warning message.

@abti
Copy link
Member

abti commented Aug 16, 2017

LGTM, but the Travis is failing for this test:

org.apache.gobblin.service.modules.core.GitConfigMonitorTest.cleanUp FAILED
java.io.IOException at GitConfigMonitorTest.java:111

Copy link
Member

@abti abti left a comment

Choose a reason for hiding this comment

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

+1

@asfgit asfgit closed this in da382db Aug 16, 2017
treff7es pushed a commit to prezi/gobblin that referenced this pull request Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants