metadata

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogAccessOverview

func LogAccessOverview(access Access)

Types

type Access

type Access interface {
	Setup(ctx context.Context, path string) error

	InsertDynakube(ctx context.Context, dynakube *Dynakube) error
	UpdateDynakube(ctx context.Context, dynakube *Dynakube) error
	DeleteDynakube(ctx context.Context, dynakubeName string) error
	GetDynakube(ctx context.Context, dynakubeName string) (*Dynakube, error)
	GetTenantsToDynakubes(ctx context.Context) (map[string]string, error)
	GetAllDynakubes(ctx context.Context) ([]*Dynakube, error)

	InsertOsAgentVolume(ctx context.Context, volume *OsAgentVolume) error
	GetOsAgentVolumeViaVolumeID(ctx context.Context, volumeID string) (*OsAgentVolume, error)
	GetOsAgentVolumeViaTenantUUID(ctx context.Context, volumeID string) (*OsAgentVolume, error)
	UpdateOsAgentVolume(ctx context.Context, volume *OsAgentVolume) error
	GetAllOsAgentVolumes(ctx context.Context) ([]*OsAgentVolume, error)

	InsertVolume(ctx context.Context, volume *Volume) error
	DeleteVolume(ctx context.Context, volumeID string) error
	GetVolume(ctx context.Context, volumeID string) (*Volume, error)
	GetAllVolumes(ctx context.Context) ([]*Volume, error)
	GetPodNames(ctx context.Context) (map[string]string, error)
	GetUsedVersions(ctx context.Context, tenantUUID string) (map[string]bool, error)
	GetAllUsedVersions(ctx context.Context) (map[string]bool, error)
	GetLatestVersions(ctx context.Context) (map[string]bool, error)
	GetUsedImageDigests(ctx context.Context) (map[string]bool, error)
	IsImageDigestUsed(ctx context.Context, imageDigest string) (bool, error)
}

func NewAccess

func NewAccess(ctx context.Context, path string) (Access, error)

NewAccess creates a new SqliteAccess, connects to the database.

type AccessOverview

type AccessOverview struct {
	Volumes        []*Volume        `json:"volumes"`
	Dynakubes      []*Dynakube      `json:"dynakubes"`
	OsAgentVolumes []*OsAgentVolume `json:"osAgentVolumes"`
}

func NewAccessOverview

func NewAccessOverview(access Access) (*AccessOverview, error)

type AppMount added in v1.1.0

type AppMount struct {
	VolumeMeta VolumeMeta
	CodeModule CodeModule `gorm:"foreignKey:CodeModuleVersion"`
	TimeStampedModel
	VolumeMetaID      string `gorm:"primaryKey"`
	CodeModuleVersion string
	Location          string `gorm:"not null"`
	MountAttempts     int64  `gorm:"not null"`
}

AppMount keeps track of our mounts to user applications, where we provide the codemodules.

type CodeModule added in v1.1.0

type CodeModule struct {
	Version  string `gorm:"primaryKey"`
	Location string `gorm:"not null"`
	TimeStampedModel
}

CodeModule holds what codemodules we have downloaded and available.

type CorrectnessChecker

type CorrectnessChecker struct {
	// contains filtered or unexported fields
}

func NewCorrectnessChecker

func NewCorrectnessChecker(cl client.Reader, access Access, opts dtcsi.CSIOptions) *CorrectnessChecker

func (*CorrectnessChecker) CorrectCSI

func (checker *CorrectnessChecker) CorrectCSI(ctx context.Context) error

CorrectMetadata checks if the entries in the storage are actually valid Removes not valid entries "Moves" agent bins from deprecated location. (just creates a symlink)

type DBAccess added in v1.1.0

type DBAccess interface {
	SchemaMigration(ctx context.Context) error

	CreateTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error
	UpdateTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error
	DeleteTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error
	ReadTenantConfigByTenantUUID(ctx context.Context, uid string) (*TenantConfig, error)

	CreateCodeModule(ctx context.Context, codeModule *CodeModule) error
	ReadCodeModuleByVersion(ctx context.Context, version string) (*CodeModule, error)
	DeleteCodeModule(ctx context.Context, codeModule *CodeModule) error

	CreateOSMount(ctx context.Context, osMount *OSMount) error
	UpdateOSMount(ctx context.Context, osMount *OSMount) error
	DeleteOSMount(ctx context.Context, osMount *OSMount) error
	RestoreOSMount(ctx context.Context, osMount *OSMount) error
	ReadOSMountByTenantUUID(ctx context.Context, tenantUUID string) (*OSMount, error)

	CreateAppMount(ctx context.Context, appMount *AppMount) error
	UpdateAppMount(ctx context.Context, appMount *AppMount) error
	DeleteAppMount(ctx context.Context, appMount *AppMount) error
	ReadAppMountByVolumeMetaID(ctx context.Context, volumeMetaID string) (*AppMount, error)
	ReadAppMounts(ctx context.Context) ([]AppMount, error)
}

type DBConn added in v1.1.0

type DBConn struct {
	// contains filtered or unexported fields
}

func NewDBAccess added in v1.1.0

func NewDBAccess(path string) (*DBConn, error)

NewDBAccess creates a new gorm db connection to the database.

func (*DBConn) CreateAppMount added in v1.1.0

func (conn *DBConn) CreateAppMount(ctx context.Context, appMount *AppMount) error

func (*DBConn) CreateCodeModule added in v1.1.0

func (conn *DBConn) CreateCodeModule(ctx context.Context, codeModule *CodeModule) error

func (*DBConn) CreateOSMount added in v1.1.0

func (conn *DBConn) CreateOSMount(ctx context.Context, osMount *OSMount) error

func (*DBConn) CreateTenantConfig added in v1.1.0

func (conn *DBConn) CreateTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error

func (*DBConn) DeleteAppMount added in v1.1.0

func (conn *DBConn) DeleteAppMount(ctx context.Context, appMount *AppMount) error

func (*DBConn) DeleteCodeModule added in v1.1.0

func (conn *DBConn) DeleteCodeModule(ctx context.Context, codeModule *CodeModule) error

func (*DBConn) DeleteOSMount added in v1.1.0

func (conn *DBConn) DeleteOSMount(ctx context.Context, osMount *OSMount) error

func (*DBConn) DeleteTenantConfig added in v1.1.0

func (conn *DBConn) DeleteTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error

func (*DBConn) ReadAppMountByVolumeMetaID added in v1.1.0

func (conn *DBConn) ReadAppMountByVolumeMetaID(ctx context.Context, volumeMetaID string) (*AppMount, error)

func (*DBConn) ReadAppMounts added in v1.1.0

func (conn *DBConn) ReadAppMounts(ctx context.Context) ([]AppMount, error)

func (*DBConn) ReadCodeModuleByVersion added in v1.1.0

func (conn *DBConn) ReadCodeModuleByVersion(ctx context.Context, version string) (*CodeModule, error)

func (*DBConn) ReadOSMountByTenantUUID added in v1.1.0

func (conn *DBConn) ReadOSMountByTenantUUID(ctx context.Context, tenantUUID string) (*OSMount, error)

func (*DBConn) ReadTenantConfigByTenantUUID added in v1.1.0

func (conn *DBConn) ReadTenantConfigByTenantUUID(ctx context.Context, uid string) (*TenantConfig, error)

func (*DBConn) ReadVolumeMetaByID added in v1.1.0

func (conn *DBConn) ReadVolumeMetaByID(ctx context.Context, id string) (*VolumeMeta, error)

func (*DBConn) RestoreOSMount added in v1.1.0

func (conn *DBConn) RestoreOSMount(ctx context.Context, osMount *OSMount) error

func (*DBConn) SchemaMigration added in v1.1.0

func (conn *DBConn) SchemaMigration(_ context.Context) error

SchemaMigration runs gormigrate migrations to create tables

func (*DBConn) UpdateAppMount added in v1.1.0

func (conn *DBConn) UpdateAppMount(ctx context.Context, appMount *AppMount) error

func (*DBConn) UpdateOSMount added in v1.1.0

func (conn *DBConn) UpdateOSMount(ctx context.Context, osMount *OSMount) error

func (*DBConn) UpdateTenantConfig added in v1.1.0

func (conn *DBConn) UpdateTenantConfig(ctx context.Context, tenantConfig *TenantConfig) error

type Dynakube

type Dynakube struct {
	Name                   string `json:"name"`
	TenantUUID             string `json:"tenantUUID"`
	LatestVersion          string `json:"latestVersion"`
	ImageDigest            string `json:"imageDigest"`
	MaxFailedMountAttempts int    `json:"maxFailedMountAttempts"`
}

Dynakube stores the necessary info from the Dynakube that is needed to be used during volume mount/unmount.

func NewDynakube

func NewDynakube(dynakubeName, tenantUUID, latestVersion, imageDigest string, maxFailedMountAttempts int) *Dynakube

NewDynakube returns a new metadata.Dynakube if all fields are set.

type FakeFailDB

type FakeFailDB struct{}

func (*FakeFailDB) DeleteDynakube

func (f *FakeFailDB) DeleteDynakube(_ context.Context, _ string) error

func (*FakeFailDB) DeleteVolume

func (f *FakeFailDB) DeleteVolume(_ context.Context, _ string) error

func (*FakeFailDB) GetAllDynakubes

func (f *FakeFailDB) GetAllDynakubes(_ context.Context) ([]*Dynakube, error)

func (*FakeFailDB) GetAllOsAgentVolumes

func (f *FakeFailDB) GetAllOsAgentVolumes(_ context.Context) ([]*OsAgentVolume, error)

func (*FakeFailDB) GetAllUsedVersions

func (f *FakeFailDB) GetAllUsedVersions(_ context.Context) (map[string]bool, error)

func (*FakeFailDB) GetAllVolumes

func (f *FakeFailDB) GetAllVolumes(_ context.Context) ([]*Volume, error)

func (*FakeFailDB) GetDynakube

func (f *FakeFailDB) GetDynakube(_ context.Context, _ string) (*Dynakube, error)

func (*FakeFailDB) GetLatestVersions

func (f *FakeFailDB) GetLatestVersions(_ context.Context) (map[string]bool, error)

func (*FakeFailDB) GetOsAgentVolumeViaTenantUUID

func (f *FakeFailDB) GetOsAgentVolumeViaTenantUUID(_ context.Context, _ string) (*OsAgentVolume, error)

func (*FakeFailDB) GetOsAgentVolumeViaVolumeID

func (f *FakeFailDB) GetOsAgentVolumeViaVolumeID(_ context.Context, _ string) (*OsAgentVolume, error)

func (*FakeFailDB) GetPodNames

func (f *FakeFailDB) GetPodNames(_ context.Context) (map[string]string, error)

func (*FakeFailDB) GetTenantsToDynakubes

func (f *FakeFailDB) GetTenantsToDynakubes(_ context.Context) (map[string]string, error)

func (*FakeFailDB) GetUsedImageDigests

func (f *FakeFailDB) GetUsedImageDigests(_ context.Context) (map[string]bool, error)

func (*FakeFailDB) GetUsedVersions

func (f *FakeFailDB) GetUsedVersions(_ context.Context, _ string) (map[string]bool, error)

func (*FakeFailDB) GetVolume

func (f *FakeFailDB) GetVolume(_ context.Context, _ string) (*Volume, error)

func (*FakeFailDB) InsertDynakube

func (f *FakeFailDB) InsertDynakube(_ context.Context, _ *Dynakube) error

