Repository navigation
Conversation
storage-foundation builds status.publicURL as https://api.<publicDomain>/<path>/ without a port. When the cluster ingress sits behind an external balancer that publishes api.<publicDomain> on another port (6443, for example), kubectl works through the kubeconfig, while d8 snapshot download/upload and d8 data export/import with --publish go to port 443 and get a 404 from the balancer. When status.publicURL has no port and names the same host as the kubeconfig server, d8 now uses the kubeconfig server port. --publish-port sets the port explicitly. The address is resolved before the origin-bound HTTP clients are built, so they are pinned to the port actually used. Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
Resuming a download walks the output root and deletes every *.tmp file under it. With -o pointing at an existing directory such as the home directory or /tmp, d8 snapshot download descended into unrelated subdirectories, failed on the first unreadable one with "permission denied", and could otherwise have removed unrelated *.tmp files. The output directory is now refused when it holds an entry a download never writes into an archive root. It is checked before the lock file is created and again once the lock is held. A missing or empty directory, or one an earlier download wrote, is accepted as before. Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
When the published endpoint is reached on a port taken from the kubeconfig or --publish-port, the resolved address is now logged, and a 404 from it carries a hint to pass --publish-port (443 for the default HTTPS port). This covers a setup where api.<publicDomain>:6443 is kube-apiserver itself rather than a balancer in front of the ingress. The help of the commands names --publish-port 443 as the opt-out. A --publish-port that has no effect because the in-cluster endpoint is used now produces a warning. An explicit port equal to the default HTTPS port no longer adds ":443" to a status.publicURL without a port. Resolving the address is shared by the snapshot and data commands, and a 404 from the exporter is classified as dataplane.ErrExportNotFound without changing the error message. Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
The output root check now accepts the .tmp form only for the files a download writes atomically (snapshot.yaml, identity.json, data.tar, data.bin* and the publication state files), and checks that directories and files are what the archive layout expects, so a foreign manifests.tmp or a plain file named manifests is refused instead of being swept or walked. lost+found, .DS_Store, Thumbs.db and desktop.ini are accepted, so a freshly formatted mount or a directory opened in a file manager can still be used or resumed. The resume-time *.tmp sweep skips lost+found. Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
Member
Author
|
Moved to the canonical repository (MR !537). Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Two fixes for
d8 snapshot downloadand the other commands that move volume data through the published endpoint.Port of the published endpoint (commits
reach the published data endpoint on the kubeconfig port,explain a rewritten published endpoint port)dataio.PublicEndpoint/dataio.ResolvePublicURL. Whenstatus.publicURLhas no port and names the same host as the kubeconfig server, which uses a non-default port, the client reaches the published endpoint on the kubeconfig port. Otherwise the URL is used as is.--publish-portsets the port explicitly. It overrides both the kubeconfig port and a port carried bystatus.publicURL.--publish-port 443keeps a port-lessstatus.publicURLon the default HTTPS port, which is the opt-out named in the command help.status.publicURL, the resolved address is logged. A 404 from the exporter on the snapshot download path carries a hint to pass--publish-port. A 404 is classified asdataplane.ErrExportNotFound; the error message itself does not change.--publish-portthat has no effect, because the in-cluster endpoint is used, produces a warning.d8 snapshot download,d8 snapshot upload,d8 data export download,d8 data export listandd8 data import upload(including the Windows build). The deprecatedd8 data list/downloadaliases do not register the flag and keep the automatic behaviour.buildSubClientsnow takes the resolved base URL; the tests reach it through a thin wrapper.SafeClientkeeps the port inCopy(), the same way as--data-insecure-skip-tls-verify.Output directory check (commits
refuse an output directory a download did not write,tighten the output directory check)d8 snapshot downloadrefuses an output directory that holds an entry a download never writes into an archive root. Allowed:manifests/,snapshots/,data/,data.tar.d/anddata.bin.d/;snapshot.yaml,identity.json,data.tar,data.bin*, the publication state files and the lock file;.tmpform, but only for the files written atomically.The entry type is checked as well: a plain file named
manifestsis refused.lost+found,.DS_Store,Thumbs.dbanddesktop.iniare accepted, so a freshly formatted mount, or a directory opened in a file manager, can still be used or resumed. The resume-time*.tmpsweep skipslost+found.The check runs before the lock file is created, so nothing is written into a foreign directory, and again through the locked destination once the lock is held.
A missing or empty directory, or one an earlier download wrote, is accepted as before, so resume keeps working.
Why do we need it, and what problem does it solve?
storage-foundation builds
status.publicURLashttps://api.<publicDomain>/<path>/without a port. Some installations put an external balancer in front of the cluster ingress and publishapi.<publicDomain>only on port 6443:api.<publicDomain>:6443goes through the balancer to ingress-nginx on 443. kubectl works because the kubeconfig carries the port. With--publish=true, d8 goes to port 443, the balancer answers404 Not Found, and the download fails withprepare filesystem inventory: ... unexpected status 404. The only workaround was to run d8 from a cluster node, where--publish=falseis picked. The cluster itself does not know the external port, so the kubeconfig is the only place d8 can learn it from. A platform-wide setting for the external API address is planned separately; this change makes the CLI usable until then.The same heuristic misfires when
api.<publicDomain>:6443is kube-apiserver itself and ingress-nginx serves that name on 443. The log line, the 404 hint and the documented--publish-port 443make that case visible and fixable without reading the code.The output directory issue showed up on the same installation.
d8 snapshot download -o ./and-o /tmp/failed withscan output directory: ... open archive path /home/<user>/<dir>/logs/...: permission denied. The resume scan treats the output directory as the root of the archive, walks it recursively and removes every*.tmpfile it finds. On a home directory or/tmpit walks unrelated trees: it failed only because it hit an unreadable directory first, and otherwise it could have deleted unrelated*.tmpfiles.What is the expected result?
https://api.example.com:6443andstatus.publicURLhttps://api.example.com/ns/snap/vs/:https://api.example.com:6443/ns/snap/vs/...;status_public_urland the resolvedurl.--publish-port 7443the requests go to port 7443. With--publish-port 443they go tostatus.publicURLunchanged.status.publicURLunchanged, so existing setups behave as before.the request went to <url> while status.publicURL is <url>; pass --publish-port ....d8 snapshot download -o ~fails right away withoutput directory holds an entry a snapshot download did not write: /home/<user> contains "..."; choose a new or empty --output directory. No lock file is left there, and nothing is walked or removed..DS_Storeadded by a file manager.Tests:
PublicEndpoint.Resolvetable tests cover:--publish-portparsing, the log line ofResolvePublicURLand the unused-port warning.OpenExportruns against anhttptestTLS server, withstatus.publicURLpointing at port 443 of the server host:WithPublishPort;dataplane: a 404 isErrExportNotFoundwith an unchanged message, and the hint is appended only when set.uploadEndpointfor the snapshot importer, including that the in-cluster URL is never rewritten.CheckOutputRootis tested on the archive layout, on metadata names and on foreign entries (.tmpforms of directory names, wrong entry types). The full-tree pipeline test checks that every downloaded node directory passes it.*.tmpsweep keeps files underlost+found, both for a node directory and for a rooted output directory.checkOutputDiris tested on a missing, empty, earlier-download, foreign and unreadable directory. A command-level test checks that a refused directory gets no lock file.Checklist