Skip to content

Commit

Permalink
PPP-2913 Add Startup probe type (#89)
Browse files Browse the repository at this point in the history
* Add Startup probe type

* Add handler for startup probe

* Add test data for startup probe

* Add testdata case for startup probe

* Update test name; add case for startup probe

* Bump yaml.v2 version

* Try dropping version specifier

* Readd version string

* Update go mod

* Adjust makefile per warnings

* Update checksum

* Try tidying up

* Bump go version

* Use install instead

* Update tests
  • Loading branch information
mgruesen authored Oct 13, 2021
1 parent 0377810 commit 0e31253
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.12.5
- 1.13.1

install:
- make deps
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ test:
.PHONY: deps
deps:
GO111MODULE=on go mod vendor
go get github.com/mattn/goveralls
go get github.com/go-playground/overalls
go install github.com/mattn/goveralls
go install github.com/go-playground/overalls

.PHONY: coveralls
coveralls:
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/namely/k8s-pipeliner

go 1.12
go 1.13

require (
github.com/hashicorp/go-multierror v1.0.0
github.com/namely/k8s-configurator v0.0.4
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.4.0
github.com/urfave/cli v1.22.4
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 // indirect
gopkg.in/yaml.v2 v2.2.8
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.5
k8s.io/client-go v11.0.0+incompatible
Expand Down
14 changes: 9 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand All @@ -115,8 +118,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM=
k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI=
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
Expand Down
4 changes: 4 additions & 0 deletions pipeline/builder/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ func (mp *ManifestParser) parseContainer(container corev1.Container, scaffold co
if probe := container.ReadinessProbe; probe != nil {
spinContainer.ReadinessProbe = spinnakerProbeHandler(probe)
}

if probe := container.StartupProbe; probe != nil {
spinContainer.StartupProbe = spinnakerProbeHandler(probe)
}

// add all of the volume mounts
for _, vm := range container.VolumeMounts {
Expand Down
10 changes: 9 additions & 1 deletion pipeline/builder/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestContainersFromManifests(t *testing.T) {
assert.Equal(t, []string{"BAR"}, container.SecurityContext.Capabilities.Drop)
})

t.Run("LivenessProbe is copied in the correct format", func(t *testing.T) {
t.Run("Probes are copied in the correct format", func(t *testing.T) {
file := filepath.Join(wd, "testdata", "deployment.probes.yml")
parser := builder.NewManfifestParser(&config.Pipeline{})
group, err := parser.ContainersFromScaffold(scaffoldMock{
Expand All @@ -287,7 +287,11 @@ func TestContainersFromManifests(t *testing.T) {
container := group.Containers[0]

require.NotNil(t, container.LivenessProbe)
assert.Equal(t, []string{"say", "liveness"}, container.LivenessProbe.Handler.ExecAction.Commands)
require.NotNil(t, container.ReadinessProbe)
assert.Equal(t, []string{"say", "readiness"}, container.ReadinessProbe.Handler.ExecAction.Commands)
require.NotNil(t, container.StartupProbe)
assert.Equal(t, []string{"say", "startup"}, container.StartupProbe.Handler.ExecAction.Commands)
})

t.Run("InitContainers are copied in the correct format", func(t *testing.T) {
Expand Down Expand Up @@ -317,7 +321,11 @@ func TestContainersFromManifests(t *testing.T) {
assert.Equal(t, "init-container", initContainer.Name)

require.NotNil(t, initContainer.LivenessProbe)
assert.Equal(t, []string{"say", "liveness"}, initContainer.LivenessProbe.Handler.ExecAction.Commands)
require.NotNil(t, initContainer.ReadinessProbe)
assert.Equal(t, []string{"say", "readiness"}, initContainer.ReadinessProbe.Handler.ExecAction.Commands)
require.NotNil(t, initContainer.StartupProbe)
assert.Equal(t, []string{"say", "startup"}, initContainer.StartupProbe.Handler.ExecAction.Commands)

t.Run("InitContainer env are copied in", func(t *testing.T) {
require.Len(t, initContainer.EnvVars, 1)
Expand Down
7 changes: 5 additions & 2 deletions pipeline/builder/testdata/deployment.initContainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ spec:
image: init.container/latest
livenessProbe:
exec:
command: ["say", "hello"]
command: ["say", "liveness"]
readinessProbe:
exec:
command: ["say", "hello"]
command: ["say", "readiness"]
startupProbe:
exec:
command: ["say", "startup"]
volumeMounts:
- name: configmap-volume
mountPath: "/thisisthemount"
Expand Down
7 changes: 5 additions & 2 deletions pipeline/builder/testdata/deployment.probes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ spec:
- hello
livenessProbe:
exec:
command: ["say", "hello"]
command: ["say", "liveness"]
readinessProbe:
exec:
command: ["say", "hello"]
command: ["say", "readiness"]
startupProbe:
exec:
command: ["say", "startup"]
1 change: 1 addition & 0 deletions pipeline/builder/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ type Container struct {

LivenessProbe *Probe `json:"livenessProbe"`
ReadinessProbe *Probe `json:"readinessProbe"`
StartupProbe *Probe `json:"startupProbe"`

SecurityContext *SecurityContext `json:"securityContext"`
}
Expand Down

0 comments on commit 0e31253

Please sign in to comment.