Skip to content

Commit c60d918

Browse files
committed
Removing cache and image translation from Hub&Spoke
Now that we are using the cluster's container-runtime to pull images, maintaining our own cache is redundant since the container runtime is using its own cache on the nodes. In addition to that, we had some issue invalidating cache entries in some cases, therefore and since we don't need it anymore, removing it completely simplifies the flow. We should use the images as mentioned in the ManagedClusterModule. There is no need for additional manipulations to it.
1 parent 29b6433 commit c60d918

File tree

8 files changed

+203
-537
lines changed

8 files changed

+203
-537
lines changed

cmd/manager-hub/main.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package main
1818

1919
import (
2020
"flag"
21-
"time"
22-
2321
"github.com/kubernetes-sigs/kernel-module-management/internal/config"
2422
"github.com/kubernetes-sigs/kernel-module-management/internal/controllers"
2523
"k8s.io/apimachinery/pkg/runtime"
@@ -38,7 +36,6 @@ import (
3836
"github.com/kubernetes-sigs/kernel-module-management/api-hub/v1beta1"
3937
"github.com/kubernetes-sigs/kernel-module-management/internal/build"
4038
"github.com/kubernetes-sigs/kernel-module-management/internal/build/pod"
41-
"github.com/kubernetes-sigs/kernel-module-management/internal/cache"
4239
"github.com/kubernetes-sigs/kernel-module-management/internal/cluster"
4340
"github.com/kubernetes-sigs/kernel-module-management/internal/cmd"
4441
"github.com/kubernetes-sigs/kernel-module-management/internal/constants"
@@ -135,14 +132,10 @@ func main() {
135132
ctrlLogger.Info("Adding controller")
136133

137134
operatorNamespace := cmd.GetEnvOrFatalError(constants.OperatorNamespaceEnvVar, setupLogger)
138-
139-
cache := cache.New[string](10 * time.Minute)
140135
ctx := ctrl.SetupSignalHandler()
141-
cache.StartCollecting(ctx, 10*time.Minute)
142-
143136
mcmr := hub.NewManagedClusterModuleReconciler(
144137
client,
145-
manifestwork.NewCreator(client, scheme, kernelAPI, registryAPI, cache, operatorNamespace),
138+
manifestwork.NewCreator(client, scheme, kernelAPI, registryAPI, operatorNamespace),
146139
cluster.NewClusterAPI(client, kernelAPI, buildAPI, signAPI, operatorNamespace),
147140
statusupdater.NewManagedClusterModuleStatusUpdater(client),
148141
filterAPI,
@@ -177,5 +170,4 @@ func main() {
177170
cmd.FatalError(setupLogger, err, "problem running manager")
178171
}
179172

180-
cache.WaitForTermination()
181173
}

install.sh

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Copyright Contributors to the Open Cluster Management project
2+
#!/usr/bin/env bash
3+
4+
# Clusteradm CLI location
5+
: ${INSTALL_DIR:="/usr/local/bin"}
6+
7+
# sudo is required to copy binary to INSTALL_DIR for linux
8+
: ${USE_SUDO:="false"}
9+
10+
# Http request CLI
11+
HTTP_REQUEST_CLI=curl
12+
13+
# GitHub Organization and repo name to download release
14+
GITHUB_ORG=open-cluster-management-io
15+
GITHUB_REPO=clusteradm
16+
17+
# CLI filename
18+
CLI_FILENAME=clusteradm
19+
20+
CLI_FILE="${INSTALL_DIR}/${CLI_FILENAME}"
21+
22+
getSystemInfo() {
23+
ARCH=$(uname -m)
24+
case $ARCH in
25+
armv7*) ARCH="arm";;
26+
aarch64) ARCH="arm64";;
27+
x86_64) ARCH="amd64";;
28+
esac
29+
30+
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]')
31+
32+
# Most linux distro needs root permission to copy the file to /usr/local/bin
33+
if [[ "$OS" == "linux" || "$OS" == "darwin" ]] && [ "$INSTALL_DIR" == "/usr/local/bin" ]; then
34+
USE_SUDO="true"
35+
fi
36+
}
37+
38+
verifySupported() {
39+
local supported=(darwin-amd64 darwin-arm64 linux-amd64 linux-arm64 windows-amd64)
40+
local current_osarch="${OS}-${ARCH}"
41+
42+
for osarch in "${supported[@]}"; do
43+
if [ "$osarch" == "$current_osarch" ]; then
44+
echo "Your system is ${OS}_${ARCH}"
45+
return
46+
fi
47+
done
48+
49+
echo "No prebuilt binary for ${current_osarch}"
50+
exit 1
51+
}
52+
53+
checkHttpRequestCLI() {
54+
if type "curl" > /dev/null; then
55+
HTTP_REQUEST_CLI=curl
56+
elif type "wget" > /dev/null; then
57+
HTTP_REQUEST_CLI=wget
58+
else
59+
echo "Either curl or wget is required"
60+
exit 1
61+
fi
62+
}
63+
64+
checkExisting() {
65+
if [ -f "$CLI_FILE" ]; then
66+
echo -e "\nclusteradm CLI is detected:"
67+
echo -e "Reinstalling clusteradm CLI - ${CLI_FILE}...\n"
68+
else
69+
echo -e "Installing clusteradm CLI...\n"
70+
fi
71+
}
72+
73+
runAsRoot() {
74+
local CMD="$*"
75+
76+
if [ $EUID -ne 0 -a $USE_SUDO = "true" ]; then
77+
CMD="sudo $CMD"
78+
fi
79+
80+
$CMD
81+
}
82+
83+
downloadFile() {
84+
TARGET_VERSION=$1
85+
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}"
86+
CLI_ARTIFACT="${CLI_FILENAME}_${OS}_${ARCH}.tar.gz"
87+
88+
if [ "$TARGET_VERSION" == "latest" ]; then
89+
DOWNLOAD_URL="${DOWNLOAD_BASE}/releases/latest/download/${CLI_ARTIFACT}"
90+
else
91+
DOWNLOAD_URL="${DOWNLOAD_BASE}/releases/download/${TARGET_VERSION}/${CLI_ARTIFACT}"
92+
fi
93+
94+
# Create the temp directory
95+
TMP_ROOT=$(mktemp -dt clusteradm-install-XXXXXX)
96+
ARTIFACT_TMP_FILE="$TMP_ROOT/$CLI_ARTIFACT"
97+
98+
echo "Downloading $DOWNLOAD_URL ..."
99+
if [ "$HTTP_REQUEST_CLI" == "curl" ]; then
100+
curl -SsL "$DOWNLOAD_URL" -o "$ARTIFACT_TMP_FILE"
101+
else
102+
wget -q -O "$ARTIFACT_TMP_FILE" "$DOWNLOAD_URL"
103+
fi
104+
105+
if [ ! -f "$ARTIFACT_TMP_FILE" ]; then
106+
echo "failed to download $DOWNLOAD_URL ..."
107+
exit 1
108+
fi
109+
}
110+
111+
isReleaseAvailable() {
112+
LATEST_RELEASE_TAG=$1
113+
114+
CLI_ARTIFACT="${CLI_FILENAME}_${OS}_${ARCH}.tar.gz"
115+
DOWNLOAD_BASE="https://github.com/${GITHUB_ORG}/${GITHUB_REPO}/releases/download"
116+
DOWNLOAD_URL="${DOWNLOAD_BASE}/${LATEST_RELEASE_TAG}/${CLI_ARTIFACT}"
117+
118+
if [ "$HTTP_REQUEST_CLI" == "curl" ]; then
119+
httpstatus=$(curl -sSLI -o /dev/null -w "%{http_code}" "$DOWNLOAD_URL")
120+
if [ "$httpstatus" == "200" ]; then
121+
return 0
122+
fi
123+
else
124+
wget -q --spider "$DOWNLOAD_URL"
125+
exitstatus=$?
126+
if [ $exitstatus -eq 0 ]; then
127+
return 0
128+
fi
129+
fi
130+
return 1
131+
}
132+
133+
installFile() {
134+
tar xf "$ARTIFACT_TMP_FILE" -C "$TMP_ROOT"
135+
local tmp_root_cli="$TMP_ROOT/$CLI_FILENAME"
136+
137+
if [ ! -f "$tmp_root_cli" ]; then
138+
echo "Failed to unpack clusteradm CLI executable."
139+
exit 1
140+
fi
141+
142+
chmod o+x $tmp_root_cli
143+
runAsRoot cp "$tmp_root_cli" "$INSTALL_DIR"
144+
145+
if [ -f "$CLI_FILE" ]; then
146+
echo "$CLI_FILENAME installed into $INSTALL_DIR successfully."
147+
else
148+
echo "Failed to install $CLI_FILENAME"
149+
exit 1
150+
fi
151+
}
152+
153+
fail_trap() {
154+
result=$?
155+
if [ "$result" != "0" ]; then
156+
echo "Failed to install clusteradm CLI"
157+
echo "For support, go to https://open-cluster-management.io/"
158+
fi
159+
cleanup
160+
exit $result
161+
}
162+
163+
cleanup() {
164+
if [[ -d "${TMP_ROOT:-}" ]]; then
165+
rm -rf "$TMP_ROOT"
166+
fi
167+
}
168+
169+
installCompleted() {
170+
echo -e "\nTo get started with clusteradm, please visit https://open-cluster-management.io/getting-started/"
171+
}
172+
173+
# -----------------------------------------------------------------------------
174+
# main
175+
# -----------------------------------------------------------------------------
176+
trap "fail_trap" EXIT
177+
178+
getSystemInfo
179+
checkHttpRequestCLI
180+
181+
if [ -z "$1" ]; then
182+
TARGET_VERSION="latest"
183+
else
184+
TARGET_VERSION=v$1
185+
fi
186+
187+
verifySupported
188+
checkExisting
189+
190+
echo "Installing $TARGET_VERSION OCM clusteradm CLI..."
191+
192+
downloadFile $TARGET_VERSION
193+
installFile
194+
cleanup
195+
196+
installCompleted

internal/cache/cache.go

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)