Skip to content

fix: optionally skip reading the config from the API server#2940

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:masterfrom
jsafrane:skip-secret
Jan 14, 2026
Merged

fix: optionally skip reading the config from the API server#2940
k8s-ci-robot merged 1 commit intokubernetes-sigs:masterfrom
jsafrane:skip-secret

Conversation

@jsafrane
Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:
Skip reading the driver configuration from the API server when -cloud-config-secret-name or -cloud-config-secret-namespace is explicitly set to an empty string.

The unit test change is technically not necessary - no unit test actually tries to get the Secret from provided namespace / name, it only make the unit test future proof once they start doing so.

Which issue(s) this PR fixes:

Fixes #2939

This fixes the aforementioned bug in a backward compatible way. If anyone set AZURE_CREDENTIAL_FILE, the driver by default still reads the config from the Kubernetes API server Secret. Only when someone explicitly sets -cloud-config-secret-name to "", the driver uses AZURE_CREDENTIAL_FILE env var without talking to the API server.
I think this makes the Deployments in this repository working as they are today.

Requirements:

Release note:

The driver no longer tries to read its config from the API server Secret if `-cloud-config-secret-name` or `-cloud-config-secret-namespace` are empty strings. `AZURE_CREDENTIAL_FILE` must be set and point to a valid config file then.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 13, 2026
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 13, 2026
@jsafrane
Copy link
Copy Markdown
Contributor Author

@andyzhangx this PR is for discussion. I can easily make the driver to use AZURE_CREDENTIAL_FILE if it is set, regardless of --cloud-config-secret-name. I think it would be even correct - someone has set the env. var, so they probably want the driver to use it and not download it from the API server. But it might be a breaking change. What do you think?

@andyzhangx andyzhangx requested a review from Copilot January 13, 2026 11:42
@andyzhangx andyzhangx changed the title Optionally skip reading the config from the API server fix: optionally skip reading the config from the API server Jan 13, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the ability to skip reading the driver configuration from the Kubernetes API server by explicitly setting the -cloud-config-secret-name or -cloud-config-secret-namespace flags to empty strings. This allows the driver to use only the AZURE_CREDENTIAL_FILE environment variable without making API calls.

Changes:

  • Modified the condition to skip Kubernetes secret reading when either secretName or secretNamespace is an empty string
  • Updated logging to distinguish between disabled secret reading and failed secret reading
  • Updated test to provide non-empty secret name and namespace parameters for future-proofing

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/azurefile/azure.go Added checks to skip API server config reading when secret name or namespace are empty strings, and updated logging accordingly
pkg/azurefile/azure_test.go Updated test to pass concrete secret name and namespace values instead of empty strings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Skip reading the driver configuration from the API server when
-cloud-config-secret-name or -cloud-config-secret-namespace is explicitly
set to an empty string.

The unit test change is technically not necessary - no unit test actually
tries to get the Secret from provided namespace / name, it only make the
unit test future proof once they start doing so.
@Phaow
Copy link
Copy Markdown
Contributor

Phaow commented Jan 14, 2026

/test pull-azurefile-csi-driver-external-e2e-nfs

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@andyzhangx andyzhangx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx, jsafrane

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 14, 2026
@k8s-ci-robot k8s-ci-robot merged commit 33774cd into kubernetes-sigs:master Jan 14, 2026
28 checks passed
@andyzhangx
Copy link
Copy Markdown
Member

/cherrypick release-1.34

@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@andyzhangx: new pull request created: #2942

Details

In response to this:

/cherrypick release-1.34

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The driver reads configuration from a Secret when AZURE_CREDENTIAL_FILE is set

6 participants