-
Notifications
You must be signed in to change notification settings - Fork 8.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
Fix cleanup temp dir path #10797
Fix cleanup temp dir path #10797
Conversation
✅ Deploy Preview for kubernetes-ingress-nginx canceled.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: miklezzzz The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The 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/test-infra repository. |
Welcome @miklezzzz! |
Hi @miklezzzz. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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/test-infra repository. |
it seems it makes sense to have it as + "/nginx/" (with a trailing slash), without slash path.Walk doesn't walk over symlinks which is a problem for a chroot'ed image |
5c70a9d
to
d3afb03
Compare
cbc29b6
to
050c887
Compare
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some questions
@@ -71,6 +71,8 @@ const ( | |||
emptyUID = "-1" | |||
) | |||
|
|||
var tmpDir = os.TempDir() + "/nginx/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this really need to be a global thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, the same value should be used across several functions in nginx.go
like NewNGINXController
and cleanTmpNginxCfg
so I thought it would make sense to define that variable globally. Moreover, I trust I saw some other local tmpDir's in other packages which is pitty and perhaps requires refactoring.
@@ -361,28 +361,28 @@ func TestCleanTempNginxCfg(t *testing.T) { | |||
t.Fatal(err) | |||
} | |||
|
|||
tmpfile, err := os.CreateTemp("", tempNginxPattern) | |||
tmpfile1, err := os.CreateTemp(tmpDir, tempNginxPattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you dont need to set that
If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by TempDir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we leave it unset, it uses /tmp
but the point is that some time ago a change was introduced to NewNGINXController
func that defined tmpDir
for temp files (configs) as os.TempDir() + "/nginx", from that point cleanTempNginxCfg
func had stopped to work.
Now, we are here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, thanks for the clarification
Signed-off-by: Mikhail Scherba <[email protected]>
Signed-off-by: Mikhail Scherba <[email protected]>
Signed-off-by: Mikhail Scherba <[email protected]>
050c887
to
771faa1
Compare
Signed-off-by: Mikhail Scherba <[email protected]>
PR needs rebase. 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. |
Already done in #11569. |
What this PR does / why we need it:
As of now, controller doesn't delete temp config files from "/tmp/nginx", clogging up FS, because it seeks them in "/tmp".
Types of changes
Which issue/s this PR fixes
How Has This Been Tested?
It was tested in a dev cluster. The ingress validation feature was disabled and an intentionally wrong snippet was introduced to make ingress controller check configuration for a substantial period of time. It transpired that temp configuration files don't get deleted at all.
Checklist: