Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Update daemonset manifest to mount /etc/machine-id#3886

Merged
bboreham merged 1 commit into
weaveworks:masterfrom
avestuk:add-etc-machine-id-mount
Jan 22, 2021
Merged

Update daemonset manifest to mount /etc/machine-id#3886
bboreham merged 1 commit into
weaveworks:masterfrom
avestuk:add-etc-machine-id-mount

Conversation

@avestuk
Copy link
Copy Markdown
Contributor

@avestuk avestuk commented Jan 21, 2021

Mounted as ReadOnly in order to minimize attack surface as in #3880

This fixes an issue I had running weave in a Kind cluster where getOldStyleSystemUUID() did not return any uuid as those files were not present inside the weave container. Because /host/etc/machine-id did not exist an attempt to read /host/var/lib/dbus/machine-id would be made but the host machine did not have a /var/lib/dbus/machine-id file. This would result in both uuid and machineid being "" and causing the container to exit.

func getSystemUUID(hostRoot string) ([]byte, error) {
	uuid, err := getOldStyleSystemUUID()
	if err != nil && !os.IsNotExist(err) {
		return nil, err
	}
	machineid, err := ioutil.ReadFile(hostRoot + "/etc/machine-id")
	if os.IsNotExist(err) {
		machineid, err = ioutil.ReadFile(hostRoot + "/var/lib/dbus/machine-id")
	}
	if err != nil && !os.IsNotExist(err) {
		return nil, err
	}
	if len(uuid) == 0 && len(machineid) == 0 {
		return nil, errors.New("All system IDs are blank")
	}
	return append(machineid, uuid...), nil
}

My change attempts to maintain the spirit of #3880 by using a new hostPath volume to only mount /etc/machine-id from the host into the weave container.

Mounted as ReadOnly in order to minimize attack surface as in weaveworks#3880
@avestuk
Copy link
Copy Markdown
Contributor Author

avestuk commented Jan 21, 2021

Appears to have some overlap with #3877

@bboreham bboreham added this to the 2.8.1 milestone Jan 22, 2021
Copy link
Copy Markdown
Contributor

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

Excellent, many thanks.

@bboreham bboreham merged commit 263aecf into weaveworks:master Jan 22, 2021
@bboreham
Copy link
Copy Markdown
Contributor

Released in v2.8.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants