Change:
<!-- This form is for bug reports and feature requests ONLY! If you're looking for help check and the . If this may be security issue, please disclose it privately via --Is this a BUG REPORT or FEATURE REQUEST?: What happened: fsgroup tests are flaking 1-2 times a day: https://k8s- Some test logs: https://k8s- https://k8s-
could you take a look?
I'll look into this.
I found why the tests failed, see my analysis of logs: I created a PR () trying to fix the issue. I am still investigating kubelet and trying to reproduce the issue locally.
/assign
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
/remove-lifecycle stale
/lifecycle frozen

Discussion:
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", <del> "//staging/src/k8s.io/apimachinery/pkg/fields:go_default_library", </del> "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",

storagev1 "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" <del> "k8s.io/apimachinery/pkg/fields" </del> "k8s.io/apimachinery/pkg/runtime/schema" utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets"

By("Deleting second pod") framework.DeletePodOrFail(config.client, config.ns, pod2.Name) }) <del> It("should not set different fsGroups for two pods simultaneously", func() { fsGroup1, fsGroup2 := int64(1234), int64(4321) By("Create first pod and check fsGroup is set") pod1 := createPodWithFsGroupTest(config, testVol, fsGroup1, fsGroup1) By("Create second pod and check fsGroup is still the old one") pod2 := createPodWithFsGroupTest(config, testVol, fsGroup2, fsGroup1) ep := &eventPatterns{ reason:  "AlreadyMountedVolume", pattern: make([]string, 2), } ep.pattern = append(ep.pattern, fmt.Sprintf("The requested fsGroup is %d", fsGroup2)) ep.pattern = append(ep.pattern, "The volume may not be shareable.") checkPodEvents(config, pod2.Name, ep) By("Deleting first pod") framework.DeletePodOrFail(config.client, config.ns, pod1.Name) By("Deleting second pod") framework.DeletePodOrFail(config.client, config.ns, pod2.Name) }) </del> }) })

// TODO: // - check for these errors in unit tests instead It("should fail due to non-existent path", func() { <del> ep := &eventPatterns{ reason:  "FailedMount", pattern: make([]string, 2)} ep.pattern = append(ep.pattern, "MountVolume.NewMounter initialization failed") </del> testVol := &localTestVolume{ node:            config.node0, hostDir:         "/non-existent/location/nowhere",

createLocalPVCsPVs(config, []*localTestVolume{testVol}, immediateMode) pod, err := createLocalPod(config, testVol, nil) Expect(err).To(HaveOccurred()) <del> checkPodEvents(config, pod.Name, ep) </del> <ins> err = framework.WaitTimeoutForPodRunningInNamespace(config.client, pod.Name, pod.Namespace, framework.PodStartShortTimeout) Expect(err).To(HaveOccurred()) </ins> cleanupLocalPVCsPVs(config, []*localTestVolume{testVol}) })

framework.Skipf("Runs only when number of nodes >= 2") } <del> ep := &eventPatterns{ reason:  "FailedMount", pattern: make([]string, 2)} ep.pattern = append(ep.pattern, "NodeSelectorTerm") ep.pattern = append(ep.pattern, "MountVolume.NodeAffinity check failed") </del> testVols := setupLocalVolumesPVCsPVs(config, DirectoryLocalVolumeType, config.node0, 1, immediateMode) testVol := testVols[0]

err = framework.WaitTimeoutForPodRunningInNamespace(config.client, pod.Name, pod.Namespace, framework.PodStartShortTimeout) Expect(err).To(HaveOccurred()) <del> checkPodEvents(config, pod.Name, ep) </del> cleanupLocalVolumes(config, []*localTestVolume{testVol}) })

Expect(err).NotTo(HaveOccurred()) } <del> type eventPatterns struct { reason  string pattern []string } func checkPodEvents(config *localTestConfig, podName string, ep *eventPatterns) { var events *v1.EventList selector := fields.Set{ "involvedObject.kind":      "Pod", "involvedObject.name":      podName, "involvedObject.namespace": config.ns, "reason":                   ep.reason, }.AsSelector().String() options := metav1.ListOptions{FieldSelector: selector} events, err := config.client.CoreV1().Events(config.ns).List(options) Expect(err).NotTo(HaveOccurred()) Expect(len(events.Items)).NotTo(Equal(0)) for _, p := range ep.pattern { Expect(events.Items[0].Message).To(ContainSubstring(p)) } } </del> // The tests below are run against multiple mount point types // Test two pods at the same time, write from pod1, and read from pod2