func (*FakeFailDB) InsertOsAgentVolume

func (f *FakeFailDB) InsertOsAgentVolume(_ context.Context, _ *OsAgentVolume) error

func (*FakeFailDB) InsertVolume

func (f *FakeFailDB) InsertVolume(_ context.Context, _ *Volume) error

func (*FakeFailDB) IsImageDigestUsed

func (f *FakeFailDB) IsImageDigestUsed(_ context.Context, _ string) (bool, error)

func (*FakeFailDB) Setup

func (f *FakeFailDB) Setup(_ context.Context, _ string) error

func (*FakeFailDB) UpdateDynakube

func (f *FakeFailDB) UpdateDynakube(_ context.Context, _ *Dynakube) error

func (*FakeFailDB) UpdateOsAgentVolume

func (f *FakeFailDB) UpdateOsAgentVolume(_ context.Context, _ *OsAgentVolume) error

type OSMount added in v1.1.0

type OSMount struct {
	VolumeMeta VolumeMeta `gorm:"foreignKey:VolumeMetaID"`
	TimeStampedModel
	TenantConfigUID string       `gorm:"not null"`
	TenantUUID      string       `gorm:"primaryKey"`
	VolumeMetaID    string       `gorm:"not null"`
	Location        string       `gorm:"not null"`
	TenantConfig    TenantConfig `gorm:"foreignKey:TenantConfigUID"`
	MountAttempts   int64        `gorm:"not null"`
}

OSMount keeps track of our mounts to OS oneAgents, can be "remounted", which causes annoyances.

type OsAgentVolume

type OsAgentVolume struct {
	LastModified *time.Time `json:"lastModified"`
	VolumeID     string     `json:"volumeID"`
	TenantUUID   string     `json:"tenantUUID"`
	Mounted      bool       `json:"mounted"`
}

func NewOsAgentVolume

func NewOsAgentVolume(volumeID, tenantUUID string, mounted bool, timeStamp *time.Time) *OsAgentVolume

NewOsAgentVolume returns a new volume if all fields are set.

type PathResolver

type PathResolver struct {
	RootDir string
}

func (PathResolver) AgentBinaryDir

func (pr PathResolver) AgentBinaryDir(tenantUUID string) string

func (PathResolver) AgentBinaryDirForVersion

func (pr PathResolver) AgentBinaryDirForVersion(tenantUUID string, version string) string

Deprecated

func (PathResolver) AgentConfigDir

func (pr PathResolver) AgentConfigDir(tenantUUID string, dynakubeName string) string

func (PathResolver) AgentRunDir

func (pr PathResolver) AgentRunDir(tenantUUID string) string

func (PathResolver) AgentRunDirForVolume

func (pr PathResolver) AgentRunDirForVolume(tenantUUID string, volumeId string) string

func (PathResolver) AgentSharedBinaryDirBase

func (pr PathResolver) AgentSharedBinaryDirBase() string

func (PathResolver) AgentSharedBinaryDirForAgent

func (pr PathResolver) AgentSharedBinaryDirForAgent(versionOrDigest string) string

func (PathResolver) AgentSharedRuxitAgentProcConf added in v1.0.0

func (pr PathResolver) AgentSharedRuxitAgentProcConf(tenantUUID, dynakubeName string) string

func (PathResolver) AgentTempUnzipDir

func (pr PathResolver) AgentTempUnzipDir() string

func (PathResolver) AgentTempUnzipRootDir

func (pr PathResolver) AgentTempUnzipRootDir() string

func (PathResolver) OsAgentDir

func (pr PathResolver) OsAgentDir(tenantUUID string) string

func (PathResolver) OverlayMappedDir

func (pr PathResolver) OverlayMappedDir(tenantUUID string, volumeId string) string

func (PathResolver) OverlayVarDir

func (pr PathResolver) OverlayVarDir(tenantUUID string, volumeId string) string

func (PathResolver) OverlayVarRuxitAgentProcConf added in v1.0.0

func (pr PathResolver) OverlayVarRuxitAgentProcConf(tenantUUID, volumeId string) string

func (PathResolver) OverlayWorkDir

func (pr PathResolver) OverlayWorkDir(tenantUUID string, volumeId string) string

func (PathResolver) TenantDir

func (pr PathResolver) TenantDir(tenantUUID string) string

type SqliteAccess

type SqliteAccess struct {
	// contains filtered or unexported fields
}

func FakeMemoryDB

func FakeMemoryDB() *SqliteAccess

func (*SqliteAccess) DeleteDynakube

func (access *SqliteAccess) DeleteDynakube(ctx context.Context, dynakubeName string) error

DeleteDynakube deletes an existing Dynakube using its name

func (*SqliteAccess) DeleteVolume

func (access *SqliteAccess) DeleteVolume(ctx context.Context, volumeID string) error

DeleteVolume deletes a Volume by its ID

func (*SqliteAccess) GetAllDynakubes

func (access *SqliteAccess) GetAllDynakubes(ctx context.Context) ([]*Dynakube, error)

GetAllDynakubes gets all the Dynakubes from the database

func (*SqliteAccess) GetAllOsAgentVolumes

func (access *SqliteAccess) GetAllOsAgentVolumes(ctx context.Context) ([]*OsAgentVolume, error)

GetAllOsAgentVolumes gets all the OsAgentVolume from the database

func (*SqliteAccess) GetAllUsedVersions

func (access *SqliteAccess) GetAllUsedVersions(ctx context.Context) (map[string]bool, error)

GetUsedVersions gets all UNIQUE versions present in the `volumes` database in map. Map is used to make sure we don't return the same version multiple time, it's also easier to check if a version is in it or not. (a Set in style of Golang)

func (*SqliteAccess) GetAllVolumes

func (access *SqliteAccess) GetAllVolumes(ctx context.Context) ([]*Volume, error)

GetAllVolumes gets all the Volumes from the database

func (*SqliteAccess) GetDynakube

func (access *SqliteAccess) GetDynakube(ctx context.Context, dynakubeName string) (*Dynakube, error)

GetDynakube gets Dynakube using its name

func (*SqliteAccess) GetLatestVersions

func (access *SqliteAccess) GetLatestVersions(ctx context.Context) (map[string]bool, error)

GetLatestVersions gets all UNIQUE latestVersions present in the `dynakubes` database in map. Map is used to make sure we don't return the same version multiple time, it's also easier to check if a version is in it or not. (a Set in style of Golang)

func (*SqliteAccess) GetOsAgentVolumeViaTenantUUID

func (access *SqliteAccess) GetOsAgentVolumeViaTenantUUID(ctx context.Context, tenantUUID string) (*OsAgentVolume, error)

GetOsAgentVolumeViaTenantUUID gets an OsAgentVolume by its tenantUUID

func (*SqliteAccess) GetOsAgentVolumeViaVolumeID

func (access *SqliteAccess) GetOsAgentVolumeViaVolumeID(ctx context.Context, volumeID string) (*OsAgentVolume, error)

GetOsAgentVolumeViaVolumeID gets an OsAgentVolume by its VolumeID

func (*SqliteAccess) GetPodNames

func (access *SqliteAccess) GetPodNames(ctx context.Context) (map[string]string, error)

GetPodNames gets all PodNames present in the `volumes` database in map with their corresponding volumeIDs.

func (*SqliteAccess) GetTenantsToDynakubes

func (access *SqliteAccess) GetTenantsToDynakubes(ctx context.Context) (map[string]string, error)

GetTenantsToDynakubes gets all Dynakubes and maps their name to the corresponding TenantUUID.

func (*SqliteAccess) GetUsedImageDigests

func (access *SqliteAccess) GetUsedImageDigests(ctx context.Context) (map[string]bool, error)

GetUsedImageDigests gets all UNIQUE image digests present in the `dynakubes` database in a map. Map is used to make sure we don't return the same digest multiple time, it's also easier to check if a digest is in it or not. (a Set in style of Golang)

func (*SqliteAccess) GetUsedVersions

func (access *SqliteAccess) GetUsedVersions(ctx context.Context, tenantUUID string) (map[string]bool, error)

GetUsedVersions gets all UNIQUE versions present in the `volumes` for a given tenantUUID database in map. Map is used to make sure we don't return the same version multiple time, it's also easier to check if a version is in it or not. (a Set in style of Golang)

func (*SqliteAccess) GetVolume

func (access *SqliteAccess) GetVolume(ctx context.Context, volumeID string) (*Volume, error)

GetVolume gets Volume by its ID

func (*SqliteAccess) InsertDynakube

func (access *SqliteAccess) InsertDynakube(ctx context.Context, dynakube *Dynakube) error

InsertDynakube inserts a new Dynakube

func (*SqliteAccess) InsertOsAgentVolume

func (access *SqliteAccess) InsertOsAgentVolume(ctx context.Context, volume *OsAgentVolume) error

InsertOsAgentVolume inserts a new OsAgentVolume

func (*SqliteAccess) InsertVolume

func (access *SqliteAccess) InsertVolume(ctx context.Context, volume *Volume) error

InsertVolume inserts a new Volume

func (*SqliteAccess) IsImageDigestUsed

func (access *SqliteAccess) IsImageDigestUsed(ctx context.Context, imageDigest string) (bool, error)

IsImageDigestUsed checks if the specified image digest is present in the database.

func (*SqliteAccess) Setup

func (access *SqliteAccess) Setup(ctx context.Context, path string) error

Setup connects to the database and creates the necessary tables if they don't exist

func (*SqliteAccess) UpdateDynakube

func (access *SqliteAccess) UpdateDynakube(ctx context.Context, dynakube *Dynakube) error

UpdateDynakube updates an existing Dynakube by matching the name

func (*SqliteAccess) UpdateOsAgentVolume

func (access *SqliteAccess) UpdateOsAgentVolume(ctx context.Context, volume *OsAgentVolume) error

UpdateOsAgentVolume updates an existing OsAgentVolume by matching the tenantUUID

type TenantConfig added in v1.1.0

type TenantConfig struct {
	TimeStampedModel
	UID                         string `gorm:"primaryKey"`
	Name                        string `gorm:"not null"`
	DownloadedCodeModuleVersion string
	ConfigDirPath               string `gorm:"not null"`
	TenantUUID                  string `gorm:"not null"`
	MaxFailedMountAttempts      int64  `gorm:"default:10"`
}

TenantConfig holds info about a given configuration for a tenant.

func (*TenantConfig) BeforeCreate added in v1.1.0

func (tc *TenantConfig) BeforeCreate(_ *gorm.DB) error

type TimeStampedModel added in v1.1.0

type TimeStampedModel struct {
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
}

type Volume

type Volume struct {
	VolumeID      string `json:"volumeID" gorm:"column:ID"`
	PodName       string `json:"podName"`
	Version       string `json:"version"`
	TenantUUID    string `json:"tenantUUID"`
	MountAttempts int    `json:"mountAttempts"`
}

func NewVolume

func NewVolume(id, podName, version, tenantUUID string, mountAttempts int) *Volume

NewVolume returns a new Volume if all fields (except version) are set.

type VolumeMeta added in v1.1.0

type VolumeMeta struct {
	ID                string `gorm:"primaryKey"`
	PodUid            string `gorm:"not null"`
	PodName           string `gorm:"not null"`
	PodNamespace      string `gorm:"not null"`
	PodServiceAccount string `gorm:"not null"`
	TimeStampedModel
}

VolumeMeta keeps metadata we get from kubernetes about the volume.

Jump to

Keyboard shortcuts

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