quota.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package fsquota
  14. import (
  15. "k8s.io/utils/mount"
  16. "k8s.io/apimachinery/pkg/api/resource"
  17. "k8s.io/apimachinery/pkg/types"
  18. utilfeature "k8s.io/apiserver/pkg/util/feature"
  19. "k8s.io/kubernetes/pkg/features"
  20. )
  21. // Interface -- quota interface
  22. type Interface interface {
  23. // Does the path provided support quotas, and if so, what types
  24. SupportsQuotas(m mount.Interface, path string) (bool, error)
  25. // Assign a quota (picked by the quota mechanism) to a path,
  26. // and return it.
  27. AssignQuota(m mount.Interface, path string, poduid types.UID, bytes *resource.Quantity) error
  28. // Get the quota-based storage consumption for the path
  29. GetConsumption(path string) (*resource.Quantity, error)
  30. // Get the quota-based inode consumption for the path
  31. GetInodes(path string) (*resource.Quantity, error)
  32. // Remove the quota from a path
  33. // Implementations may assume that any data covered by the
  34. // quota has already been removed.
  35. ClearQuota(m mount.Interface, path string) error
  36. }
  37. func enabledQuotasForMonitoring() bool {
  38. return utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolationFSQuotaMonitoring)
  39. }