Enabling Liveness and Readiness Probes in ACI Provider (#280)
* Enabling Liveness and Readiness Probes in ACI Provider * Adding a check to ensure both exec and httpGet are not provided
This commit is contained in:
committed by
Robbie Zhang
parent
13fbd5c38e
commit
a4d8f74c7d
@@ -722,11 +722,67 @@ func (p *ACIProvider) getContainers(pod *v1.Pod) ([]aci.Container, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if container.LivenessProbe != nil {
|
||||
probe, err := getProbe(container.LivenessProbe)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.LivenessProbe = probe
|
||||
}
|
||||
|
||||
if container.ReadinessProbe != nil {
|
||||
probe, err := getProbe(container.ReadinessProbe)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.ReadinessProbe = probe
|
||||
}
|
||||
|
||||
containers = append(containers, c)
|
||||
}
|
||||
return containers, nil
|
||||
}
|
||||
|
||||
func getProbe(probe *v1.Probe) (*aci.ContainerProbe, error) {
|
||||
|
||||
if probe.Handler.Exec != nil && probe.Handler.HTTPGet != nil {
|
||||
return nil, fmt.Errorf("probe may not specify more than one of \"exec\" and \"httpGet\"")
|
||||
}
|
||||
|
||||
if probe.Handler.Exec == nil && probe.Handler.HTTPGet == nil {
|
||||
return nil, fmt.Errorf("probe must specify one of \"exec\" and \"httpGet\"")
|
||||
}
|
||||
|
||||
// Probes have can have a Exec or HTTP Get Handler.
|
||||
// Create those if they exist, then add to the
|
||||
// ContainerProbe struct
|
||||
var exec *aci.ContainerExecProbe
|
||||
if probe.Handler.Exec != nil {
|
||||
exec = &aci.ContainerExecProbe{
|
||||
Command: probe.Handler.Exec.Command,
|
||||
}
|
||||
}
|
||||
|
||||
var httpGET *aci.ContainerHTTPGetProbe
|
||||
if probe.Handler.HTTPGet != nil {
|
||||
httpGET = &aci.ContainerHTTPGetProbe{
|
||||
Port: probe.Handler.HTTPGet.Port.IntValue(),
|
||||
Path: probe.Handler.HTTPGet.Path,
|
||||
Scheme: string(probe.Handler.HTTPGet.Scheme),
|
||||
}
|
||||
}
|
||||
|
||||
return &aci.ContainerProbe{
|
||||
Exec: exec,
|
||||
HTTPGet: httpGET,
|
||||
InitialDelaySeconds: probe.InitialDelaySeconds,
|
||||
Period: probe.PeriodSeconds,
|
||||
FailureThreshold: probe.FailureThreshold,
|
||||
SuccessThreshold: probe.SuccessThreshold,
|
||||
TimeoutSeconds: probe.TimeoutSeconds,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *ACIProvider) getVolumes(pod *v1.Pod) ([]aci.Volume, error) {
|
||||
volumes := make([]aci.Volume, 0, len(pod.Spec.Volumes))
|
||||
for _, v := range pod.Spec.Volumes {
|
||||
|
||||
Reference in New Issue
Block a user