mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Add an option for resource-gatherer to look only on master node
This commit is contained in:
parent
4bb30e0097
commit
74773827ba
@ -149,8 +149,11 @@ func (f *Framework) BeforeEach() {
|
|||||||
Logf("Skipping waiting for service account")
|
Logf("Skipping waiting for service account")
|
||||||
}
|
}
|
||||||
|
|
||||||
if TestContext.GatherKubeSystemResourceUsageData {
|
if TestContext.GatherKubeSystemResourceUsageData != "false" && TestContext.GatherKubeSystemResourceUsageData != "none" {
|
||||||
f.gatherer, err = NewResourceUsageGatherer(f.Client, ResourceGathererOptions{inKubemark: ProviderIs("kubemark")})
|
f.gatherer, err = NewResourceUsageGatherer(f.Client, ResourceGathererOptions{
|
||||||
|
inKubemark: ProviderIs("kubemark"),
|
||||||
|
masterOnly: TestContext.GatherKubeSystemResourceUsageData == "master",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Logf("Error while creating NewResourceUsageGatherer: %v", err)
|
Logf("Error while creating NewResourceUsageGatherer: %v", err)
|
||||||
} else {
|
} else {
|
||||||
@ -209,7 +212,7 @@ func (f *Framework) AfterEach() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
summaries := make([]TestDataSummary, 0)
|
summaries := make([]TestDataSummary, 0)
|
||||||
if TestContext.GatherKubeSystemResourceUsageData && f.gatherer != nil {
|
if TestContext.GatherKubeSystemResourceUsageData != "false" && TestContext.GatherKubeSystemResourceUsageData != "none" && f.gatherer != nil {
|
||||||
By("Collecting resource usage data")
|
By("Collecting resource usage data")
|
||||||
summaries = append(summaries, f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.AddonResourceConstraints))
|
summaries = append(summaries, f.gatherer.stopAndSummarize([]int{90, 99, 100}, f.AddonResourceConstraints))
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
|
utilruntime "k8s.io/kubernetes/pkg/util/runtime"
|
||||||
|
"k8s.io/kubernetes/pkg/util/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -225,6 +226,7 @@ type containerResourceGatherer struct {
|
|||||||
|
|
||||||
type ResourceGathererOptions struct {
|
type ResourceGathererOptions struct {
|
||||||
inKubemark bool
|
inKubemark bool
|
||||||
|
masterOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewResourceUsageGatherer(c *client.Client, options ResourceGathererOptions) (*containerResourceGatherer, error) {
|
func NewResourceUsageGatherer(c *client.Client, options ResourceGathererOptions) (*containerResourceGatherer, error) {
|
||||||
@ -263,18 +265,21 @@ func NewResourceUsageGatherer(c *client.Client, options ResourceGathererOptions)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
g.workerWg.Add(len(nodeList.Items))
|
|
||||||
for _, node := range nodeList.Items {
|
for _, node := range nodeList.Items {
|
||||||
g.workers = append(g.workers, resourceGatherWorker{
|
if !options.masterOnly || system.IsMasterNode(&node) {
|
||||||
c: c,
|
g.workerWg.Add(1)
|
||||||
nodeName: node.Name,
|
g.workers = append(g.workers, resourceGatherWorker{
|
||||||
wg: &g.workerWg,
|
c: c,
|
||||||
containerIDToNameMap: g.containerIDToNameMap,
|
nodeName: node.Name,
|
||||||
containerIDs: g.containerIDs,
|
wg: &g.workerWg,
|
||||||
stopCh: g.stopCh,
|
containerIDToNameMap: g.containerIDToNameMap,
|
||||||
finished: false,
|
containerIDs: g.containerIDs,
|
||||||
inKubemark: false,
|
stopCh: g.stopCh,
|
||||||
})
|
finished: false,
|
||||||
|
inKubemark: false,
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &g, nil
|
return &g, nil
|
||||||
|
@ -47,9 +47,10 @@ type TestContextType struct {
|
|||||||
VerifyServiceAccount bool
|
VerifyServiceAccount bool
|
||||||
DeleteNamespace bool
|
DeleteNamespace bool
|
||||||
CleanStart bool
|
CleanStart bool
|
||||||
// If set to true framework will start a goroutine monitoring resource usage of system add-ons.
|
// If set to 'true' or 'all' framework will start a goroutine monitoring resource usage of system add-ons.
|
||||||
// It will read the data every 30 seconds from all Nodes and print summary during afterEach.
|
// It will read the data every 30 seconds from all Nodes and print summary during afterEach. If set to 'master'
|
||||||
GatherKubeSystemResourceUsageData bool
|
// only master Node will be monitored.
|
||||||
|
GatherKubeSystemResourceUsageData string
|
||||||
GatherLogsSizes bool
|
GatherLogsSizes bool
|
||||||
GatherMetricsAfterTest bool
|
GatherMetricsAfterTest bool
|
||||||
// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
|
// Currently supported values are 'hr' for human-readable and 'json'. It's a comma separated list.
|
||||||
@ -123,7 +124,7 @@ func RegisterFlags() {
|
|||||||
flag.BoolVar(&TestContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
|
flag.BoolVar(&TestContext.VerifyServiceAccount, "e2e-verify-service-account", true, "If true tests will verify the service account before running.")
|
||||||
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
|
flag.BoolVar(&TestContext.DeleteNamespace, "delete-namespace", true, "If true tests will delete namespace after completion. It is only designed to make debugging easier, DO NOT turn it off by default.")
|
||||||
flag.BoolVar(&TestContext.CleanStart, "clean-start", false, "If true, purge all namespaces except default and system before running tests. This serves to Cleanup test namespaces from failed/interrupted e2e runs in a long-lived cluster.")
|
flag.BoolVar(&TestContext.CleanStart, "clean-start", false, "If true, purge all namespaces except default and system before running tests. This serves to Cleanup test namespaces from failed/interrupted e2e runs in a long-lived cluster.")
|
||||||
flag.BoolVar(&TestContext.GatherKubeSystemResourceUsageData, "gather-resource-usage", false, "If set to true framework will be monitoring resource usage of system add-ons in (some) e2e tests.")
|
flag.StringVar(&TestContext.GatherKubeSystemResourceUsageData, "gather-resource-usage", "false", "If set to 'true' or 'all' framework will be monitoring resource usage of system all add-ons in (some) e2e tests, if set to 'master' framework will be monitoring master node only, if set to 'none' of 'false' monitoring will be turned off.")
|
||||||
flag.BoolVar(&TestContext.GatherLogsSizes, "gather-logs-sizes", false, "If set to true framework will be monitoring logs sizes on all machines running e2e tests.")
|
flag.BoolVar(&TestContext.GatherLogsSizes, "gather-logs-sizes", false, "If set to true framework will be monitoring logs sizes on all machines running e2e tests.")
|
||||||
flag.BoolVar(&TestContext.GatherMetricsAfterTest, "gather-metrics-at-teardown", false, "If set to true framwork will gather metrics from all components after each test.")
|
flag.BoolVar(&TestContext.GatherMetricsAfterTest, "gather-metrics-at-teardown", false, "If set to true framwork will gather metrics from all components after each test.")
|
||||||
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "hr", "Comma separated list: 'hr' for human readable summaries 'json' for JSON ones.")
|
flag.StringVar(&TestContext.OutputPrintType, "output-print-type", "hr", "Comma separated list: 'hr' for human readable summaries 'json' for JSON ones.")
|
||||||
|
Loading…
Reference in New Issue
Block a user