Skip to content

Commit

Permalink
Fix ProxyKube not reporting its readiness (gravitational#12150)
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini authored Apr 21, 2022
1 parent b543b99 commit 6cdcfe7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func TestIntegrations(t *testing.T) {
t.Run("PortForwarding", suite.bind(testPortForwarding))
t.Run("ProxyHostKeyCheck", suite.bind(testProxyHostKeyCheck))
t.Run("ReverseTunnelCollapse", suite.bind(testReverseTunnelCollapse))
t.Run("Readyz", suite.bind(testReadyz))
t.Run("RotateChangeSigningAlg", suite.bind(testRotateChangeSigningAlg))
t.Run("RotateRollback", suite.bind(testRotateRollback))
t.Run("RotateSuccess", suite.bind(testRotateSuccess))
Expand Down Expand Up @@ -3663,6 +3664,45 @@ func testPAM(t *testing.T, suite *integrationTestSuite) {
}
}

func testReadyz(t *testing.T, suite *integrationTestSuite) {
// TODO: test more service combinations

recConfig, err := types.NewSessionRecordingConfigFromConfigFile(types.SessionRecordingConfigSpecV2{
Mode: types.RecordOff,
})
require.NoError(t, err)

tconf := suite.defaultServiceConfig()
tconf.Auth.Enabled = true
tconf.Auth.SessionRecordingConfig = recConfig
tconf.Proxy.Enabled = true
tconf.Proxy.DisableWebInterface = true
tconf.Proxy.Kube.Enabled = true
// fire up the proxy kube service
tconf.Proxy.Kube.ListenAddr = utils.NetAddr{
AddrNetwork: "tcp",
Addr: "127.0.0.1:0",
}
tconf.SSH.Enabled = false
tconf.DiagnosticAddr = utils.NetAddr{
AddrNetwork: "tcp",
Addr: "127.0.0.1:0",
}

teleport := suite.newTeleportWithConfig(t, nil, nil, tconf)
t.Cleanup(func() { require.NoError(t, teleport.StopAll()) })

diagAddr, err := teleport.Process.DiagnosticAddr()
require.NoError(t, err)

require.Eventually(t, func() bool {
resp, err := http.Get(fmt.Sprintf("http://%s/readyz", diagAddr))
require.NoError(t, err)
require.NoError(t, resp.Body.Close())
return resp.StatusCode == http.StatusOK
}, 5*time.Second, 500*time.Millisecond)
}

// testRotateSuccess tests full cycle cert authority rotation
func testRotateSuccess(t *testing.T, suite *integrationTestSuite) {
tr := utils.NewTracer(utils.ThisFunction()).Start()
Expand Down
2 changes: 2 additions & 0 deletions lib/kube/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ func NewTLSServer(cfg TLSServerConfig) (*TLSServer, error) {
}
} else {
log.Debug("No local kube credentials on proxy, will not start kubernetes_service heartbeats")
// Report the component as being ready.
cfg.OnHeartbeat(nil)
}

return server, nil
Expand Down

0 comments on commit 6cdcfe7

Please sign in to comment.