-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test framework does not help investigating daemonset pods #9983
Comments
xref: Example which needed to copy-paste the |
@chrischdi Just for my understanding. I got it correctly that we could use this func to stream DaemonSet logs from workload clusters? |
Yes, workload or also Management Cluster. |
The function itself would come down to: type WatchDaemonSetLogsByLabelSelectorInput struct {
GetLister framework.GetLister
Cache toolscache.Cache
ClientSet *kubernetes.Clientset
Labels map[string]string
LogPath string
}
// WatchDaemonSetLogsByLabelSelector streams logs for all containers for all pods belonging to a daemonset on the basis of label. Each container's logs are streamed
// in a separate goroutine so they can all be streamed concurrently. This only causes a test failure if there are errors
// retrieving the daemonset, its pods, or setting up a log file. If there is an error with the log streaming itself,
// that does not cause the test to fail.
func WatchDaemonSetLogsByLabelSelector(ctx context.Context, input WatchDaemonSetLogsByLabelSelectorInput) {
Expect(ctx).NotTo(BeNil(), "ctx is required for WatchDaemonSetLogsByLabelSelector")
Expect(input.Cache).NotTo(BeNil(), "input.Cache is required for WatchDaemonSetLogsByLabelSelector")
Expect(input.ClientSet).NotTo(BeNil(), "input.ClientSet is required for WatchDaemonSetLogsByLabelSelector")
Expect(input.Labels).NotTo(BeNil(), "input.Selector is required for WatchDaemonSetLogsByLabelSelector")
daemonSetList := &appsv1.DaemonSetList{}
Eventually(func() error {
return input.GetLister.List(ctx, daemonSetList, client.MatchingLabels(input.Labels))
}, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to get daemonsets for labels")
for _, daemonSet := range daemonSetList.Items {
watchPodLogs(ctx, watchPodLogsInput{
Cache: input.Cache,
ClientSet: input.ClientSet,
Namespace: daemonSet.Namespace,
DeploymentName: daemonSet.Name,
LabelSelector: daemonSet.Spec.Selector,
LogPath: input.LogPath,
})
}
} |
Sounds good /triage accepted Let's make sure we start using this func in CAPV for CPI & CSI (I think) once this is implemented and cherry-picked |
What would you like to be added (User Story)?
As a developer, I'd like to save the logs of pods running in my e2e tests as daemonsets.
Detailed Description
The cloud-provider-vsphere project makes use of CAPI and CAPV to setup a test environment / provision a kubernetes cluster.
On top it deploys the Cloud Provider as Daemonset.
When investigating issues it is important to be able to analyse the logs of the Daemonset pods.
The current utilities in CAPI's test framework only focus on being able to stream and save logs of Deployments via:
cluster-api/test/framework/deployment_helpers.go
Line 117 in a313570
and
cluster-api/test/framework/deployment_helpers.go
Line 153 in a313570
Under the hood this helpers use the function:
cluster-api/test/framework/deployment_helpers.go
Line 189 in a313570
For watching and saving logs for Daemonsets in other projects, it would be helpful to either being able to extend the functionality by exposing
watchPodLogs
publicly, or by implementing similar functions for Daemonsets.This could also help analysing Daemonset logs for CAPI providers, which may also deploy daemonsets for a functional cluster (cloud-provider, csi, cni).
Anything else you would like to add?
cc @DanielXiao
/assign sbueringer
Label(s) to be applied
/kind feature
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.
The text was updated successfully, but these errors were encountered: