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
10 changes: 5 additions & 5 deletions assets/components/lvms/topolvm-controller_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
- command:
- /topolvm-controller
- --cert-dir=/certs
image: {{ .ReleaseImage.topolvm_csi }}
image: '{{ .ReleaseImage.topolvm_csi }}'
livenessProbe:
failureThreshold: 3
httpGet:
Expand Down Expand Up @@ -69,7 +69,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: {{ .ReleaseImage.topolvm_csi_provisioner }}
image: '{{ .ReleaseImage.topolvm_csi_provisioner }}'
name: csi-provisioner
resources:
requests:
Expand All @@ -80,7 +80,7 @@ spec:
name: socket-dir
- args:
- --csi-address=/run/topolvm/csi-topolvm.sock
image: {{ .ReleaseImage.topolvm_csi_resizer }}
image: '{{ .ReleaseImage.topolvm_csi_resizer }}'
name: csi-resizer
resources:
requests:
Expand All @@ -91,7 +91,7 @@ spec:
name: socket-dir
- args:
- --csi-address=/run/topolvm/csi-topolvm.sock
image: {{ .ReleaseImage.topolvm_csi_livenessprobe }}
image: '{{ .ReleaseImage.topolvm_csi_livenessprobe }}'
name: liveness-probe
resources:
requests:
Expand All @@ -106,7 +106,7 @@ spec:
- -c
- openssl req -nodes -x509 -newkey rsa:4096 -subj '/DC=self_signed_certificate'
-keyout /certs/tls.key -out /certs/tls.crt -days 3650
image: {{ .ReleaseImage.openssl }}
image: '{{ .ReleaseImage.openssl }}'
name: self-signed-cert-generator
resources: {}
volumeMounts:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ metadata:
name: topolvm-controller
namespace: openshift-storage
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- watch
- list
- delete
- update
- create
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- watch
- list
- delete
- update
- create
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ roleRef:
kind: Role
name: topolvm-controller
subjects:
- kind: ServiceAccount
name: topolvm-controller
namespace: openshift-storage
- kind: ServiceAccount
name: topolvm-controller
namespace: openshift-storage
5 changes: 2 additions & 3 deletions assets/components/lvms/topolvm-lvmd-config_configmap_v1.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Source: topolvm/templates/lvmd/configmap.yaml
apiVersion: v1
data:
lvmd.yaml: ""
kind: ConfigMap
metadata:
name: lvmd
namespace: openshift-storage
data:
lvmd.yaml: {{ .lvmd }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ allowHostPID: true
allowHostPorts: false
allowPrivilegeEscalation: true
allowPrivilegedContainer: true
allowedCapabilities:
allowedCapabilities: []
apiVersion: security.openshift.io/v1
defaultAddCapabilities:
defaultAddCapabilities: []
fsGroup:
type: RunAsAny
groups: []
kind: SecurityContextConstraints
metadata:
name: topolvm-node
priority:
priority: null
readOnlyRootFilesystem: false
requiredDropCapabilities: []
runAsUser:
Expand Down
36 changes: 18 additions & 18 deletions assets/components/lvms/topolvm-node_daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
template:
metadata:
annotations:
lvms.microshift.io/lvmd_config_sha256sum: "{{ Sha256sum .lvmd }}"
lvms.microshift.io/lvmd_config_sha256sum: '{{ Sha256sum .lvmd }}'
labels:
app.kubernetes.io/component: topolvm-node
app.kubernetes.io/managed-by: lvms-operator
Expand All @@ -30,16 +30,16 @@ spec:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "kubernetes.io/os"
operator: In
values:
- "linux"
- key: kubernetes.io/os
operator: In
values:
- linux
containers:
- command:
- /lvmd
- --config=/etc/topolvm/lvmd.yaml
- --container=true
image: {{ .ReleaseImage.topolvm_csi }}
image: '{{ .ReleaseImage.topolvm_csi }}'
name: lvmd
resources:
requests:
Expand All @@ -49,7 +49,7 @@ spec:
privileged: true
runAsUser: 0
volumeMounts:
- mountPath: {{ Dir .SocketName }}
- mountPath: '{{ Dir .SocketName }}'
name: lvmd-socket-dir
- mountPath: /etc/topolvm
name: lvmd-config-dir
Expand All @@ -61,7 +61,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: {{ .ReleaseImage.topolvm_csi }}
image: '{{ .ReleaseImage.topolvm_csi }}'
livenessProbe:
failureThreshold: 3
httpGet:
Expand All @@ -85,7 +85,7 @@ spec:
volumeMounts:
- mountPath: /run/topolvm
name: node-plugin-dir
- mountPath: {{ Dir .SocketName }}
- mountPath: '{{ Dir .SocketName }}'
name: lvmd-socket-dir
- mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
Expand All @@ -96,7 +96,7 @@ spec:
- args:
- --csi-address=/run/topolvm/csi-topolvm.sock
- --kubelet-registration-path=/var/lib/kubelet/plugins/topolvm.io/node/csi-topolvm.sock
image: {{ .ReleaseImage.topolvm_csi_registrar }}
image: '{{ .ReleaseImage.topolvm_csi_registrar }}'
lifecycle:
preStop:
exec:
Expand All @@ -116,7 +116,7 @@ spec:
name: registration-dir
- args:
- --csi-address=/run/topolvm/csi-topolvm.sock
image: {{ .ReleaseImage.topolvm_csi_livenessprobe }}
image: '{{ .ReleaseImage.topolvm_csi_livenessprobe }}'
name: liveness-probe
resources:
requests:
Expand All @@ -132,7 +132,7 @@ spec:
- -c
- until [ -f /etc/topolvm/lvmd.yaml ]; do echo waiting for lvmd config file;
sleep 5; done
image: {{ .ReleaseImage.openssl }}
image: '{{ .ReleaseImage.openssl }}'
name: file-checker
resources: {}
volumeMounts:
Expand All @@ -156,14 +156,14 @@ spec:
path: /var/lib/kubelet/pods/
type: DirectoryOrCreate
name: pod-volumes-dir
- name: lvmd-config-dir
configMap:
name: lvmd
- configMap:
items:
- key: lvmd.yaml
path: lvmd.yaml
- key: lvmd.yaml
path: lvmd.yaml
name: lvmd
name: lvmd-config-dir
- emptyDir:
medium: Memory
name: lvmd-socket-dir
updateStrategy:
type: RollingUpdate
type: RollingUpdate
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: Namespace
metadata:
name: openshift-storage
annotations:
openshift.io/node-selector: ""
workload.openshift.io/allowed: "management"
workload.openshift.io/allowed: management
labels:
openshift.io/run-level: "0"
pod-security.kubernetes.io/audit: privileged
pod-security.kubernetes.io/enforce: privileged
pod-security.kubernetes.io/warn: privileged
name: openshift-storage
4 changes: 2 additions & 2 deletions assets/components/openshift-dns/dns/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
requests:
cpu: 50m
memory: 70Mi
image: {{ .ReleaseImage.coredns }}
image: '{{ .ReleaseImage.coredns }}'
- name: kube-rbac-proxy
args:
- --logtostderr
Expand All @@ -70,7 +70,7 @@ spec:
- mountPath: /etc/tls/private
name: metrics-tls
readOnly: true
image: {{ .ReleaseImage.kube_rbac_proxy }}
image: '{{ .ReleaseImage.kube_rbac_proxy }}'
imagePullPolicy: IfNotPresent
dnsPolicy: Default
volumes:
Expand Down
2 changes: 1 addition & 1 deletion assets/components/openshift-dns/dns/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
port: 9154
targetPort: metrics
protocol: TCP
clusterIP: {{.ClusterIP}}
clusterIP: '{{.ClusterIP}}'
selector:
dns.operator.openshift.io/daemonset-dns: default
metadata:
Expand Down
2 changes: 1 addition & 1 deletion assets/components/openshift-router/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
- mountPath: /var/run/configmaps/service-ca
name: service-ca-bundle
readOnly: true
image: {{ .ReleaseImage.haproxy_router }}
image: '{{ .ReleaseImage.haproxy_router }}'
ports:
- name: http
containerPort: 80
Expand Down
6 changes: 3 additions & 3 deletions assets/components/service-ca/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
serviceAccountName: service-ca
containers:
- name: service-ca-controller
image: {{ .ReleaseImage.service_ca_operator }}
image: '{{ .ReleaseImage.service_ca_operator }}'
imagePullPolicy: IfNotPresent
command: ["service-ca-operator", "controller"]
ports:
Expand All @@ -46,10 +46,10 @@ spec:
volumes:
- name: signing-key
secret:
secretName: {{.TLSSecret}}
secretName: '{{.TLSSecret}}'
- name: signing-cabundle
configMap:
name: {{.CAConfigMap}}
name: '{{.CAConfigMap}}'
nodeSelector:
node-role.kubernetes.io/master: ""
priorityClassName: "system-cluster-critical"
Expand Down
2 changes: 1 addition & 1 deletion pkg/components/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func renderLvmdParams(l *lvmd.Lvmd) (assets.RenderParams, error) {
if err != nil {
return nil, err
}
r["lvmd"] = fmt.Sprintf(`%q`, b)
r["lvmd"] = string(b)
r["SocketName"] = l.SocketName
return r, nil
}
53 changes: 1 addition & 52 deletions pkg/components/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Test_renderLvmdParams(t *testing.T) {
wantErr: false,
want: assets.RenderParams{
"SocketName": "/run/lvmd/lvmd.socket",
"lvmd": `"device-classes:\n- default: true\n lvcreate-options: null\n name: test\n spare-gb: 5\n stripe: null\n stripe-size: \"\"\n thin-pool: null\n type: \"\"\n volume-group: vg\nsocket-name: /run/lvmd/lvmd.socket\n"`,
"lvmd": "device-classes:\n- default: true\n lvcreate-options: null\n name: test\n spare-gb: 5\n stripe: null\n stripe-size: \"\"\n thin-pool: null\n type: \"\"\n volume-group: vg\nsocket-name: /run/lvmd/lvmd.socket\n",
},
},
}
Expand All @@ -64,57 +64,6 @@ func Test_renderLvmdParams(t *testing.T) {
}
}

func Test_renderLvmdConfig(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to this test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because it was testing if the ConfigMap is properly templated ({{ .lvmd }}) but now it's substituted so this test didn't made much sense:

# pkg/components/storage.go
-	if err := assets.ApplyConfigMaps(cm, renderTemplate, lvmdRenderParams, kubeconfigPath); err != nil {
+	if err := assets.ApplyConfigMapWithData(cm, map[string]string{"lvmd.yaml": lvmdRenderParams["lvmd"].(string)}, kubeconfigPath); err != nil {

I think, if we'd want to test something, it would be assets.ApplyConfigMapWithData() (although I think it would need a refactor to split this logic from applying it to API)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, it makes sense to remove this. We can add other tests in separate PRs if we want them.


defL := (&lvmd.Lvmd{}).WithDefaults()

cmWrap := func(d []byte) []byte {
base :=
`# Source: topolvm/templates/lvmd/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: lvmd
namespace: openshift-storage
data:
lvmd.yaml:`
return []byte(fmt.Sprintf("%s %q\n", base, d))
}

type args struct {
tb []byte
data assets.RenderParams
}
tests := []struct {
name string
args args
want []byte
wantErr bool
}{
{
name: "should render topolvm configMap",
args: args{
tb: embedded.MustAsset("components/lvms/topolvm-lvmd-config_configmap_v1.yaml"),
data: func() assets.RenderParams { p, _ := renderLvmdParams(defL); return p }(),
},
want: cmWrap([]byte("device-classes:\n- default: true\n lvcreate-options: null\n name: default\n spare-gb: 0\n stripe: null\n stripe-size: \"\"\n thin-pool: null\n type: \"\"\n volume-group: rhel\nsocket-name: /run/lvmd/lvmd.socket\n")),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := renderTemplate(tt.args.tb, tt.args.data)
if (err != nil) != tt.wantErr {
t.Errorf("renderTemplate() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("renderTemplate() got = %s, want %s", string(got), string(tt.want))
}
})
}
}

func Test_renderTopolvmDaemonsetTemplate(t *testing.T) {
tb := embedded.MustAsset("components/lvms/topolvm-node_daemonset.yaml")

Expand Down
6 changes: 2 additions & 4 deletions pkg/components/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ func startCSIPlugin(cfg *config.MicroshiftConfig, kubeconfigPath string) error {
cd = []string{
"components/lvms/csi-driver.yaml",
}
cm = []string{
"components/lvms/topolvm-lvmd-config_configmap_v1.yaml",
}
cm = "components/lvms/topolvm-lvmd-config_configmap_v1.yaml"
ds = []string{
"components/lvms/topolvm-node_daemonset.yaml",
}
Expand Down Expand Up @@ -120,7 +118,7 @@ func startCSIPlugin(cfg *config.MicroshiftConfig, kubeconfigPath string) error {
klog.Warningf("Failed to apply clusterrolebinding %v: %v", crb, err)
return err
}
if err := assets.ApplyConfigMaps(cm, renderTemplate, lvmdRenderParams, kubeconfigPath); err != nil {
if err := assets.ApplyConfigMapWithData(cm, map[string]string{"lvmd.yaml": lvmdRenderParams["lvmd"].(string)}, kubeconfigPath); err != nil {
klog.Warningf("Failed to apply configMap %v: %v", crb, err)
return err
}
Expand Down
Loading