Skip to content

Commit

Permalink
fix(mount): fix parsing /proc/cmdline (#516)
Browse files Browse the repository at this point in the history
* fix parsing cmdline file when the device path is directly mentioned without identifier
* add test case for cmdline path without identifier

Signed-off-by: Akhil Mohan <[email protected]>
  • Loading branch information
akhilerm authored and kmova committed Dec 10, 2020
1 parent c852b64 commit 38350d8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions deploy/ndm-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ spec:
# to detect disk attach and detach events using fd.
hostNetwork: true
hostPID: true
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-manager
image: openebs/node-disk-manager:ci
Expand Down Expand Up @@ -226,7 +226,7 @@ spec:
labels:
name: node-disk-operator
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-operator
image: openebs/node-disk-operator:ci
Expand Down Expand Up @@ -281,7 +281,7 @@ spec:
labels:
name: ndm-cluster-exporter
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: ndm-cluster-exporter
image: openebs/node-disk-exporter:ci
Expand Down Expand Up @@ -322,7 +322,7 @@ spec:
labels:
name: ndm-node-exporter
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-exporter
image: openebs/node-disk-exporter:ci
Expand Down
2 changes: 1 addition & 1 deletion deploy/yamls/ndm-cluster-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
labels:
name: ndm-cluster-exporter
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: ndm-cluster-exporter
image: openebs/node-disk-exporter:ci
Expand Down
2 changes: 1 addition & 1 deletion deploy/yamls/ndm-node-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
labels:
name: ndm-node-exporter
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-exporter
image: openebs/node-disk-exporter:ci
Expand Down
2 changes: 1 addition & 1 deletion deploy/yamls/node-disk-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
# to detect disk attach and detach events using fd.
hostNetwork: true
hostPID: true
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-manager
image: openebs/node-disk-manager:ci
Expand Down
2 changes: 1 addition & 1 deletion deploy/yamls/node-disk-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
labels:
name: node-disk-operator
spec:
serviceAccountName: openebs-ndm-operator
serviceAccountName: openebs-maya-operator
containers:
- name: node-disk-operator
image: openebs/node-disk-operator:ci
Expand Down
8 changes: 8 additions & 0 deletions pkg/mount/mountutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ func parseRootDeviceLink(file io.Reader) (string, error) {

rootSpec := strings.Split(arg[len(rootPrefix):], "=")

// if the expected format is not present, then we skip getting the root partition
if len(rootSpec) < 2 {
if strings.HasPrefix(rootSpec[0], "/dev") {
return rootSpec[0], nil
}
return "", ErrCouldNotFindRootDevice
}

identifierType := strings.ToLower(rootSpec[0])
identifier := rootSpec[1]

Expand Down
5 changes: 5 additions & 0 deletions pkg/mount/mountutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ func TestParseRootDeviceLink(t *testing.T) {
"/dev/disk/by-partuuid/325c5bfa-08a8-433c-bc62-2dd5255213fd",
nil,
},
"single line with root on dm device, (simulates cmdline in GKE)": {
"BOOT_IMAGE=/syslinux/vmlinuz.A root=/dev/dm-0",
"/dev/dm-0",
nil,
},
}

for name, test := range tests {
Expand Down

0 comments on commit 38350d8

Please sign in to comment.