|
1 | 1 | package node
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "errors" |
5 | 4 | "fmt"
|
6 | 5 | "os"
|
7 | 6 | "path/filepath"
|
8 | 7 |
|
9 | 8 | "github.com/golang/glog"
|
10 | 9 |
|
11 |
| - kapiv1 "k8s.io/api/core/v1" |
12 |
| - "k8s.io/kubernetes/cmd/kubelet/app" |
13 |
| - "k8s.io/kubernetes/pkg/volume" |
14 |
| - |
15 |
| - configapi "github.com/openshift/origin/pkg/cmd/server/apis/config" |
16 | 10 | cmdutil "github.com/openshift/origin/pkg/cmd/util"
|
17 |
| - "github.com/openshift/origin/pkg/volume/emptydir" |
18 | 11 | )
|
19 | 12 |
|
20 | 13 | // TODO this is a best effort check at the moment that should either move to kubelet or be removed entirely
|
@@ -83,60 +76,3 @@ func initializeVolumeDir(rootDirectory string) error {
|
83 | 76 | }
|
84 | 77 | return nil
|
85 | 78 | }
|
86 |
| - |
87 |
| -// TODO this needs to move into the forked kubelet with a `--openshift-config` flag |
88 |
| -// PatchUpstreamVolumePluginsForLocalQuota checks if the node config specifies a local storage |
89 |
| -// perFSGroup quota, and if so will test that the volumeDirectory is on a |
90 |
| -// filesystem suitable for quota enforcement. If checks pass the k8s emptyDir |
91 |
| -// volume plugin will be replaced with a wrapper version which adds quota |
92 |
| -// functionality. |
93 |
| -func PatchUpstreamVolumePluginsForLocalQuota(nodeConfig configapi.NodeConfig) func() []volume.VolumePlugin { |
94 |
| - // This looks a little weird written this way but it allows straight lifting from here to kube at a future time |
95 |
| - // and will allow us to wrap the exec. |
96 |
| - |
97 |
| - existingProbeVolumePlugins := app.ProbeVolumePlugins |
98 |
| - return func() []volume.VolumePlugin { |
99 |
| - if nodeConfig.VolumeConfig.LocalQuota.PerFSGroup == nil { |
100 |
| - return existingProbeVolumePlugins() |
101 |
| - } |
102 |
| - |
103 |
| - glog.V(4).Info("Replacing empty-dir volume plugin with quota wrapper") |
104 |
| - wrappedEmptyDirPlugin := false |
105 |
| - |
106 |
| - quotaApplicator, err := emptydir.NewQuotaApplicator(nodeConfig.VolumeDirectory) |
107 |
| - if err != nil { |
108 |
| - glog.Fatalf("Could not set up local quota, %s", err) |
109 |
| - } |
110 |
| - |
111 |
| - // Create a volume spec with emptyDir we can use to search for the |
112 |
| - // emptyDir plugin with CanSupport: |
113 |
| - emptyDirSpec := &volume.Spec{ |
114 |
| - Volume: &kapiv1.Volume{ |
115 |
| - VolumeSource: kapiv1.VolumeSource{ |
116 |
| - EmptyDir: &kapiv1.EmptyDirVolumeSource{}, |
117 |
| - }, |
118 |
| - }, |
119 |
| - } |
120 |
| - |
121 |
| - ret := existingProbeVolumePlugins() |
122 |
| - for idx, plugin := range ret { |
123 |
| - // Can't really do type checking or use a constant here as they are not exported: |
124 |
| - if plugin.CanSupport(emptyDirSpec) { |
125 |
| - wrapper := emptydir.EmptyDirQuotaPlugin{ |
126 |
| - VolumePlugin: plugin, |
127 |
| - Quota: *nodeConfig.VolumeConfig.LocalQuota.PerFSGroup, |
128 |
| - QuotaApplicator: quotaApplicator, |
129 |
| - } |
130 |
| - ret[idx] = &wrapper |
131 |
| - wrappedEmptyDirPlugin = true |
132 |
| - } |
133 |
| - } |
134 |
| - // Because we can't look for the k8s emptyDir plugin by any means that would |
135 |
| - // survive a refactor, error out if we couldn't find it: |
136 |
| - if !wrappedEmptyDirPlugin { |
137 |
| - glog.Fatal(errors.New("No plugin handling EmptyDir was found, unable to apply local quotas")) |
138 |
| - } |
139 |
| - |
140 |
| - return ret |
141 |
| - } |
142 |
| -} |
0 commit comments