Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
envs.sh
bin
vendor/

# Eclipse IDE
.project
.settings
Expand Down
42 changes: 42 additions & 0 deletions examples/startup-probe-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: v1
kind: Pod
metadata:
name: startup-probe-test-pod
namespace: vk
spec:
containers:
- name: app-container
image: nginx:alpine
ports:
- containerPort: 80
startupProbe:
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 300
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
livenessProbe:
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
restartPolicy: Always
8 changes: 5 additions & 3 deletions pkg/slurm/Create.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,15 @@ func (h *SidecarHandler) SubmitHandler(w http.ResponseWriter, r *http.Request) {
)

// Process probes if enabled
var readinessProbes, livenessProbes []ProbeCommand
var readinessProbes, livenessProbes, startupProbes []ProbeCommand
if h.Config.EnableProbes && !isInit {
readinessProbes, livenessProbes = translateKubernetesProbes(spanCtx, container)
if len(readinessProbes) > 0 || len(livenessProbes) > 0 {
readinessProbes, livenessProbes, startupProbes = translateKubernetesProbes(spanCtx, container)
if len(readinessProbes) > 0 || len(livenessProbes) > 0 || len(startupProbes) > 0 {
log.G(h.Ctx).Info("-- Container " + container.Name + " has probes configured")
span.SetAttributes(
attribute.Int("job.container"+strconv.Itoa(i)+".readiness_probes", len(readinessProbes)),
attribute.Int("job.container"+strconv.Itoa(i)+".liveness_probes", len(livenessProbes)),
attribute.Int("job.container"+strconv.Itoa(i)+".startup_probes", len(startupProbes)),
)
}
}
Expand All @@ -168,6 +169,7 @@ func (h *SidecarHandler) SubmitHandler(w http.ResponseWriter, r *http.Request) {
isInitContainer: isInit,
readinessProbes: readinessProbes,
livenessProbes: livenessProbes,
startupProbes: startupProbes,
containerImage: image,
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/slurm/Status.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (h *SidecarHandler) StatusHandler(w http.ResponseWriter, r *http.Request) {
}
for _, ct := range pod.Spec.Containers {
// Check probe status for container readiness
readinessCount, _, err := loadProbeMetadata(path, ct.Name)
readinessCount, _, _, err := loadProbeMetadata(path, ct.Name)
isReady := true
if err != nil {
log.G(h.Ctx).Debug("Failed to load probe metadata for container ", ct.Name, ": ", err)
Expand Down Expand Up @@ -287,7 +287,7 @@ func (h *SidecarHandler) StatusHandler(w http.ResponseWriter, r *http.Request) {
}
for _, ct := range pod.Spec.Containers {
// Check probe status for container readiness
readinessCount, _, err := loadProbeMetadata(path, ct.Name)
readinessCount, _, _, err := loadProbeMetadata(path, ct.Name)
isReady := true
if err != nil {
log.G(h.Ctx).Debug("Failed to load probe metadata for container ", ct.Name, ": ", err)
Expand Down
6 changes: 6 additions & 0 deletions pkg/slurm/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func NewSlurmConfig() (SlurmConfig, error) {

SlurmConfigInst.Tsockspath = path
}

// Set default ContainerRuntime if not configured
if SlurmConfigInst.ContainerRuntime == "" {
SlurmConfigInst.ContainerRuntime = "singularity"
}

// Check if a supported container runtime is configured (supported: singularity, enroot)
if SlurmConfigInst.ContainerRuntime != "singularity" && SlurmConfigInst.ContainerRuntime != "enroot" {
err := fmt.Errorf("container runtime %q is not supported. Please configure a supported one (singularity, enroot)", SlurmConfigInst.ContainerRuntime)
Expand Down
14 changes: 7 additions & 7 deletions pkg/slurm/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,15 @@ highestExitCode=0
// Generate probe cleanup script first if any probes exist
var hasProbes bool
for _, containerCommand := range commands {
if len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0 {
if len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0 || len(containerCommand.startupProbes) > 0 {
hasProbes = true
break
}
}
if hasProbes && config.EnableProbes {
for _, containerCommand := range commands {
if len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0 {
cleanupScript := generateProbeCleanupScript(containerCommand.containerName, containerCommand.readinessProbes, containerCommand.livenessProbes)
if len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0 || len(containerCommand.startupProbes) > 0 {
cleanupScript := generateProbeCleanupScript(containerCommand.containerName, containerCommand.readinessProbes, containerCommand.livenessProbes, containerCommand.startupProbes)
stringToBeWritten.WriteString(cleanupScript)
break // Only need one cleanup script
}
Expand Down Expand Up @@ -898,7 +898,7 @@ highestExitCode=0
}

// Generate probe scripts if enabled and not an init container
if config.EnableProbes && !containerCommand.isInitContainer && (len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0) {
if config.EnableProbes && !containerCommand.isInitContainer && (len(containerCommand.readinessProbes) > 0 || len(containerCommand.livenessProbes) > 0 || len(containerCommand.startupProbes) > 0) {
// Extract the image name from the singularity command
var imageName string
for i, arg := range containerCommand.runtimeCommand {
Expand All @@ -922,12 +922,12 @@ highestExitCode=0

if imageName != "" {
// Store probe metadata for status checking
err := storeProbeMetadata(path, containerCommand.containerName, len(containerCommand.readinessProbes), len(containerCommand.livenessProbes))
err := storeProbeMetadata(path, containerCommand.containerName, len(containerCommand.readinessProbes), len(containerCommand.livenessProbes), len(containerCommand.startupProbes))
if err != nil {
log.G(Ctx).Error("Failed to store probe metadata: ", err)
}

probeScript := generateProbeScript(Ctx, config, containerCommand.containerName, imageName, containerCommand.readinessProbes, containerCommand.livenessProbes)
probeScript := generateProbeScript(Ctx, config, containerCommand.containerName, imageName, containerCommand.readinessProbes, containerCommand.livenessProbes, containerCommand.startupProbes)
stringToBeWritten.WriteString("\n")
stringToBeWritten.WriteString(probeScript)
}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ func prepareRuntimeCommand(config SlurmConfig, container v1.Container, metadata
singularityOptions = singOpts
}

// See https://github.com/interTwin-eu/interlink-slurm-plugin/issues/32#issuecomment-2416031030
// See https://github.com/interlink-hq/interlink-slurm-plugin/issues/32#issuecomment-2416031030
// singularity run will honor the entrypoint/command (if exist) in container image, while exec will override entrypoint.
// Thus if pod command (equivalent to container entrypoint) exist, we do exec, and other case we do run
singularityCommand := ""
Expand Down
Loading
Loading