Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix apparmor policy configuration in Daemonset and minor bug fixes #703

Merged
merged 1 commit into from Jan 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions apparmor.profile
Expand Up @@ -15,7 +15,6 @@ profile directpv flags=(attach_disconnected,mediate_deleted) {

deny /bin/** wl,
deny /boot/** wl,
deny /dev/** wl,
deny /etc/** wl,
deny /home/** wl,
deny /lib/** wl,
Expand All @@ -27,9 +26,7 @@ profile directpv flags=(attach_disconnected,mediate_deleted) {
deny /root/** wl,
deny /sbin/** wl,
deny /srv/** wl,
deny /tmp/** wl,
deny /sys/** wl,
deny /dev/** wl,
deny /run/udev/data/** wl,
# deny /usr/** wl,

Expand Down
4 changes: 2 additions & 2 deletions cmd/kubectl-directpv/discover.go
Expand Up @@ -245,7 +245,7 @@ func discoverDevices(ctx context.Context, nodes []types.Node) (devices map[direc
return
}
switch event.Type {
case watch.Modified:
case watch.Modified, watch.Added:
node := event.Node
if !node.Spec.Refresh {
devices[directpvtypes.NodeID(node.Name)] = node.GetDevicesByNames(drivesArgs)
Expand All @@ -258,7 +258,7 @@ func discoverDevices(ctx context.Context, nodes []types.Node) (devices map[direc
default:
}
case <-ctx.Done():
err = fmt.Errorf("unable to discover devices; %v", ctx.Err())
utils.Eprintf(quietFlag, true, "unable to complete the discovery; %v\n", ctx.Err())
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-directpv/init.go
Expand Up @@ -196,7 +196,7 @@ func initDevices(ctx context.Context, initRequests []types.InitRequest, requestI
return
}
switch event.Type {
case watch.Modified:
case watch.Modified, watch.Added:
initReq := event.InitRequest
if initReq.Status.Status != directpvtypes.InitStatusPending {
results = append(results, initResult{
Expand Down
2 changes: 1 addition & 1 deletion pkg/device/sysfs_linux.go
Expand Up @@ -100,7 +100,7 @@ func getPartitions(name string) ([]string, error) {
}

func getHolders(name string) ([]string, error) {
return readdirnames("/sys/block/"+name+"/holders", false)
return readdirnames("/sys/class/block/"+name+"/holders", false)
}

func getDMName(name string) (string, error) {
Expand Down
5 changes: 4 additions & 1 deletion pkg/installer/daemonset.go
Expand Up @@ -202,7 +202,10 @@ func livenessProbeContainer(image string) corev1.Container {
func newDaemonset(podSpec corev1.PodSpec, name, appArmorProfile string) *appsv1.DaemonSet {
annotations := map[string]string{createdByLabel: pluginName}
if appArmorProfile != "" {
annotations["container.apparmor.security.beta.kubernetes.io/"+consts.AppName] = appArmorProfile
// AppArmor profiles need to be specified per-container
for _, container := range podSpec.Containers {
annotations["container.apparmor.security.beta.kubernetes.io/"+container.Name] = "localhost/" + appArmorProfile
}
}
selectorValue := fmt.Sprintf("%v-%v", consts.Identity, getRandSuffix())

Expand Down