Skip to content

Commit

Permalink
remove XFS quota patch from origin
Browse files Browse the repository at this point in the history
  • Loading branch information
sjenning committed May 4, 2018
1 parent 7331c64 commit 0d76139
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 739 deletions.
64 changes: 0 additions & 64 deletions pkg/cmd/server/kubernetes/node/node.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package node

import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/golang/glog"

kapiv1 "k8s.io/api/core/v1"
"k8s.io/kubernetes/cmd/kubelet/app"
"k8s.io/kubernetes/pkg/volume"

configapi "github.com/openshift/origin/pkg/cmd/server/apis/config"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/volume/emptydir"
)

// TODO this is a best effort check at the moment that should either move to kubelet or be removed entirely
Expand Down Expand Up @@ -83,60 +76,3 @@ func initializeVolumeDir(rootDirectory string) error {
}
return nil
}

// TODO this needs to move into the forked kubelet with a `--openshift-config` flag
// PatchUpstreamVolumePluginsForLocalQuota checks if the node config specifies a local storage
// perFSGroup quota, and if so will test that the volumeDirectory is on a
// filesystem suitable for quota enforcement. If checks pass the k8s emptyDir
// volume plugin will be replaced with a wrapper version which adds quota
// functionality.
func PatchUpstreamVolumePluginsForLocalQuota(nodeConfig configapi.NodeConfig) func() []volume.VolumePlugin {
// This looks a little weird written this way but it allows straight lifting from here to kube at a future time
// and will allow us to wrap the exec.

existingProbeVolumePlugins := app.ProbeVolumePlugins
return func() []volume.VolumePlugin {
if nodeConfig.VolumeConfig.LocalQuota.PerFSGroup == nil {
return existingProbeVolumePlugins()
}

glog.V(4).Info("Replacing empty-dir volume plugin with quota wrapper")
wrappedEmptyDirPlugin := false

quotaApplicator, err := emptydir.NewQuotaApplicator(nodeConfig.VolumeDirectory)
if err != nil {
glog.Fatalf("Could not set up local quota, %s", err)
}

// Create a volume spec with emptyDir we can use to search for the
// emptyDir plugin with CanSupport:
emptyDirSpec := &volume.Spec{
Volume: &kapiv1.Volume{
VolumeSource: kapiv1.VolumeSource{
EmptyDir: &kapiv1.EmptyDirVolumeSource{},
},
},
}

ret := existingProbeVolumePlugins()
for idx, plugin := range ret {
// Can't really do type checking or use a constant here as they are not exported:
if plugin.CanSupport(emptyDirSpec) {
wrapper := emptydir.EmptyDirQuotaPlugin{
VolumePlugin: plugin,
Quota: *nodeConfig.VolumeConfig.LocalQuota.PerFSGroup,
QuotaApplicator: quotaApplicator,
}
ret[idx] = &wrapper
wrappedEmptyDirPlugin = true
}
}
// Because we can't look for the k8s emptyDir plugin by any means that would
// survive a refactor, error out if we couldn't find it:
if !wrappedEmptyDirPlugin {
glog.Fatal(errors.New("No plugin handling EmptyDir was found, unable to apply local quotas"))
}

return ret
}
}
2 changes: 0 additions & 2 deletions pkg/cmd/server/start/start_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentF
node.EnsureKubeletAccess()
// TODO perform this "ensure" in ansible and skip it entirely.
node.EnsureVolumeDir(nodeConfig.VolumeDirectory)
// TODO accept an --openshift-config in our fork. This overwrites the volume creation patch for the node.
kubeletapp.ProbeVolumePlugins = node.PatchUpstreamVolumePluginsForLocalQuota(nodeConfig)

go func() {
glog.Fatal(runKubeletInProcess(kubeletArgs))
Expand Down
92 changes: 0 additions & 92 deletions pkg/volume/emptydir/empty_dir_quota.go

This file was deleted.

Loading

0 comments on commit 0d76139

Please sign in to comment.