mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
storage version integration test: check the test server's health before running
we disabled the /healthz check because our test blocks one post-start hook from finishing. Instead we should check all the other /healthz/... endpoints before running the tests
This commit is contained in:
parent
4480c44535
commit
dc047b183b
@ -22,6 +22,7 @@ go_library(
|
|||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/util/cert:go_default_library",
|
"//staging/src/k8s.io/client-go/util/cert:go_default_library",
|
||||||
|
"//staging/src/k8s.io/kube-aggregator/pkg/apiserver:go_default_library",
|
||||||
"//test/utils:go_default_library",
|
"//test/utils:go_default_library",
|
||||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -38,6 +38,7 @@ import (
|
|||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/util/cert"
|
"k8s.io/client-go/util/cert"
|
||||||
|
"k8s.io/kube-aggregator/pkg/apiserver"
|
||||||
"k8s.io/kubernetes/cmd/kube-apiserver/app"
|
"k8s.io/kubernetes/cmd/kube-apiserver/app"
|
||||||
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
|
||||||
testutil "k8s.io/kubernetes/test/utils"
|
testutil "k8s.io/kubernetes/test/utils"
|
||||||
@ -201,8 +202,6 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
}
|
}
|
||||||
}(stopCh)
|
}(stopCh)
|
||||||
|
|
||||||
// skip healthz check when we test the storage version manager poststart hook
|
|
||||||
if instanceOptions.StorageVersionWrapFunc == nil {
|
|
||||||
t.Logf("Waiting for /healthz to be ok...")
|
t.Logf("Waiting for /healthz to be ok...")
|
||||||
|
|
||||||
client, err := kubernetes.NewForConfig(server.GenericAPIServer.LoopbackClientConfig)
|
client, err := kubernetes.NewForConfig(server.GenericAPIServer.LoopbackClientConfig)
|
||||||
@ -218,7 +217,16 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO())
|
req := client.CoreV1().RESTClient().Get().AbsPath("/healthz")
|
||||||
|
// The storage version bootstrap test wraps the storage version post-start
|
||||||
|
// hook, so the hook won't become health when the server bootstraps
|
||||||
|
if instanceOptions.StorageVersionWrapFunc != nil {
|
||||||
|
// We hardcode the param instead of having a new instanceOptions field
|
||||||
|
// to avoid confusing users with more options.
|
||||||
|
storageVersionCheck := fmt.Sprintf("poststarthook/%s", apiserver.StorageVersionPostStartHookName)
|
||||||
|
req.Param("exclude", storageVersionCheck)
|
||||||
|
}
|
||||||
|
result := req.Do(context.TODO())
|
||||||
status := 0
|
status := 0
|
||||||
result.StatusCode(&status)
|
result.StatusCode(&status)
|
||||||
if status == 200 {
|
if status == 200 {
|
||||||
@ -249,7 +257,6 @@ func StartTestServer(t Logger, instanceOptions *TestServerInstanceOptions, custo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("failed to wait for default namespace to be created: %v", err)
|
return result, fmt.Errorf("failed to wait for default namespace to be created: %v", err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// from here the caller must call tearDown
|
// from here the caller must call tearDown
|
||||||
result.ClientConfig = restclient.CopyConfig(server.GenericAPIServer.LoopbackClientConfig)
|
result.ClientConfig = restclient.CopyConfig(server.GenericAPIServer.LoopbackClientConfig)
|
||||||
|
@ -64,8 +64,12 @@ func init() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
// legacyAPIServiceName is the fixed name of the only non-groupified API version
|
// legacyAPIServiceName is the fixed name of the only non-groupified API version
|
||||||
const legacyAPIServiceName = "v1."
|
legacyAPIServiceName = "v1."
|
||||||
|
// StorageVersionPostStartHookName is the name of the storage version updater post start hook.
|
||||||
|
StorageVersionPostStartHookName = "built-in-resources-storage-version-updater"
|
||||||
|
)
|
||||||
|
|
||||||
// ExtraConfig represents APIServices-specific configuration
|
// ExtraConfig represents APIServices-specific configuration
|
||||||
type ExtraConfig struct {
|
type ExtraConfig struct {
|
||||||
@ -269,7 +273,7 @@ func (c completedConfig) NewWithDelegate(delegationTarget genericapiserver.Deleg
|
|||||||
utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerIdentity) {
|
utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIServerIdentity) {
|
||||||
// Spawn a goroutine in aggregator apiserver to update storage version for
|
// Spawn a goroutine in aggregator apiserver to update storage version for
|
||||||
// all built-in resources
|
// all built-in resources
|
||||||
s.GenericAPIServer.AddPostStartHookOrDie("built-in-resources-storage-version-updater", func(hookContext genericapiserver.PostStartHookContext) error {
|
s.GenericAPIServer.AddPostStartHookOrDie(StorageVersionPostStartHookName, func(hookContext genericapiserver.PostStartHookContext) error {
|
||||||
// Wait for apiserver-identity to exist first before updating storage
|
// Wait for apiserver-identity to exist first before updating storage
|
||||||
// versions, to avoid storage version GC accidentally garbage-collecting
|
// versions, to avoid storage version GC accidentally garbage-collecting
|
||||||
// storage versions.
|
// storage versions.
|
||||||
|
Loading…
Reference in New Issue
Block a user