Conversation
Service: &host.PortService{ | ||
Name: app.Name + "-web", | ||
Create: true, | ||
Check: &host.PortServiceCheck{Type: "http"}, |
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.
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.
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.
We could add a loose check that accepts any status code (maybe status code -1
), what do you think?
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.
I think that could work. We could also just use the TCP checker?
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.
Yeah, probably easier to just do TCP and won't show up in the logs, we can always change it later.
@titanous I'm thinking of renaming the types |
@@ -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") | |||
|
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.
Why was this removed?
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.
Is it used anywhere? I think it's a leftover from the original code.
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.
It sets an environment variable that should be passed on. It is 'used' in the sense that that env var should be available.
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.
Yes, I figured that os.Getenv("container") == ""
, since I couldn't find anything setting container
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.
libvirt-lxc sets it. Check out the environment of a container.
Changing the type names is fine, |
} | ||
portStr := strconv.Itoa(port.Port) | ||
if portStr == "0" { | ||
portStr = env["PORT"] |
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.
Do this before converting to a string.
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.
env["PORT"]
is a string, so I need to convert that to an integer then.
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.
Ah, misunderstood this. Can't we just serialize the info after port assignment?
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.
What do you mean by that?
This should have a bunch of integration tests covering each option of the service check, especially stuff like |
e02e0f6
to
09c8393
Compare
@titanous Do we need to test all cases though? I'd test the |
09c8393
to
a86d3c3
Compare
A sanity check or two wouldn't hurt, but you don't need to go overboard. |
f7fb2ca
to
04404d9
Compare
@titanous Tests pass. |
} | ||
} | ||
} | ||
localAddr := fmt.Sprintf("127.0.0.1:%v", port.Port) |
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.
Do we need this? Can't we just use addr
?
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.
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) |
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.
Why does this service register with discoverd?
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.
Ouch, totally missed that, I think I copied the boilerplate code from the TCP app...
147014a
to
b9b32dd
Compare
@titanous Addressed again. Note that TestFailure takes 11s for some reason, the |
@archseer Yes, sounds like a threshold/timeout issue. |
0bafbb5
to
499f551
Compare
@titanous Ready for another pass, should pass CI after the server is restarted. |
499f551
to
1559e5f
Compare
@@ -136,7 +136,11 @@ func (RegisterSuite) TestRegister(c *C) { | |||
Events: make(chan MonitorEvent), | |||
} | |||
hb := reg.Register() | |||
defer hb.Close() | |||
defer func() { | |||
go func() { <-unregisterChan }() |
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.
What does this goroutine do?
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.
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.
LGTM |
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>
1559e5f
to
97afdf0
Compare
This is ready for merge. I'm writing a quick prototype of how the CLI-side interactions with these services would go.