Documentation
¶
Index ¶
- Constants
- Variables
- func OptionDisableUpdatesOnFailedRollout(api *API) error
- func OptionInitDB(api *API) error
- type API
- func (api *API) ClearUpdatesEnabledOverride(groupID string) error
- func (api *API) Close()
- func (api *API) GetUpdatePackage(inst Instance, instApp InstanceApplication) (*Package, error)
- func (api *API) GetUpdatePackagesForSyncer(inst Instance, instApp InstanceApplication) ([]*Package, error)
- func (api *API) MigrateDown(version string) (int, error)
- func (api *API) Reads() *dbreads.Queries
- func (api *API) RegisterEvent(instanceID, appID, groupID string, etype, eresult int, ...) error
- func (api *API) RegisterInstance(inst Instance, instApp InstanceApplication) (*Instance, error)
- func (api *API) UpdateInstance(instanceID string, alias string) (*Instance, error)
- func (api *API) UpdateInstanceStats(t *time.Time, duration *time.Duration) error
- type Activity
- type ActivityQueryParams
- type AppInstancesPerChannelMetric
- type Application
- type Arch
- type Channel
- type ChannelFloorInfo
- type ChannelPackageFloor
- type Event
- type FailedUpdatesMetric
- type File
- type FlatcarAction
- type Group
- type GroupDescriptor
- type Instance
- type InstanceApplication
- type InstanceStats
- type InstanceStatusHistoryEntry
- type InstancesQueryParams
- type InstancesStatusStats
- type InstancesWithTotal
- type Package
- type StatusVersionCountTimelineEntry
- type StringArray
- type Team
- type UpdatesStats
- type User
- type VersionBreakdownEntry
- type VersionCountMap
- type VersionCountTimelineEntry
Constants ¶
const ( ArchAll = types.ArchAll ArchAMD64 = types.ArchAMD64 ArchAArch64 = types.ArchAArch64 ArchX86 = types.ArchX86 )
const ( // EventUpdateComplete indicates that the update process completed. It could // mean a successful or failed updated, depending on the result attached to // the event. This applies to all events. EventUpdateComplete = 3 // EventUpdateDownloadStarted indicates that the instance started // downloading the update package. EventUpdateDownloadStarted = 13 // EventUpdateDownloadFinished indicates that the update package was // downloaded. EventUpdateDownloadFinished = 14 // EventUpdateInstalled indicates that the update package was installed. EventUpdateInstalled = 800 )
const ( // ResultFailed indicates that the operation associated with the event // posted failed. ResultFailed = 0 // ResultSuccess indicates that the operation associated with the event // posted succeeded. ResultSuccess = 1 // ResultSuccessReboot also indicates a successful operation, but it's // meant only to be used along with events of EventUpdateComplete type. // It's important that instances use EventUpdateComplete events in // combination with ResultSuccessReboot to communicate a successful update // completed as it has a special meaning for Nebraska in order to adjust // properly the rollout policies and create activity entries. ResultSuccessReboot = 2 )
const ( InstanceStatusUndefined = types.InstanceStatusUndefined InstanceStatusUpdateGranted = types.InstanceStatusUpdateGranted InstanceStatusError = types.InstanceStatusError InstanceStatusComplete = types.InstanceStatusComplete InstanceStatusInstalled = types.InstanceStatusInstalled InstanceStatusDownloaded = types.InstanceStatusDownloaded InstanceStatusDownloading = types.InstanceStatusDownloading InstanceStatusOnHold = types.InstanceStatusOnHold )
const ( // PkgTypeFlatcar indicates that the package is a Flatcar update package PkgTypeFlatcar = types.PkgTypeFlatcar // PkgTypeDocker indicates that the package is a Docker container PkgTypeDocker = types.PkgTypeDocker // PkgTypeRocket indicates that the package is a Rocket container PkgTypeRocket = types.PkgTypeRocket // PkgTypeOther is the generic package type. PkgTypeOther = types.PkgTypeOther )
Variables ¶
var ( // ErrNoRowsAffected indicates that no rows were affected in an update or // delete database operation. ErrNoRowsAffected = types.ErrNoRowsAffected // ErrInvalidSemver indicates that the provided semver version is not valid. ErrInvalidSemver = types.ErrInvalidSemver // ErrArchMismatch indicates that arches of two objects didn't // match (for example, for a package and channel) ErrArchMismatch = types.ErrArchMismatch )
var ( // ErrInvalidPackage error indicates that a package doesn't belong to the // application it was supposed to belong to. ErrInvalidPackage = types.ErrInvalidPackage // ErrBlacklistedChannel error indicates an attempt of creating/updating a // channel using a package that has blacklisted the channel. ErrBlacklistedChannel = types.ErrBlacklistedChannel )
var ( // ErrInvalidInstance indicates that the instance provided is not valid or // it doesn't exist. ErrInvalidInstance = errors.New("nebraska: invalid instance") // ErrInvalidApplicationOrGroup indicates that the application or group id // provided are not valid or related to each other. ErrInvalidApplicationOrGroup = types.ErrInvalidApplicationOrGroup // ErrInvalidEventTypeOrResult indicates that the event or result provided // are not valid (Nebraska only implements a subset of the Omaha protocol // events). ErrInvalidEventTypeOrResult = errors.New("nebraska: invalid event type or result") // ErrEventRegistrationFailed indicates that the event registration into // Nebraska failed. ErrEventRegistrationFailed = errors.New("nebraska: event registration failed") // ErrNoUpdateInProgress indicates that an event was received but there // wasn't an update in progress for the provided instance/application, so // it was rejected. ErrNoUpdateInProgress = errors.New("nebraska: no update in progress") // ErrFlatcarEventIgnored indicates that a Flatcar updater event was ignored. // This is a temporary solution to handle Flatcar specific behaviour. ErrFlatcarEventIgnored = errors.New("nebraska: flatcar event ignored") )
var ( // ErrInvalidChannel error indicates that a channel doesn't belong to the // application it was supposed to belong to. ErrInvalidChannel = types.ErrInvalidChannel // ErrExpectingValidTimezone error indicates that a valid timezone wasn't // provided when enabling the flag PolicyOfficeHours. ErrExpectingValidTimezone = types.ErrExpectingValidTimezone )
var ( // ErrBlacklistingChannel error indicates that the channel the package is // trying to blacklist is already pointing to the package. ErrBlacklistingChannel = types.ErrBlacklistingChannel // ErrPackageIsFloor error indicates that the package cannot be deleted // because it is marked as a floor version for one or more channels. ErrPackageIsFloor = types.ErrPackageIsFloor // ErrBlacklistingFloor error indicates that the package cannot be blacklisted // because it is marked as a floor version for the channel. ErrBlacklistingFloor = types.ErrBlacklistingFloor )
var ( // ErrRegisterInstanceFailed indicates that the instance registration did // not succeed. ErrRegisterInstanceFailed = errors.New("nebraska: register instance failed") // ErrUpdateInProgressOnInstance indicates that an update is currently in // progress on the instance requesting an update package, so the request // will be rejected. ErrUpdateInProgressOnInstance = errors.New("nebraska: update in progress on instance") // ErrNoPackageFound indicates that the group doesn't have a channel // assigned or that the channel doesn't have a package assigned. ErrNoPackageFound = dbreads.ErrNoPackageFound // ErrNoUpdatePackageAvailable indicates that the instance requesting the // update has already the latest version of the application. ErrNoUpdatePackageAvailable = errors.New("nebraska: no update package available") // ErrUpdateGrantFailed indicates that the update could not be granted // due to a database or internal error. ErrUpdateGrantFailed = errors.New("nebraska: failed to grant update") // ErrUpdatesDisabled indicates that updates are not enabled in the group. ErrUpdatesDisabled = errors.New("nebraska: updates disabled") // ErrGetUpdatesStatsFailed indicates that there was a problem getting the // updates stats of the group which are needed to enforce the rollout // policy. ErrGetUpdatesStatsFailed = errors.New("nebraska: get updates stats failed") // ErrMaxUpdatesPerPeriodLimitReached indicates that the maximum number of // updates per period has been reached. ErrMaxUpdatesPerPeriodLimitReached = errors.New("nebraska: max updates per period limit reached") // ErrMaxConcurrentUpdatesLimitReached indicates that the maximum number of // concurrent updates has been reached. ErrMaxConcurrentUpdatesLimitReached = errors.New("nebraska: max concurrent updates limit reached") // ErrMaxTimedOutUpdatesLimitReached indicates that limit of instances that // timed out while updating has been reached. ErrMaxTimedOutUpdatesLimitReached = errors.New("nebraska: max timed out updates limit reached") // ErrGrantingUpdate indicates that something went wrong while granting an // update. ErrGrantingUpdate = errors.New("nebraska: error granting update") )
var ErrInvalidArch = types.ErrInvalidArch
var ErrPackageBlacklisted = types.ErrPackageBlacklisted
var ErrUpdatingPassword = types.ErrUpdatingPassword
Functions ¶
func OptionDisableUpdatesOnFailedRollout ¶
OptionDisableUpdatesOnFailedRollout will modify API to disable updates on failed rollout.
func OptionInitDB ¶
OptionInitDB will initialize the database during the API instance creation, dropping all existing tables, which will force all migration scripts to be re-executed. Use with caution, this will DESTROY ALL YOUR DATA.
Types ¶
type API ¶
API represents an api instance used to interact with Nebraska entities.
func NewForTest ¶
NewForTest creates a new API instance with given options and fills the database with sample data for testing purposes.
func NewWithMigrations ¶
NewWithMigrations creates a new API instance, creates the underlying db connection and applies all available db migrations.
func (*API) ClearUpdatesEnabledOverride ¶
ClearUpdatesEnabledOverride clears the local policy_updates_enabled override on the group_local row so the admin default on groups takes effect again on this node.
func (*API) GetUpdatePackage ¶
func (api *API) GetUpdatePackage(inst Instance, instApp InstanceApplication) (*Package, error)
GetUpdatePackage returns an update package for the instance/application provided. The instance details and the application it's running will be registered in Nebraska (or updated if it's already registered).
func (*API) GetUpdatePackagesForSyncer ¶
func (api *API) GetUpdatePackagesForSyncer(inst Instance, instApp InstanceApplication) ([]*Package, error)
GetUpdatePackagesForSyncer returns all packages (floors + target) for a syncer client
func (*API) Reads ¶
Reads returns the shared read queries (dbreads.Queries) owned by this API instance.
func (*API) RegisterEvent ¶
func (api *API) RegisterEvent(instanceID, appID, groupID string, etype, eresult int, previousVersion, errorCode string) error
RegisterEvent registers an event posted by an instance in Nebraska. The event will be bound to an application/group combination.
func (*API) RegisterInstance ¶
func (api *API) RegisterInstance(inst Instance, instApp InstanceApplication) (*Instance, error)
RegisterInstance registers an instance into Nebraska.
func (*API) UpdateInstance ¶
type ActivityQueryParams ¶
type ActivityQueryParams = types.ActivityQueryParams
type AppInstancesPerChannelMetric ¶
type AppInstancesPerChannelMetric = types.AppInstancesPerChannelMetric
type Application ¶
type Application = types.Application
type ChannelFloorInfo ¶
type ChannelFloorInfo = types.ChannelFloorInfo
type ChannelPackageFloor ¶
type ChannelPackageFloor = types.ChannelPackageFloor
type Event ¶
type Event struct {
ID int `db:"id" json:"id"`
CreatedTs time.Time `db:"created_ts" json:"created_ts"`
PreviousVersion null.String `db:"previous_version" json:"previous_version"`
ErrorCode null.String `db:"error_code" json:"error_code"`
InstanceID string `db:"instance_id" json:"instance_id"`
ApplicationID string `db:"application_id" json:"application_id"`
EventTypeID string `db:"event_type_id" json:"event_type_id"`
}
Event represents an event posted by an instance to Nebraska.
type FailedUpdatesMetric ¶
type FailedUpdatesMetric = types.FailedUpdatesMetric
type FlatcarAction ¶
type FlatcarAction = types.FlatcarAction
type GroupDescriptor ¶
type GroupDescriptor = types.GroupDescriptor
type InstanceApplication ¶
type InstanceApplication = types.InstanceApplication
func NewInstanceApplication ¶
func NewInstanceApplication(appID, groupID, version string) InstanceApplication
NewInstanceApplication creates an InstanceApplication with the fields used for registration.
type InstanceStats ¶
type InstanceStats = types.InstanceStats
type InstanceStatusHistoryEntry ¶
type InstanceStatusHistoryEntry = types.InstanceStatusHistoryEntry
type InstancesQueryParams ¶
type InstancesQueryParams = types.InstancesQueryParams
type InstancesStatusStats ¶
type InstancesStatusStats = types.InstancesStatusStats
type InstancesWithTotal ¶
type InstancesWithTotal = types.InstancesWithTotal
type StatusVersionCountTimelineEntry ¶
type StatusVersionCountTimelineEntry = types.StatusVersionCountTimelineEntry
type StringArray ¶
type StringArray = types.StringArray
type UpdatesStats ¶
type UpdatesStats = types.UpdatesStats
type VersionBreakdownEntry ¶
type VersionBreakdownEntry = types.VersionBreakdownEntry
type VersionCountMap ¶
type VersionCountMap = types.VersionCountMap
type VersionCountTimelineEntry ¶
type VersionCountTimelineEntry = types.VersionCountTimelineEntry
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package admin provides write operations for admin-managed tables (application, channel, package, groups, team, users).
|
Package admin provides write operations for admin-managed tables (application, channel, package, groups, team, users). |
|
internal
|
|
|
dbreads
Package dbreads holds the shared read queries used by the api stack.
|
Package dbreads holds the shared read queries used by the api stack. |
|
types
This file was taken from the pq project and is licensed under the terms of the MIT license: https://github.com/lib/pq Copyright (c) 2011-2013, 'pq' Contributors Portions Copyright (C) 2011 Blake Mizerany
|
This file was taken from the pq project and is licensed under the terms of the MIT license: https://github.com/lib/pq Copyright (c) 2011-2013, 'pq' Contributors Portions Copyright (C) 2011 Blake Mizerany |