Skip to content

Commit f85810b

Browse files
committed
[bootstrapmonitor] Switch from latest to master tag
A recent PR (#4469) proposes to change the `latest` tag to refer to the image of the most recent release intead of the latest merge to master. This change requires updating the bootstrap monitor to use the `master` tag (already updated on every merge to master) to ensure bootstrap testing continues to target the most recently published image.
1 parent 8ebe57a commit f85810b

File tree

8 files changed

+39
-33
lines changed

8 files changed

+39
-33
lines changed

scripts/build_image.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -euo pipefail
99
# DOCKER_IMAGE=myavalanchego ./scripts/build_image.sh # Build local single arch image with a custom image name
1010
# DOCKER_IMAGE=avaplatform/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to docker hub
1111
# DOCKER_IMAGE=localhost:5001/avalanchego ./scripts/build_image.sh # Build and push multi-arch image to private registry
12-
# DOCKER_IMAGE=localhost:5001/avalanchego FORCE_TAG_LATEST=1 ./scripts/build_image.sh # Build and push image to private registry with tag `latest`
12+
# DOCKER_IMAGE=localhost:5001/avalanchego FORCE_TAG_MASTER=1 ./scripts/build_image.sh # Build and push image to private registry with tag `master`
1313

1414
# Multi-arch builds require Docker Buildx and QEMU. buildx should be enabled by
1515
# default in the version of docker included with Ubuntu 22.04, and qemu can be
@@ -32,8 +32,8 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
3232
# Skip building the race image
3333
SKIP_BUILD_RACE="${SKIP_BUILD_RACE:-}"
3434

35-
# Force tagging as latest even if not the master branch
36-
FORCE_TAG_LATEST="${FORCE_TAG_LATEST:-}"
35+
# Force tagging as master for testing purposes
36+
FORCE_TAG_MASTER="${FORCE_TAG_MASTER:-}"
3737

3838
# Load the constants
3939
source "$AVALANCHE_PATH"/scripts/constants.sh
@@ -117,7 +117,13 @@ if [[ -z "${SKIP_BUILD_RACE}" ]]; then
117117
fi
118118

119119
# Only tag the latest image for the master branch when images are pushed to a registry
120-
if [[ "${DOCKER_IMAGE}" == *"/"* && ($image_tag == "master" || -n "${FORCE_TAG_LATEST}") ]]; then
120+
if [[ "${DOCKER_IMAGE}" == *"/"* && $image_tag == "master" ]]; then
121121
echo "Tagging current avalanchego images as $DOCKER_IMAGE:latest"
122122
docker buildx imagetools create -t "$DOCKER_IMAGE:latest" "$DOCKER_IMAGE:$commit_hash"
123123
fi
124+
125+
# Forcibly tag the image as `master` if requested. This is only intended to be used for testing.
126+
if [[ "${DOCKER_IMAGE}" == *"/"* && -n "${FORCE_TAG_MASTER}" ]]; then
127+
echo "Tagging current avalanchego images as $DOCKER_IMAGE:master"
128+
docker buildx imagetools create -t "$DOCKER_IMAGE:master" "$DOCKER_IMAGE:$commit_hash"
129+
fi

scripts/tests.load.kube.kind.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ fi
1313
./scripts/start_kind_cluster.sh "$@"
1414

1515
# Build AvalancheGo image
16-
AVALANCHEGO_IMAGE="localhost:5001/avalanchego"
16+
AVALANCHEGO_IMAGE="localhost:5001/avalanchego:master"
1717
if [[ -n "${SKIP_BUILD_IMAGE:-}" ]]; then
1818
echo "Skipping build of avalanchego image due to SKIP_BUILD_IMAGE=${SKIP_BUILD_IMAGE}"
1919
else
20-
DOCKER_IMAGE="$AVALANCHEGO_IMAGE" FORCE_TAG_LATEST=1 ./scripts/build_image.sh
20+
DOCKER_IMAGE="$AVALANCHEGO_IMAGE" FORCE_TAG_MASTER=1 ./scripts/build_image.sh
2121
fi
2222

2323
# Determine kubeconfig context to use

tests/fixture/bootstrapmonitor/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ and initiates a new test when one is found.
9494
- Mounting the same data volume as the avalanchego node
9595
- Reading bootstrap test configuration as described previously
9696
- Determining the image ID and versions for an image if the
97-
avalanchego image for the pod uses the `latest` tag. This will
97+
avalanchego image for the pod uses the `master` tag. This will
9898
only need to be performed the first pod that a bootstrap testing
9999
`StatefulSet` runs. Subsequent pods from the same `StatefulSet`
100100
should have an image qualified with its SHA and version details
101101
set by the previous test run's `wait-for-completion` pod.
102-
- A new pod will be started with the `latest` image to execute
102+
- A new pod will be started with the `master` image to execute
103103
`avalanchego --versions-json` to determine the image ID (which
104104
includes a sha256 hash) of the image and its avalanchego
105105
versions. Those values will then be applied to the `StatefulSet`
@@ -109,7 +109,7 @@ and initiates a new test when one is found.
109109
versions (including commit hash) of the binary that the image
110110
provides.
111111
- A separate pod is used because the image ID of a non-init
112-
avalanchego container using a `latest`-tagged image is only
112+
avalanchego container using a `master`-tagged image is only
113113
available when that container runs rather than when an init container runs.
114114
- While it would be possible to add an init container running the
115115
same avalanchego image as the primary avalanchego container,
@@ -178,8 +178,8 @@ sync bootstrap usually takes much longer.
178178

179179
If avalanchego supported a `--bootstrap-mode` flag that exited on
180180
successful bootstrap, and a pod configured with this flag used an
181-
image with a `latest` tag, the pod would continuously bootstrap, exit,
182-
and restart with the current latest image. While appealingly simple,
181+
image with a `master` tag, the pod would continuously bootstrap, exit,
182+
and restart with the current `master` image. While appealingly simple,
183183
this approach doesn't directly support:
184184

185185
- A mechanism for resuming a long-running bootstrap. Given the

tests/fixture/bootstrapmonitor/bootstrap_test_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func bootstrapTestConfigForPod(pod *corev1.Pod, nodeContainerName string) (*Boot
111111
}
112112

113113
// Attempt to retrieve the image versions from a pod annotation. The annotation may not be populated in
114-
// the case of a newly-created bootstrap test using an image tagged `latest` that hasn't yet had a
114+
// the case of a newly-created bootstrap test using an image tagged `master` that hasn't yet had a
115115
// chance to discover the versions.
116116
if versionsAnnotation := pod.Annotations[VersionsAnnotationKey]; len(versionsAnnotation) > 0 {
117117
if err := json.Unmarshal([]byte(versionsAnnotation), &testConfig.Versions); err != nil {

tests/fixture/bootstrapmonitor/common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ type ImageDetails struct {
127127
Versions *version.Versions
128128
}
129129

130-
// GetLatestImageDetails retrieves the image details for the avalanchego image with tag `latest`.
131-
func getLatestImageDetails(
130+
// GetMasterImageDetails retrieves the image details for the avalanchego image with tag `master`.
131+
func getMasterImageDetails(
132132
ctx context.Context,
133133
log logging.Logger,
134134
clientset *kubernetes.Clientset,
@@ -141,7 +141,7 @@ func getLatestImageDetails(
141141
return nil, err
142142
}
143143

144-
// Start a new pod with the `latest`-tagged avalanchego image to discover its image ID
144+
// Start a new pod with the `master`-tagged avalanchego image to discover its image ID
145145
pod := &corev1.Pod{
146146
ObjectMeta: metav1.ObjectMeta{
147147
GenerateName: "avalanchego-version-check-",
@@ -152,7 +152,7 @@ func getLatestImageDetails(
152152
Name: containerName,
153153
Command: []string{"./avalanchego"},
154154
Args: []string{"--version-json"},
155-
Image: baseImageName + ":latest",
155+
Image: baseImageName + ":master",
156156
},
157157
},
158158
RestartPolicy: corev1.RestartPolicyNever,

tests/fixture/bootstrapmonitor/e2e/e2e_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const (
4646
repoRelativePath = "tests/fixture/bootstrapmonitor/e2e"
4747

4848
avalanchegoImage = "localhost:5001/avalanchego"
49-
latestAvalanchegoImage = avalanchegoImage + ":latest"
49+
masterAvalanchegoImage = avalanchegoImage + ":master"
5050
monitorImage = "localhost:5001/bootstrap-monitor"
5151
latestMonitorImage = monitorImage + ":latest"
5252

@@ -256,7 +256,7 @@ func buildImage(tc tests.TestContext, imageName string, forceNewHash bool, scrip
256256
) // #nosec G204
257257
cmd.Env = append(os.Environ(),
258258
"DOCKER_IMAGE="+imageName,
259-
"FORCE_TAG_LATEST=1",
259+
"FORCE_TAG_MASTER=1",
260260
"SKIP_BUILD_RACE=1",
261261
)
262262
output, err := cmd.CombinedOutput()
@@ -267,7 +267,7 @@ func newNodeStatefulSet(name string, flags tmpnet.FlagsMap) *appsv1.StatefulSet
267267
statefulSet := tmpnet.NewNodeStatefulSet(
268268
name,
269269
true, // generateName
270-
latestAvalanchegoImage,
270+
masterAvalanchegoImage,
271271
nodeContainerName,
272272
volumeName,
273273
volumeSize,

tests/fixture/bootstrapmonitor/init.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ func InitBootstrapTest(log logging.Logger, namespace string, podName string, nod
4949
}
5050
log.Info("Retrieved bootstrap test config", zap.Reflect("testConfig", testConfig))
5151

52-
// If the image uses the latest tag, determine the latest image id and set the container image to that
53-
if strings.HasSuffix(testConfig.Image, ":latest") {
52+
// If the image uses the master tag, determine the master image id and set the container image to that
53+
if strings.HasSuffix(testConfig.Image, ":master") {
5454
log.Info("Determining image id for image", zap.String("image", testConfig.Image))
55-
latestImageDetails, err := getLatestImageDetails(ctx, log, clientset, namespace, testConfig.Image, nodeContainerName)
55+
masterImageDetails, err := getMasterImageDetails(ctx, log, clientset, namespace, testConfig.Image, nodeContainerName)
5656
if err != nil {
57-
return fmt.Errorf("failed to get latest image details: %w", err)
57+
return fmt.Errorf("failed to get master image details: %w", err)
5858
}
5959
log.Info("Updating owning statefulset with image details",
60-
zap.String("image", latestImageDetails.Image),
61-
zap.Reflect("versions", latestImageDetails.Versions),
60+
zap.String("image", masterImageDetails.Image),
61+
zap.Reflect("versions", masterImageDetails.Versions),
6262
)
63-
if err := setImageDetails(ctx, log, clientset, namespace, podName, latestImageDetails); err != nil {
63+
if err := setImageDetails(ctx, log, clientset, namespace, podName, masterImageDetails); err != nil {
6464
return fmt.Errorf("failed to set container image: %w", err)
6565
}
6666
}

tests/fixture/bootstrapmonitor/wait.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,25 @@ func WaitForCompletion(
114114
ctx, cancel := context.WithTimeout(context.Background(), contextDuration)
115115
defer cancel()
116116

117-
log.Info("Starting pod to get the image id for the `latest` tag")
118-
latestImageDetails, err := getLatestImageDetails(ctx, log, clientset, namespace, testConfig.Image, nodeContainerName)
117+
log.Info("Starting pod to get the image id for the `master` tag")
118+
masterImageDetails, err := getMasterImageDetails(ctx, log, clientset, namespace, testConfig.Image, nodeContainerName)
119119
if err != nil {
120-
log.Error("failed to get latest image id", zap.Error(err))
120+
log.Error("failed to get master image id", zap.Error(err))
121121
return false, nil
122122
}
123123

124-
if latestImageDetails.Image == testConfig.Image {
124+
if masterImageDetails.Image == testConfig.Image {
125125
log.Info(ImageUnchanged)
126126
return false, nil
127127
}
128128

129129
log.Info("Found updated image",
130-
zap.String("image", latestImageDetails.Image),
131-
zap.Reflect("versions", latestImageDetails.Versions),
130+
zap.String("image", masterImageDetails.Image),
131+
zap.Reflect("versions", masterImageDetails.Versions),
132132
)
133133

134134
log.Info("Updating StatefulSet to trigger a new test")
135-
if err := setImageDetails(ctx, log, clientset, namespace, podName, latestImageDetails); err != nil {
135+
if err := setImageDetails(ctx, log, clientset, namespace, podName, masterImageDetails); err != nil {
136136
log.Error("failed to set container image", zap.Error(err))
137137
return false, nil
138138
}

0 commit comments

Comments
 (0)