Skip to content

Commit 46050fd

Browse files
committed
test: discrepancies between owner spec and child statuses
metadataExtractor.buildImageMetadata accepts a workload's metadata and a list of container statuses, belonging to containers in a pod running said images. this function attempts to build image metadata based on the owner's spec (for example a deployment), which contains the data about "what should be", as well as the container statuses for that pod, which contain data about "what actually is". some discrepancies may occur between "what should be" and "what actually is". an example we've stumbled upon happens when sidecar containers are injected (through an admission controller), causing the deployment's spec to contain a single container, but the statuses to include the injected containers. this results in an error in buildImageMetadata that relies every container that appears in the statuses list to also appear in the spec. this test proves the bug exists.
1 parent be9b3b9 commit 46050fd

File tree

3 files changed

+441
-1
lines changed

3 files changed

+441
-1
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
annotations:
5+
deployment.kubernetes.io/revision: "1"
6+
flux.weave.works/antecedent: security-tools:helmrelease/hello-world
7+
creationTimestamp: "2019-11-25T13:23:51Z"
8+
generation: 2
9+
labels:
10+
app: hello-world
11+
name: hello-world
12+
namespace: security-tools
13+
resourceVersion: "55787967"
14+
selfLink: /apis/extensions/v1beta1/namespaces/security-tools/deployments/hello-world
15+
uid: d2006330-0f86-11ea-ae05-4201c0a88014
16+
spec:
17+
progressDeadlineSeconds: 2147483647
18+
replicas: 1
19+
revisionHistoryLimit: 3
20+
selector:
21+
matchLabels:
22+
app: hello-world
23+
strategy:
24+
rollingUpdate:
25+
maxSurge: 1
26+
maxUnavailable: 1
27+
type: RollingUpdate
28+
template:
29+
metadata:
30+
annotations:
31+
json_logs: "true"
32+
prometheus.io/scrape: "false"
33+
creationTimestamp: null
34+
labels:
35+
app: hello-world
36+
spec:
37+
containers:
38+
- image: eu.gcr.io/cookie/hello-world:1.20191125.132107-4664980
39+
imagePullPolicy: IfNotPresent
40+
livenessProbe:
41+
failureThreshold: 3
42+
httpGet:
43+
path: /hello
44+
port: 8080
45+
scheme: HTTP
46+
initialDelaySeconds: 5
47+
periodSeconds: 5
48+
successThreshold: 1
49+
timeoutSeconds: 5
50+
name: hello-world
51+
ports:
52+
- containerPort: 8080
53+
name: http
54+
protocol: TCP
55+
readinessProbe:
56+
failureThreshold: 3
57+
httpGet:
58+
path: /hello
59+
port: 8080
60+
scheme: HTTP
61+
initialDelaySeconds: 5
62+
periodSeconds: 5
63+
successThreshold: 1
64+
timeoutSeconds: 5
65+
resources:
66+
limits:
67+
cpu: "2"
68+
memory: 512Mi
69+
requests:
70+
cpu: "1"
71+
memory: 128Mi
72+
terminationMessagePath: /dev/termination-log
73+
terminationMessagePolicy: File
74+
dnsPolicy: ClusterFirst
75+
restartPolicy: Always
76+
schedulerName: default-scheduler
77+
securityContext:
78+
fsGroup: 40500
79+
runAsUser: 40500
80+
serviceAccount: hello-world
81+
serviceAccountName: hello-world
82+
terminationGracePeriodSeconds: 30
83+
status:
84+
availableReplicas: 1
85+
conditions:
86+
- lastTransitionTime: "2019-11-25T13:23:51Z"
87+
lastUpdateTime: "2019-11-25T13:23:51Z"
88+
message: Deployment has minimum availability.
89+
reason: MinimumReplicasAvailable
90+
status: "True"
91+
type: Available
92+
observedGeneration: 2
93+
readyReplicas: 1
94+
replicas: 1
95+
updatedReplicas: 1

0 commit comments

Comments
 (0)