Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

discoverd: Die sdutil! #933

Merged
merged 10 commits into from Feb 12, 2015
Merged

discoverd: Die sdutil! #933

merged 10 commits into from Feb 12, 2015

Conversation

archseer
Copy link
Contributor

@archseer archseer commented Feb 2, 2015

This is ready for merge. I'm writing a quick prototype of how the CLI-side interactions with these services would go.

Service: &host.PortService{
Name: app.Name + "-web",
Create: true,
Check: &host.PortServiceCheck{Type: "http"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

HTTP check by default. Works for majority of cases, but might not fit where the user has a resource that is not available under /, however I think we can just note that in the usage manual, and then have instructions on how to change the service checker using the CLI.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could add a loose check that accepts any status code (maybe status code -1), what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that could work. We could also just use the TCP checker?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, probably easier to just do TCP and won't show up in the logs, we can always change it later.

@archseer
Copy link
Contributor Author

archseer commented Feb 2, 2015

@titanous I'm thinking of renaming the types PortService -> Service, PortServiceChecker -> Checker/HealthChecker. WDYT? They are under the host type namespace, so they won't conflict with let's say, Checker from the discoverd package.

@@ -535,9 +619,6 @@ func Main() {
log.Fatalf("Unable to unmarshal config: %v", err)
}

// Propagate the plugin-specific container env variable
config.Env["container"] = os.Getenv("container")

Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it used anywhere? I think it's a leftover from the original code.

Copy link
Contributor

Choose a reason for hiding this comment

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

It sets an environment variable that should be passed on. It is 'used' in the sense that that env var should be available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I figured that os.Getenv("container") == "", since I couldn't find anything setting container

Copy link
Contributor

Choose a reason for hiding this comment

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

libvirt-lxc sets it. Check out the environment of a container.

@titanous
Copy link
Contributor

titanous commented Feb 3, 2015

Changing the type names is fine, HealthChecker sounds good.

}
portStr := strconv.Itoa(port.Port)
if portStr == "0" {
portStr = env["PORT"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this before converting to a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

env["PORT"] is a string, so I need to convert that to an integer then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, misunderstood this. Can't we just serialize the info after port assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by that?

@titanous
Copy link
Contributor

titanous commented Feb 3, 2015

This should have a bunch of integration tests covering each option of the service check, especially stuff like KillDown and thresholds.

@archseer archseer force-pushed the discoverd-die-sdutil branch 4 times, most recently from e02e0f6 to 09c8393 Compare February 3, 2015 21:00
@archseer
Copy link
Contributor Author

archseer commented Feb 3, 2015

@titanous Do we need to test all cases though? I'd test the KillDown + StartTimeout, but all of the Monitor and Checker options are already tested in the discoverd unit tests.

@titanous
Copy link
Contributor

titanous commented Feb 3, 2015

A sanity check or two wouldn't hurt, but you don't need to go overboard.

@archseer archseer force-pushed the discoverd-die-sdutil branch 8 times, most recently from f7fb2ca to 04404d9 Compare February 5, 2015 02:50
@archseer
Copy link
Contributor Author

archseer commented Feb 5, 2015

@titanous Tests pass.

}
}
}
localAddr := fmt.Sprintf("127.0.0.1:%v", port.Port)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? Can't we just use addr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran into problems originally, but I think that might have happened because of other problems. Now that we have tests, I'll give it a try.

port := os.Getenv("PORT")
addr := ":" + port

hb, err := discoverd.AddServiceAndRegister(service, addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this service register with discoverd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ouch, totally missed that, I think I copied the boilerplate code from the TCP app...

@archseer
Copy link
Contributor Author

archseer commented Feb 9, 2015

@titanous Addressed again. Note that TestFailure takes 11s for some reason, the current == nil event is sent straight away, but the down event is delayed.

@titanous
Copy link
Contributor

titanous commented Feb 9, 2015

@archseer Yes, sounds like a threshold/timeout issue.

@archseer archseer force-pushed the discoverd-die-sdutil branch 3 times, most recently from 0bafbb5 to 499f551 Compare February 11, 2015 05:44
@archseer
Copy link
Contributor Author

@titanous Ready for another pass, should pass CI after the server is restarted.

@@ -136,7 +136,11 @@ func (RegisterSuite) TestRegister(c *C) {
Events: make(chan MonitorEvent),
}
hb := reg.Register()
defer hb.Close()
defer func() {
go func() { <-unregisterChan }()
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this goroutine do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1559e5f calls the wrapped heartbeater's close method, which then triggers the mocked Close() method, that sends a notification to the unregisterChan. I'm making sure the channel gets drained here, so that the function does not block indefinitely.

@titanous
Copy link
Contributor

LGTM

Blaž Hrastnik added 10 commits February 12, 2015 13:01
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
It's no longer used or implemented.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Now that the services can be registered using containerinit and configuration,
we can get rid of this utility -- this way users don't need to create custom
images that include sdutil if they want to register their service.

Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
Signed-off-by: Blaž Hrastnik <blaz.hrast@gmail.com>
archseer pushed a commit that referenced this pull request Feb 12, 2015
@archseer archseer merged commit 474cd75 into master Feb 12, 2015
@archseer archseer deleted the discoverd-die-sdutil branch February 12, 2015 04:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants