Skip to content
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

feat: Add spec.ordinals.start. #448

Merged
merged 44 commits into from
Dec 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3d50513
feat: Add staringOrdinal
vimystic Nov 11, 2024
212e049
fix lint error
vimystic Nov 11, 2024
6c4f498
update build pods test to reflect startingordinals usage
vimystic Nov 12, 2024
8c55a1f
add retries for trivy to overcome the throttling
vimystic Nov 14, 2024
9dfdca0
Merge branch 'main' into vimystic/feat/445-add-starting-ordinals
vimystic Nov 18, 2024
62db355
Update: reorg so that we use a similar structure to stateful set inst…
vimystic Nov 19, 2024
b9ccbfa
optimize & use starting ordinal for pvcs too
vimystic Nov 20, 2024
804e076
Update to use starting ordinal in appropriate files
vimystic Nov 20, 2024
75dcd8a
Optimize tests
vimystic Nov 20, 2024
bfe1a51
fix test
vimystic Nov 20, 2024
e088656
fix test
vimystic Nov 20, 2024
0a52ff4
Use Ordinal within spec (duh))
vimystic Nov 20, 2024
91bded5
Remove redundant parameters
vimystic Nov 20, 2024
6bb42dd
Note: this is incorrect since PVC allocations start from 0, only the …
vimystic Nov 20, 2024
a8cc9e0
Attempt to find root cause of mapping issue crash
vimystic Nov 20, 2024
be87c7d
Adding spec.ordinal.start usage back to configmap_builder.go
vimystic Nov 20, 2024
e62a9a9
Adding spec.ordinal.start usage back to node_keybuilder.go
vimystic Nov 20, 2024
5905c9b
Adding spec.ordinal.start usage back to peer_collector.go
vimystic Nov 20, 2024
3b27cf1
Add spec.ordinal.start usage back to service_builder.go
vimystic Nov 20, 2024
65c1d33
service_builder.go
vimystic Nov 20, 2024
51747d4
Update pvc to use name from ordinals , but resource from 0
vimystic Nov 20, 2024
df5a242
revert previous commit
vimystic Nov 20, 2024
8be6661
Update pvc_contro.go to use ordinal start
vimystic Nov 20, 2024
dc23a15
name/label update
vimystic Nov 20, 2024
060d6cf
Attempting range check
vimystic Nov 20, 2024
4a11667
Revert previous
vimystic Nov 20, 2024
3c8739e
Update configmap , key peer and service builders to use correct ordin…
vimystic Nov 20, 2024
fcbcf8a
Merge branch 'main' into vimystic/feat/445-add-starting-ordinals
vimystic Nov 21, 2024
b124b07
Allow instanceoverrides for pvcs (example: changing storage) to wor…
vimystic Nov 27, 2024
ae29f8a
Use 'Ordinals' instead of 'Ordinals' as per review
vimystic Dec 3, 2024
212fd65
Update autogenerated yaml file with 'ordinals'
vimystic Dec 3, 2024
8a24b65
match the description for start with that of the stateful set
vimystic Dec 4, 2024
b1163e0
add happy path test with a non 0 starting ordinal
vimystic Dec 4, 2024
f27d4a3
add node keybuilder test
vimystic Dec 4, 2024
94afe93
test ofr peer collector
vimystic Dec 4, 2024
57019ed
pvc and service builder tests
vimystic Dec 4, 2024
e0afa9b
Ensure correct tags for goloang json
vimystic Dec 4, 2024
4595139
make for loops consistent across all builders
vimystic Dec 4, 2024
79e5c85
fix service builder loop. seperate index from ordinal name since both…
vimystic Dec 4, 2024
c8ba8ce
potential lint error fix (new lines between functions)
vimystic Dec 4, 2024
0bc73a8
remove unnecessary new line
vimystic Dec 4, 2024
ffdaafa
Merge branch 'main' into vimystic/feat/445-add-starting-ordinals
vimystic Dec 4, 2024
2749a79
Update the Ordinals description to match language similar to be simil…
vimystic Dec 5, 2024
1c27636
update with no starting ordinal defined. i.e: Default value 0
vimystic Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert previous
  • Loading branch information
vimystic committed Nov 20, 2024
commit 4a116672769acc50d26855724d76ef138b6d7b42
29 changes: 10 additions & 19 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
@@ -232,27 +232,21 @@ const (
// ordered sequence. Pods have deterministic, consistent names similar to a StatefulSet instead of generated names.
func (b PodBuilder) WithOrdinal(ordinal int32) PodBuilder {
pod := b.pod.DeepCopy()

// Validate ordinal is within valid range based on start ordinal
startOrdinal := b.crd.Spec.Ordinal.Start
if ordinal < startOrdinal || ordinal >= (startOrdinal+b.crd.Spec.Replicas) {
return b
}

name := instanceName(b.crd, ordinal)

pod.Labels[kube.InstanceLabel] = name

pod.Name = name
pod.Spec.InitContainers = initContainers(b.crd, name)

pod.Spec.Hostname = pod.Name
pod.Spec.Subdomain = b.crd.Name

pod.Spec.Volumes = []corev1.Volume{
{
Name: volChainHome,
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: pvcName(b.crd, ordinal),
},
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ClaimName: pvcName(b.crd, ordinal)},
},
},
{
@@ -265,9 +259,7 @@ func (b PodBuilder) WithOrdinal(ordinal int32) PodBuilder {
Name: volConfig,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: instanceName(b.crd, ordinal),
},
LocalObjectReference: corev1.LocalObjectReference{Name: instanceName(b.crd, ordinal)},
Items: []corev1.KeyToPath{
{Key: configOverlayFile, Path: configOverlayFile},
{Key: appOverlayFile, Path: appOverlayFile},
@@ -294,28 +286,27 @@ func (b PodBuilder) WithOrdinal(ordinal int32) PodBuilder {
},
}

// Mounts required by all containers.
mounts := []corev1.VolumeMount{
{Name: volChainHome, MountPath: ChainHomeDir(b.crd)},
{Name: volSystemTmp, MountPath: systemTmpDir},
}

// Additional mounts only needed for init containers.
for i := range pod.Spec.InitContainers {
pod.Spec.InitContainers[i].VolumeMounts = append(mounts, []corev1.VolumeMount{
{Name: volTmp, MountPath: tmpDir},
{Name: volConfig, MountPath: tmpConfigDir},
}...)
}

// At this point, guaranteed to have at least 2 containers.
pod.Spec.Containers[0].VolumeMounts = append(mounts, corev1.VolumeMount{
Name: volNodeKey,
MountPath: path.Join(ChainHomeDir(b.crd), "config", nodeKeyFile),
SubPath: nodeKeyFile,
Name: volNodeKey, MountPath: path.Join(ChainHomeDir(b.crd), "config", nodeKeyFile), SubPath: nodeKeyFile,
})

pod.Spec.Containers[1].VolumeMounts = []corev1.VolumeMount{
// The healthcheck sidecar needs access to the home directory so it can read disk usage.
{Name: volChainHome, MountPath: ChainHomeDir(b.crd), ReadOnly: true},
}

if len(pod.Spec.Containers) > 2 {
pod.Spec.Containers[2].VolumeMounts = mounts
}
Loading