-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
287 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# Copyright 2024 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Build sidecar-mounter go binary | ||
FROM golang:1.22.7 AS metadata-prefetch-builder | ||
|
||
ARG STAGINGVERSION | ||
|
||
WORKDIR /gcs-fuse-csi-driver | ||
ADD . . | ||
RUN make metadata-prefetch BINDIR=/bin | ||
|
||
# go/gke-releasing-policies#base-images | ||
FROM gke.gcr.io/debian-base:bookworm-v1.0.4-gke.2 AS debian | ||
|
||
# go/gke-releasing-policies#base-images | ||
FROM gcr.io/distroless/base-debian12 | ||
ARG TARGETPLATFORM | ||
|
||
# Copy existing binaries. | ||
COPY --from=debian /bin/ls /bin/ls | ||
|
||
# Copy dependencies. | ||
COPY --from=debian /lib/x86_64-linux-gnu/libselinux.so.1 /lib/x86_64-linux-gnu/libselinux.so.1 | ||
COPY --from=debian /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc.so.6 | ||
COPY --from=debian /lib/x86_64-linux-gnu/libpcre2-8.so.0 /lib/x86_64-linux-gnu/libpcre2-8.so.0 | ||
COPY --from=debian /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 | ||
|
||
# Copy the built binaries | ||
COPY --from=metadata-prefetch-builder /bin/gcs-fuse-csi-driver-metadata-prefetch /gcs-fuse-csi-driver-metadata-prefetch | ||
|
||
ENTRYPOINT ["/gcs-fuse-csi-driver-metadata-prefetch"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
Copyright 2018 The Kubernetes Authors. | ||
Copyright 2024 Google LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"os" | ||
"os/exec" | ||
"os/signal" | ||
"syscall" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
func main() { | ||
klog.InitFlags(nil) | ||
flag.Parse() | ||
|
||
// Create cancellable context to pass into exec. | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
|
||
// Handle SIGTERM signal. | ||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGTERM) | ||
|
||
go func() { | ||
<-sigs | ||
klog.Info("Caught SIGTERM signal: Terminating...") | ||
cancel() | ||
|
||
os.Exit(0) // Exit gracefully | ||
}() | ||
|
||
// Start the "ls" command in the background. | ||
// All our volumes are mounted under the /volumes/ directory. | ||
cmd := exec.CommandContext(ctx, "ls", "-R", "/volumes/") | ||
cmd.Stdout = nil // Connects file descriptor to the null device (os.DevNull). | ||
|
||
// TODO(hime): We should research stratergies to parallelize ls execution and speed up cache population. | ||
err := cmd.Start() | ||
if err == nil { | ||
klog.Info("Running ls on bucket(s)") | ||
err = cmd.Wait() | ||
if err != nil { | ||
klog.Errorf("Error while executing ls command: %v", err) | ||
} else { | ||
klog.Info("Metadata prefetch complete.") | ||
} | ||
} else { | ||
klog.Errorf("Error starting ls command: %v.", err) | ||
} | ||
|
||
klog.Info("Going to sleep...") | ||
|
||
// Keep the process running. | ||
select {} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.