Skip to content

Commit

Permalink
update entrypoint and curve generation (still not working but testing)
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Oct 10, 2023
1 parent 27799d1 commit fdb06a7
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Check Spelling
uses: crate-ci/typos@7ad296c72fa8265059cc03d1eda562fbdfcd6df2 # v1.9.0
with:
files: ./docs/*/*.md ./docs/*/*/*.md ./docs/*.md ./README.md ./config/samples ./docs/*.md
files: ./docs/*/*.md ./docs/*/*/*.md ./docs/*.md ./README.md ./docs/*.md

unit-tests:
name: Unit Tests
Expand Down
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: list
list:
kubectl get -n flux-operator pods
kubectl get pods

.PHONY: reset
reset:
Expand All @@ -162,11 +162,11 @@ clean:
# kubectl delete -n flux-operator secret --all --grace-period=0 --force
kubectl delete -n flux-operator cm --all --grace-period=0 --force
# pods, pvc, and pv need to be deleted in this order
kubectl delete -n flux-operator pods --all --grace-period=0 --force
kubectl delete pods --all --grace-period=0 --force
kubectl delete -n flux-operator pvc --all --grace-period=0 --force
kubectl delete -n flux-operator pv --all --grace-period=0 --force
kubectl delete -n flux-operator jobs --all --grace-period=0 --force
kubectl delete -n flux-operator MiniCluster --all --grace-period=0 --force
kubectl delete jobs --all --grace-period=0 --force
kubectl delete MiniCluster --all --grace-period=0 --force

# This applies the basic minicluster (and not extended examples)
apply:
Expand All @@ -186,9 +186,6 @@ redo: clean apply run
redo_example: clean example run
redo_test: clean applytest run

log:
kubectl logs -n flux-operator job.batch/flux-sample $@

##@ Test
# NOTE these are not fully developed yet

Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha2/minicluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ func (f *MiniCluster) Validate() bool {
if f.Spec.Flux.Container.Image == "" {
f.Spec.Flux.Container.Image = "ghcr.io/converged-computing/flux-view-rocky:tag-9"
}
if f.Spec.Flux.Scheduler.QueuePolicy == "" {
f.Spec.Flux.Scheduler.QueuePolicy = "fcfs"
}

// Flux Restful default port
if f.Spec.FluxRestful.Port == 0 {
Expand Down
1 change: 1 addition & 0 deletions docs/getting_started/custom-resource-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ This means that (if desired) you can customize this container base. We provide t

- [ghcr.io/converged-computing/flux-view-rocky:tag-9](https://github.com/converged-computing/flux-views/pkgs/container/flux-view-rocky)
- [ghcr.io/converged-computing/flux-view-rocky:tag-8](https://github.com/converged-computing/flux-views/pkgs/container/flux-view-rocky)
- [ghcr.io/converged-computing/flux-view-ubuntu:tag-focal](https://github.com/converged-computing/flux-views/pkgs/container/flux-view-ubuntu)

More will be coming soon.

Expand Down
6 changes: 1 addition & 5 deletions examples/tests/hello-world/minicluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ spec:

# Number of pods to create for MiniCluster
size: 4
logging:
debug: true
flux:
logLevel: 7


# This is a list because a pod can support multiple containers
containers:
- image: rockylinux:9
Expand Down
13 changes: 5 additions & 8 deletions pkg/flux/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func GenerateEntrypoints(cluster *api.MiniCluster) (map[string]string, error) {
}
}
// Main flux entrypoint for flux-view generation
data[cluster.Spec.Flux.Container.Name] = GenerateFluxEntrypoint(cluster)
script, err := GenerateFluxEntrypoint(cluster)
if err != nil {
return data, err
}
data[cluster.Spec.Flux.Container.Name] = script
return data, nil
}

Expand Down Expand Up @@ -80,12 +84,6 @@ func generateEntrypointScript(
container := cluster.Spec.Containers[containerIndex]
mainHost := fmt.Sprintf("%s-0", cluster.Name)

// Generate the curve certificate
curveCert, err := GetCurveCert(cluster)
if err != nil {
return "", err
}

// Ensure Flux Restful has a secret key
cluster.Spec.FluxRestful.SecretKey = getRandomToken(cluster.Spec.FluxRestful.SecretKey)

Expand All @@ -99,7 +97,6 @@ func generateEntrypointScript(
wt := WaitTemplate{
RequiredRanks: requiredRanks,
ViewBase: cluster.Spec.Flux.Container.MountPath,
CurveCert: curveCert,
Container: container,
MainHost: mainHost,
Spec: cluster.Spec,
Expand Down
1 change: 0 additions & 1 deletion pkg/flux/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type ServiceTemplate struct {
type WaitTemplate struct {
ViewBase string // Where the mounted view with flux is expected to be
MainHost string // Main host identifier
CurveCert string // curve certificate string
FluxToken string // Token to log into the UI, should be consistent across containers
Container api.MiniClusterContainer
Spec api.MiniClusterSpec
Expand Down
25 changes: 11 additions & 14 deletions pkg/flux/templates/wait.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ echo "Hello user ${fluxuser}"{{ end }}
# Add fluxuser to sudoers living... dangerously!
if [[ "${fluxuser}" != "root" ]]; then
echo "${fluxuser} ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
sudo chown -R ${fluxuid} ${viewroot}/etc/curve
fi

# Write the curve certificate
cat <<EOT >> ${viewroot}/etc/curve/curve.cert
{{ .CurveCert }}
EOT

# Ensure the flux user owns the curve.cert
curvepath=${viewroot}/etc/curve/curve.cert
{{ if not .Spec.Logging.Quiet }}
echo
echo "🌟️ Curve Certificate"
ls ${viewroot}/etc/curve/
cat ${curvepath}
{{ end }}

# Remove group and other read
chmod o-r ${viewroot}/etc/curve/curve.cert
chmod g-r ${viewroot}/etc/curve/curve.cert
chown -R ${fluxuid} ${viewroot}/etc/curve/curve.cert
# chmod o-r ${curvepath}
# chmod g-r ${curvepath}
chown -R ${fluxuid} ${curvepath}

foundroot=$(find $viewroot -maxdepth 2 -type d -path $viewroot/lib/python3\*)

Expand Down Expand Up @@ -159,9 +159,6 @@ if [[ -e "{{ .Spec.Archive.Path}}" ]]; then
brokerOptions="${brokerOptions} -Scontent.restore={{ .Spec.Archive.Path}}"
fi{{ end }}

# We will copy the curve certificate if the lead, otherwise wait for it
curvepath=${viewroot}/etc/curve/curve.cert

# And pre command logic that isn't passed to the certificate generator
{{ .Container.Commands.Pre}} {{ if .Spec.Logging.Quiet }}> /dev/null 2>&1{{ end }}

Expand Down
30 changes: 22 additions & 8 deletions pkg/flux/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,28 @@ queue-policy = "%s"

// generateFluxEntrypoint generates the flux entrypoint to prepare flux
// This is run inside of the flux container that will be copied to the empty volume
func GenerateFluxEntrypoint(cluster *api.MiniCluster) string {
func GenerateFluxEntrypoint(cluster *api.MiniCluster) (string, error) {

// fluxRoot for the view is in /opt/view/lib
// This must be consistent between the flux-view containers
// github.com:converged-computing/flux-views.git
fluxRoot := "/opt/view"

mainHost := fmt.Sprintf("%s-0", cluster.Name)

// Generate the curve certificate
curveCert, err := GetCurveCert(cluster)
if err != nil {
return "", err
}

// Generate hostlists, this is the lead broker
hosts := generateHostlist(cluster, cluster.Spec.MaxSize)
brokerConfig := generateBrokerConfig(cluster, hosts)

setup := `#!/bin/sh
fluxroot=%s
# The mount for the view will be at the user defined mount / view
mount="%s/view"
mainHost=%s
echo "Hello I am hostname $(hostname) running setup."
# Always use verbose, no reason to not here
Expand Down Expand Up @@ -149,7 +154,15 @@ cat ${fluxroot}/etc/flux/config/broker.toml
mkdir -p ${fluxroot}/run/flux ${fluxroot}/etc/curve
# Generate the certificate (ONLY if the lead broker)
mkdir -p ${fluxroot}/etc/curve
if [[ "$(hostname)" == "${mainHost}" ]]; then
echo "Generating curve certificate at main host..."
cat <<EOT >> ${fluxroot}/etc/curve/curve.cert
%s
EOT
echo
echo "🌟️ Curve Certificate"
cat ${fluxroot}/etc/curve/curve.cert
fi
# Now prepare to copy finished spack view over
echo "Moving content from /opt/view to be in shared volume at %s"
Expand All @@ -176,11 +189,12 @@ sleep infinity
return fmt.Sprintf(
setup,
fluxRoot,
cluster.Spec.Flux.Container.MountPath,
mainHost,
hosts,
brokerConfig,
curveCert,
cluster.Spec.Flux.Container.MountPath,
cluster.Spec.Flux.Container.MountPath,
cluster.Spec.Flux.Container.Name,
)
), nil
}

0 comments on commit fdb06a7

Please sign in to comment.