Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Fix secret volume does not get mounted by webhook #332

Closed
wants to merge 5 commits into from

Conversation

mayitbeegh
Copy link
Contributor

@mayitbeegh mayitbeegh commented Oct 8, 2021

TL;DR

#306 introduced an issue with secret file injection where nil pointer error happens if a pod contains a secret-less volume. A nil check on the secret fixes this error. Relevant logs below:
2021/10/08 06:15:58 http: panic serving 10.42.0.1:46429: runtime error: invalid memory address or nil pointer dereference goroutine 328 [running]: net/http.(*conn).serve.func1(0xc0009903c0) /usr/local/go/src/net/http/server.go:1824 +0x153 panic(0x214cbc0, 0x3826290) /usr/local/go/src/runtime/panic.go:971 +0x499 github.com/flyteorg/flytepropeller/pkg/webhook.AppendVolume(0x28727c8, 0xc00075e880, 0xc000766300, 0x1, 0x1, 0xc000ba92a0, 0x10, 0x0, 0x0, 0x0, ...) /go/src/github.com/flyteorg/flytepropeller/pkg/webhook/utils.go:112 +0xcc github.com/flyteorg/flytepropeller/pkg/webhook.K8sSecretInjector.Inject(0x28727c8, 0xc00075e880, 0xc00070b1a0, 0xc0002ffc00, 0x38, 0xc00076acc0, 0x2, 0x2) /go/src/github.com/flyteorg/flytepropeller/pkg/webhook/k8s_secrets.go:54 +0x1b8 github.com/flyteorg/flytepropeller/pkg/webhook.(*SecretsMutator).Mutate(0xc000fd3ac0, 0x28727c8, 0xc00075e880, 0xc0002ffc00, 0x2826200, 0xc0011f37a0, 0xc000acfb00, 0x3) /go/src/github.com/flyteorg/flytepropeller/pkg/webhook/secrets.go:53 +0x2f5 github.com/flyteorg/flytepropeller/pkg/webhook.PodMutator.Mutate(0xc00075e040, 0x38361c0, 0xc00017d140, 0x1, 0x1, 0x28727c8, 0xc00075e880, 0xc0002ffc00, 0x3, 0x0, ...) /go/src/github.com/flyteorg/flytepropeller/pkg/webhook/pod.go:117 +0xd0 github.com/flyteorg/flytepropeller/pkg/webhook.(*PodMutator).Handle(0xc000988ba0, 0x28727c8, 0xc00075e880, 0xc0011eaff0, 0x24, 0x0, 0x0, 0xc00074d2e8, 0x2, 0xc00074d2ea, ...) /go/src/github.com/flyteorg/flytepropeller/pkg/webhook/pod.go:94 +0x276 sigs.k8s.io/controller-runtime/pkg/webhook/admission.(*Webhook).Handle(0xc000197c80, 0x28727c8, 0xc00075e880, 0xc0011eaff0, 0x24, 0x0, 0x0, 0xc00074d2e8, 0x2, 0xc00074d2ea, ...)

Before:
Screen Shot 2021-10-08 at 11 14 10

After:
Screen Shot 2021-10-08 at 09 49 54

Task under test:
@task(secret_requests=[Secret(group=SECRET_GROUP, key=SECRET_NAME, mount_requirement=Secret.MountType.FILE)]) def secret_file_task() -> (str, str): # SM here is a handle to the secrets manager sm = flytekit.current_context().secrets f = sm.get_secrets_file(SECRET_GROUP, SECRET_NAME) secret_val = sm.get(SECRET_GROUP, SECRET_NAME) # returning the filename and the secret_val return f, secret_val

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

Tracking Issue

flyteorg/flyte#1451

Follow-up issue

NA

Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Signed-off-by: Sean Lin <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant