quota

package
v0.0.0-...-d57b899 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQuotaNotSupported = errQuotaNotSupported{}

ErrQuotaNotSupported indicates if were found the FS didn't have projects quotas available

Functions

func CanTestQuota

func CanTestQuota() (string, bool)

CanTestQuota - checks if xfs prjquota can be tested returns a reason if not

func PrepareQuotaTestImage

func PrepareQuotaTestImage(t *testing.T) (string, error)

PrepareQuotaTestImage - prepares an xfs prjquota test image returns the path of the image on success

func WrapMountTest

func WrapMountTest(imageFileName string, enableQuota bool, testFunc func(t *testing.T, mountPoint, backingFsDev, testDir string)) func(*testing.T)

WrapMountTest - wraps a test function such that it has easy access to a mountPoint and testDir with guaranteed prjquota or guaranteed no prjquota support.

func WrapQuotaTest

func WrapQuotaTest(testFunc func(t *testing.T, ctrl *Control, mountPoint, testDir, testSubDir string)) func(t *testing.T, mountPoint, backingFsDev, testDir string)

WrapQuotaTest - wraps a test function such that is has easy and guaranteed access to a quota Control instance with a quota test dir under its control.

Types

type Control

type Control struct {
	sync.RWMutex // protect nextProjectID and quotas map
	// contains filtered or unexported fields
}

Control - Context to be used by storage driver (e.g. overlay) who wants to apply project quotas to container dirs

func NewControl

func NewControl(basePath string) (*Control, error)

NewControl - initialize project quota support. Test to make sure that quota can be set on a test dir and find the first project id to be used for the next container create.

Returns nil (and error) if project quota is not supported.

First get the project id of the home directory. This test will fail if the backing fs is not xfs.

xfs_quota tool can be used to assign a project id to the driver home directory, e.g.:

echo 999:/var/lib/docker/overlay2 >> /etc/projects
echo docker:999 >> /etc/projid
xfs_quota -x -c 'project -s docker' /<xfs mount point>

In that case, the home directory project id will be used as a "start offset" and all containers will be assigned larger project ids (e.g. >= 1000). This is a way to prevent xfs_quota management from conflicting with docker.

Then try to create a test directory with the next project id and set a quota on it. If that works, continue to scan existing containers to map allocated project ids.

func (*Control) GetQuota

func (q *Control) GetQuota(targetPath string, quota *Quota) error

GetQuota - get the quota limits of a directory that was configured with SetQuota

func (*Control) SetQuota

func (q *Control) SetQuota(targetPath string, quota Quota) error

SetQuota - assign a unique project id to directory and set the quota limits for that project id

type Quota

type Quota struct {
	Size uint64
}

Quota limit params - currently we only control blocks hard limit

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL