Talk from Software Circus, on how bugs in even small tools can require investigations which span projects, libraries, protocols and specifications.
Gareth RushgroveA dark story of bug huntingand the importance ofspecification
View Slide
@garethr
- Act 1: Discovery- Act 2: Investigation- Act 3: Resolution
Setting the sceneThe background to our tale
apiVersion: v1kind: Servicemetadata:name: redis-masterlabels:app: redisrole: mastertier: backendspec:ports:- port: 6379targetPort: 6379selector:app: redisrole: mastertier: backendIs this a valid Kubernetes configuration file?
Is this Puppet code valid for Kubernetes?$ cat example.ppkubernetes_pod { 'sample-pod':ensure => present,metadata => {namespace => 'default',},spec => {containers => [{name => 'container-name',image => 'nginx',}]},}$ puppet kubernetes compile --manifest example.pp
Is this Helm template valid for Kubernetes?apiVersion: v1kind: Servicemetadata:name: {{ template "fullname" . }}labels:app: {{ template "fullname" . }}chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"release: "{{ .Release.Name }}"heritage: "{{ .Release.Service }}"spec:ports:- name: memcacheport: 11211targetPort: memcacheselector:app: {{ template "fullname" . }}
Kubeval - validate Kubernetes configs with JSON schema
Like all software, kubevalhas bugs. This is the storyof one of them
Act 1In which our bug is discovered
Initial bug report
The bug in action$ tail -n 6 valid-config.yamlspec:ports:- port: 80targetPort: 8082selector:k8s-app: heapster$ kubeval valid-config.yamlThe document valid-config.yaml is not a valid Service--> spec.ports.0.targetPort: Invalid type. Expected: string, given: integer
Act 2In which our bug is hunted down
Look at the source code
Look at tools used to extract the schema
Look at the Kubernetes OpenAPI description
Look at the JSON Schema for targetPort{"type": "string","format": "int-or-string"}
Narrow down the search to the OpenAPI spec
The format property is an openstring-valued property, and canhave any value to supportdocumentation needs.
The bug here is thatKubernetes relies on formatfor parsing instructions
The reality of software rabbit holes
Act 3In which our bug meets its fate
First attempt at fixing, a terribleidea to add complex stringparsing to kubeval
Second attempt, fix the schema{"type": "object","$schema": "http://json-schema.org/schema#","oneOf": [{"type": "string"},{"type": "integer"}]}
The end?
To-be-continued: fix upstream
Which relies on another upstream project...
SummaryIf all you remember is...
Software bugs often involveinteractions between multipleprojects, protocols and standards
Different layers of software,and associated standards,move at different speeds
Specification is powerful andimportant because it typicallymoves slowly
Bugs can be fixed in differentplaces, often with differentupfront and maintenance costs.Choose wisely
Thanks for listeningHappy to answer questions later