Skip to content
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

tests in controller.go all require secrets #562

Open
joejulian opened this issue Nov 1, 2024 · 1 comment · May be fixed by #563
Open

tests in controller.go all require secrets #562

joejulian opened this issue Nov 1, 2024 · 1 comment · May be fixed by #563
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@joejulian
Copy link

Using v5.3.1:

If a controller's methods don't require secrets, and no SecretsFile is defined in TestConfig when running tests through GinkgoTest, controller tests will panic as nearly every test passes some sc.Secrets. even if sc.Secrets is nil.

// Configure the sanity test
var config = &sanity.TestConfig{
	Address: "/tmp/csi/csi.sock",
	DialOptions: []grpc.DialOption{
		grpc.WithTransportCredentials(insecure.NewCredentials()),
	},
	CreateTargetDir: func(basePath string) (string, error) {
		targetDir := filepath.Join(tempDir, "target")
		err := os.MkdirAll(targetDir, 0755)
		return targetDir, err
	},
	CreateStagingDir: func(basePath string) (string, error) {
		stagingDir := filepath.Join(tempDir, "staging")
		err := os.MkdirAll(stagingDir, 0755)
		return stagingDir, err
	},
	RemoveTargetPath: func(basePath string) error {
		targetDir := filepath.Join(tempDir, "target")
		err := os.RemoveAll(targetDir)
		return err
	},
	RemoveStagingPath: func(basePath string) error {
		targetDir := filepath.Join(tempDir, "staging")
		err := os.RemoveAll(targetDir)
		return err
	},
}

// Register the sanity tests
var _ = sanity.GinkgoTest(config)
  [PANICKED] in [It] - /usr/lib/go/src/runtime/panic.go:262 @ 11/01/24 12:06:32.825
• [PANICKED] [0.002 seconds]
Controller Service [Controller Server] ControllerPublishVolume [It] should fail when no node id is provided
/home/jjulian/dev/go/pkg/mod/github.com/kubernetes-csi/csi-test/[email protected]/pkg/sanity/controller.go:862

  [PANICKED] Test Panicked
  In [It] at: /usr/lib/go/src/runtime/panic.go:262 @ 11/01/24 12:06:32.825

  runtime error: invalid memory address or nil pointer dereference

  Full Stack Trace
    github.com/kubernetes-csi/csi-test/v5/pkg/sanity.init.func1.9.3()
        /home/jjulian/dev/go/pkg/mod/github.com/kubernetes-csi/csi-test/[email protected]/pkg/sanity/controller.go:866 +0x31

This is not happening in ControllerPublishVolume. It never gets called because [pkg/sanity/controller.go 828-841]

		It("should fail when the requested volume does not exist", func() {

			rsp, err := r.ValidateVolumeCapabilities(
				context.Background(),
				&csi.ValidateVolumeCapabilitiesRequest{
					VolumeId: sc.Config.IDGen.GenerateUniqueValidVolumeID(),
					VolumeCapabilities: []*csi.VolumeCapability{
						TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
					},
					Secrets: sc.Secrets.ControllerValidateVolumeCapabilitiesSecret,
				},
			)
			ExpectErrorCode(rsp, err, codes.NotFound)
		})

is panicking at sc.Secrets.ControllerValidateVolumeCapabilitiesSecret

This should be valid to not include secrets according to pkg/sanity/sanity.go 256-261

	if len(sc.Config.SecretsFile) > 0 {
		sc.Secrets, err = loadSecrets(sc.Config.SecretsFile)
		Expect(err).NotTo(HaveOccurred())
	} else {
		sc.Secrets = &CSISecrets{}
	}
@joejulian joejulian linked a pull request Nov 1, 2024 that will close this issue
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants