models

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllAtOnce StrategyType = "AllAtOnce"
	Canary                 = "Canary"
	Percent                = "Percent"
	Increment              = "Increment"
)

Variables

View Source
var STRATEGIES = []string{
	"AllAtOnce",
	"OneThenAllWithCanary",
	"25PercentStepRolloutNoCanary",
	"10PercentStepRolloutNoCanary",
	"10AtATimeNoCanary",
	"20AtATimeNoCanary",
}

Functions

func AddReleaseS3Objects

func AddReleaseS3Objects(awsc *mocks.MockClients, release *Release)

func MockAwsClients

func MockAwsClients(release *Release) *mocks.MockClients

MockAwsClients mocks

func MockPrepareRelease

func MockPrepareRelease(release *Release)

MockPrepareRelease mocks

func ValidateELB

func ValidateELB(service serviceIface, lb *elb.LoadBalancer) error

ValidateELB returns

func ValidateIAMProfile

func ValidateIAMProfile(service serviceIface, profile *iam.Profile) error

ValidateIAMProfile returns

func ValidateImage

func ValidateImage(service serviceIface, im *ami.Image) error

ValidateImage returns

func ValidatePrevASG

func ValidatePrevASG(service serviceIface, as *asg.ASG) error

ValidatePrevASG returns

func ValidateSecurityGroup

func ValidateSecurityGroup(service serviceIface, sc *sg.SecurityGroup) error

ValidateSecurityGroup returns

func ValidateSubnet

func ValidateSubnet(service serviceIface, subnet *subnet.Subnet) error

ValidateSubnet returns

func ValidateTargetGroup

func ValidateTargetGroup(service serviceIface, tg *alb.TargetGroup) error

ValidateTargetGroup returns

Types

type AutoScalingConfig

type AutoScalingConfig struct {
	MinSize                *int64    `json:"min_size,omitempty"`
	MaxSize                *int64    `json:"max_size,omitempty"`
	MaxTerminations        *int64    `json:"max_terms,omitempty"`
	DefaultCooldown        *int64    `json:"default_cooldown,omitempty"`
	HealthCheckGracePeriod *int64    `json:"health_check_grace_period,omitempty"`
	Spread                 *float64  `json:"spread,omitempty"`
	Policies               []*Policy `json:"policies,omitempty"`

	Strategy *string `json:"strategy,omitempty"`
}

AutoScalingConfig struct

func (*AutoScalingConfig) SetDefaults

func (a *AutoScalingConfig) SetDefaults(serviceID *string, timeout *int) error

SetDefaults assigns values

func (*AutoScalingConfig) ValidateAttributes

func (a *AutoScalingConfig) ValidateAttributes() error

ValidateAttributes validates attributes

type DetachError

type DetachError struct {
	Cause string
}

Errors

func (DetachError) Error

func (e DetachError) Error() string

type HaltError

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

HaltError error

func (*HaltError) Error

func (he *HaltError) Error() string

Error returns error

type HealthReport

type HealthReport struct {
	TargetHealthy  *int64   `json:"target_healthy,omitempty"`  // Number of instances aimed to to Launch
	TargetLaunched *int64   `json:"target_launched,omitempty"` // Number of instances aimed to to Launch
	Healthy        *int     `json:"healthy,omitempty"`         // Number of instances that are healthy
	Launching      *int     `json:"launching,omitempty"`       // Number of instances that have been created
	Terminating    *int     `json:"terminating,omitempty"`     // Number of instances that are Terminating
	TerminatingIDs []string `json:"terminating_ids,omitempty"` // Instance IDs that are Terminating

	DesiredCapacity *int64 `json:"desired_capacity,omitempty"` // The current desired capacity goal
	MinSize         *int64 `json:"min_size,omitempty"`         // The current min size
}

HealthReport is built to make log lines like: web: .....|. gray targets, red terminated, yellow unhealthy, green healthy

type LifeCycleHook

type LifeCycleHook struct {
	Transistion      *string `json:"transition,omitempty"`
	SNS              *string `json:"sns,omitempty"`
	Role             *string `json:"role,omitempty"`
	HeartbeatTimeout *int64  `json:"heartbeat_timeout,omitempty"`

	RoleARN               *string `json:"role_arn,omitempty"`
	NotificationTargetARN *string `json:"notification_target_arn,omitempty"`
	Name                  *string `json:"name,omitempty"`
}

LifeCycleHook struct

func (*LifeCycleHook) FetchResources

func (lc *LifeCycleHook) FetchResources(iamc aws.IAMAPI, snsc aws.SNSAPI) error

FetchResources validates resources exist

func (*LifeCycleHook) SetDefaults

func (lc *LifeCycleHook) SetDefaults(region *string, accountID *string, name string)

SetDefaults assigns default values

func (*LifeCycleHook) ToLifecycleHookSpecification

func (lc *LifeCycleHook) ToLifecycleHookSpecification() *autoscaling.LifecycleHookSpecification

ToLifecycleHookSpecification returns Specification

func (*LifeCycleHook) ValidateAttributes

func (lc *LifeCycleHook) ValidateAttributes() error

ValidateAttributes validates attributes

type Policy

type Policy struct {
	NameVal              *string  `json:"name,omitempty"`
	Type                 *string  `json:"type,omitempty"`
	ScalingAdjustmentVal *int64   `json:"scaling_adjustment,omitempty"`
	ThresholdVal         *float64 `json:"threshold,omitempty"`
	PeriodVal            *int64   `json:"period,omitempty"`
	EvaluationPeriodsVal *int64   `json:"evaluation_periods,omitempty"`
	CooldownVal          *int64   `json:"cooldown,omitempty"`
	// contains filtered or unexported fields
}

Policy struct

func (*Policy) Cooldown

func (a *Policy) Cooldown() *int64

Cooldown returns cooldown

func (*Policy) Create

func (a *Policy) Create(asgc aws.ASGAPI, cwc aws.CWAPI, asgName *string) error

Create attempts to create alarm and policy

func (*Policy) EvaluationPeriods

func (a *Policy) EvaluationPeriods() *int64

EvaluationPeriods returns eval periods

func (*Policy) Name

func (a *Policy) Name() *string

func (*Policy) Period

func (a *Policy) Period() *int64

Period returns period

func (*Policy) ScalingAdjustment

func (a *Policy) ScalingAdjustment() *int64

ScalingAdjustment returns up or down adjustment

func (*Policy) SetDefaults

func (a *Policy) SetDefaults(serviceID *string) error

SetDefaults assigns default values

func (*Policy) Threshold

func (a *Policy) Threshold() *float64

Threshold returns threshold

func (*Policy) ValidateAttributes

func (a *Policy) ValidateAttributes() error

ValidateAttributes validates attributes

type Release

type Release struct {
	bifrost.Release

	SafeRelease bool `json:"safe_release,omitempty"`

	Subnets []*string `json:"subnets,omitempty"`

	Image *string `json:"ami,omitempty"`

	UserDataSHA256 *string `json:"user_data_sha256,omitempty"`

	// LifeCycleHooks
	LifeCycleHooks map[string]*LifeCycleHook `json:"lifecycle,omitempty"`

	// Maintain a Log to look at what has happened
	Healthy *bool `json:"healthy,omitempty"`

	WaitForHealthy *int `json:"wait_for_healthy,omitempty"`

	// AWS Service is Downloaded
	Services map[string]*Service `json:"services,omitempty"` // Downloaded From S3

	// DetachStrategy can be "Detach"(default) | "SkipDetach" || "SkipDetachCheck"
	DetachStrategy *string `json:"detach_strategy,omitempty"`

	WaitForDetach *int `json:"wait_for_detach,omitempty"`
	// contains filtered or unexported fields
}

Release is the Data Structure passed between Client to Deployer

func MockMinimalRelease

func MockMinimalRelease(t *testing.T) *Release

MockMinimalRelease mocks

func MockRelease

func MockRelease(t *testing.T) *Release

MockRelease mocks

func (*Release) CreateResources

func (release *Release) CreateResources(asgc aws.ASGAPI, cwc aws.CWAPI) error

CreateResources returns

func (*Release) DetachAllASGs

func (release *Release) DetachAllASGs(asgc aws.ASGAPI, asgs []*asg.ASG) error

func (*Release) DetachForFailure

func (release *Release) DetachForFailure(asgc aws.ASGAPI) error

DetachForFailure detach new ASGs

func (*Release) DetachForSuccess

func (release *Release) DetachForSuccess(asgc aws.ASGAPI) error

Success

func (*Release) DownloadUserData

func (release *Release) DownloadUserData(s3c aws.S3API) error

DownloadUserData fetches and populates the User data from S3

func (*Release) FetchResources

func (release *Release) FetchResources(asgc aws.ASGAPI, ec2 aws.EC2API, elbc aws.ELBAPI, albc aws.ALBAPI, iamc aws.IAMAPI, snsc aws.SNSAPI) (*ReleaseResources, error)

FetchResources checks the existence of all Resources references in this release and returns a struct of the resources

func (*Release) IsSkipDetachCheck

func (release *Release) IsSkipDetachCheck() bool

IsSkipDetachStep returns true if we should skip all detach steps

func (*Release) IsSkipDetachStep

func (release *Release) IsSkipDetachStep() bool

IsSkipDetachStep returns true if we should skip all detach steps

func (*Release) ResetDesiredCapacity

func (release *Release) ResetDesiredCapacity(asgc aws.ASGAPI) error

ResetDesiredCapacity resets the ASGs to the desired capacity that would exist without `spread` This is due to a situation where each successive deploy would ratchet up the desired capacity

func (*Release) SetDefaults

func (release *Release) SetDefaults()

SetDefaults assigns default values

func (*Release) SetDefaultsWithUserData

func (release *Release) SetDefaultsWithUserData(s3c aws.S3API) error

SetDefaultsWithUserData sets the default values including userdata fetched from S3

func (*Release) SetUserData

func (release *Release) SetUserData(userdata *string)

SetUserData sets the User data

func (*Release) SuccessfulTearDown

func (release *Release) SuccessfulTearDown(asgc aws.ASGAPI, cwc aws.CWAPI) error

SuccessfulTearDown returns

func (*Release) UnmarshalJSON

func (release *Release) UnmarshalJSON(data []byte) error

UnmarshalJSON should error if there is something unexpected

func (*Release) UnsuccessfulTearDown

func (release *Release) UnsuccessfulTearDown(asgc aws.ASGAPI, cwc aws.CWAPI) error

UnsuccessfulTearDown deletes the services we were trying to create because :(

func (*Release) UpdateHealthy

func (release *Release) UpdateHealthy(asgc aws.ASGAPI, elbc aws.ELBAPI, albc aws.ALBAPI) error

UpdateHealthy will try set the Healthy attribute First Error is a Halting Error, Second Error is a Retry Error

func (*Release) UpdateWithResources

func (release *Release) UpdateWithResources(resources *ReleaseResources)

UpdateWithResources returns

func (*Release) UserData

func (release *Release) UserData() *string

UserData returns user data

func (*Release) UserDataPath

func (release *Release) UserDataPath() *string

UserDataPath returns

func (*Release) Validate

func (release *Release) Validate(s3c aws.S3API) error

Validate returns

func (*Release) ValidateResources

func (release *Release) ValidateResources(resources *ReleaseResources) error

ValidateResources returns

func (*Release) ValidateSafeRelease

func (release *Release) ValidateSafeRelease(s3c aws.S3API, resources *ReleaseResources) error

ValidateSafeRelease will error if the currently deployed release has different: 1. Subnets, or Services Or any service has different: 2. Security Groups or Profile 3. ELBs or Target Groups 4. Instance Type or Autoscaling Preferences 5. EBS information 6. AssociatePublicIpAddress

func (*Release) ValidateServices

func (release *Release) ValidateServices() error

ValidateServices returns

func (*Release) ValidateUserDataSHA

func (release *Release) ValidateUserDataSHA(s3c aws.S3API) error

ValidateUserDataSHA validates the userdata has the correct SHA for the release

type ReleaseResources

type ReleaseResources struct {
	PreviousReleaseID *string
	PreviousASGs      map[string]*asg.ASG
	ServiceResources  map[string]*ServiceResources
}

type SafeReleaseError

type SafeReleaseError struct {
	Subnets        error
	Timeout        error
	AllServices    error
	MissingService error

	Services map[string]*SafeReleaseServiceError
}

func (*SafeReleaseError) Error

func (sre *SafeReleaseError) Error() string

Prints the list of safe release errors

type SafeReleaseServiceError

type SafeReleaseServiceError struct {
	SecurityGroups           error
	Profile                  error
	ELBs                     error
	TargetGroups             error
	EBSVolumeSize            error
	EBSVolumeType            error
	EBSDeviceName            error
	AssociatePublicIpAddress error
	InstanceType             error
	MinSize                  error
	MaxSize                  error
	MaxTerminations          error
	DefaultCooldown          error
	HealthCheckGracePeriod   error
	Spread                   error
}

type Service

type Service struct {

	// Generated
	ServiceName *string `json:"service_name,omitempty"`

	// Find these Resources
	ELBs           []*string          `json:"elbs,omitempty"`
	Profile        *string            `json:"profile,omitempty"`
	TargetGroups   []*string          `json:"target_groups,omitempty"`
	SecurityGroups []*string          `json:"security_groups,omitempty"`
	Tags           map[string]*string `json:"tags,omitempty"`

	// Create Resources
	InstanceType *string            `json:"instance_type,omitempty"`
	Autoscaling  *AutoScalingConfig `json:"autoscaling,omitempty"`
	SpotPrice    *string            `json:"spot_price,omitempty"`

	// EBS
	EBSVolumeSize *int64  `json:"ebs_volume_size,omitempty"`
	EBSVolumeType *string `json:"ebs_volume_type,omitempty"`
	EBSDeviceName *string `json:"ebs_device_name,omitempty"`

	// Placement Group
	PlacementGroupName           *string `json:"placement_group_name,omitempty"`
	PlacementGroupPartitionCount *int64  `json:"placement_group_partition_count,omitempty"`
	PlacementGroupStrategy       *string `json:"placement_group_strategy,omitempty"`

	// Dedicated tenancy or neighbors allowed
	PlacementTenancy *string `json:"placement_tenancy,omitempty"`

	// Network
	AssociatePublicIpAddress *bool `json:"associate_public_ip_address,omitempty"`

	// Found Resources
	Resources *ServiceResourceNames `json:"resources,omitempty"`

	// Created Resources
	CreatedASG              *string `json:"created_asg,omitempty"`
	PreviousDesiredCapacity *int64  `json:"previous_desired_capacity,omitempty"`

	// What is Healthy
	HealthReport *HealthReport `json:"healthy_report,omitempty"`
	Healthy      bool
	// contains filtered or unexported fields
}

Service struct

func (*Service) ConfigName

func (service *Service) ConfigName() *string

ConfigName returns config name

func (*Service) CreateResources

func (service *Service) CreateResources(asgc aws.ASGAPI, cwc aws.CWAPI) error

CreateResources creates the ASG and Launch configuration for the service

func (*Service) CreatedAt

func (service *Service) CreatedAt() *time.Time

CreatedAt returns created at data

func (*Service) FetchResources

func (service *Service) FetchResources(ec2 aws.EC2API, elbc aws.ELBAPI, albc aws.ALBAPI, iamc aws.IAMAPI) (*ServiceResources, error)

FetchResources attempts to retrieve all resources

func (*Service) LifeCycleHookSpecs

func (service *Service) LifeCycleHookSpecs() []*autoscaling.LifecycleHookSpecification

LifeCycleHookSpecs returns

func (*Service) LifeCycleHooks

func (service *Service) LifeCycleHooks() map[string]*LifeCycleHook

LifeCycleHooks returns

func (*Service) Name

func (service *Service) Name() *string

Name service name

func (*Service) ProjectName

func (service *Service) ProjectName() *string

ProjectName returns project name

func (*Service) ReleaseID

func (service *Service) ReleaseID() *string

ReleaseID returns release ID

func (*Service) ReleaseUUID

func (service *Service) ReleaseUUID() *string

ReleaseUUID returns release UUID

func (*Service) ResetDesiredCapacity

func (service *Service) ResetDesiredCapacity(asgc aws.ASGAPI) error

ResetDesiredCapacity sets the min and desired capacities to their final values

func (*Service) SafeSetMinDesiredCapacity

func (service *Service) SafeSetMinDesiredCapacity(asgc aws.ASGAPI, group *asg.ASG, minSize, desiredCapacity int64) error

SafeSetMinDesiredCapacity is a wrapper around SetMinDesiredCapacity which ensures that 1. minSize and desiredCapacity are never lower than the existing group 2. minSize is never higher than desiredCapacity 3. we don't do anything if the values dont change

func (*Service) ServiceID

func (service *Service) ServiceID() *string

ServiceID returns a formatted string of the services ID

func (*Service) SetDefaults

func (service *Service) SetDefaults(release *Release, serviceName string)

SetDefaults assigns default values

func (*Service) SetMinDesiredCapacity

func (service *Service) SetMinDesiredCapacity(asgc aws.ASGAPI, minSize, desiredCapacity *int64) error

func (*Service) SetUserData

func (service *Service) SetUserData(userdata *string)

SetUserData sets the userdata

func (*Service) SubnetIds

func (service *Service) SubnetIds() *string

SubnetIds returns

func (*Service) Subnets

func (service *Service) Subnets() []*string

Subnets returns subnets

func (*Service) UpdateHealthy

func (service *Service) UpdateHealthy(asgc aws.ASGAPI, elbc aws.ELBAPI, albc aws.ALBAPI) error

UpdateHealthy updates the health status of the service This might cause a Halt Error which will force the release to stop

func (*Service) UserData

func (service *Service) UserData() *string

UserData will take the releases template and override

func (*Service) Validate

func (service *Service) Validate() error

Validate validates the service

func (*Service) ValidateAttributes

func (service *Service) ValidateAttributes() error

ValidateAttributes validates attributes

type ServiceResourceNames

type ServiceResourceNames struct {
	Image          *string   `json:"image,omitempty"`
	Profile        *string   `json:"profile_arn,omitempty"`
	PrevASG        *string   `json:"prev_asg_arn,omitempty"`
	SecurityGroups []*string `json:"security_groups,omitempty"`
	ELBs           []*string `json:"elbs,omitempty"`
	TargetGroups   []*string `json:"target_group_arns,omitempty"`
	Subnets        []*string `json:"subnets,omitempty"`
}

ServiceResourceNames struct

type ServiceResources

type ServiceResources struct {
	Image          *ami.Image
	Profile        *iam.Profile
	PrevASG        *asg.ASG
	SecurityGroups []*sg.SecurityGroup
	ELBs           []*elb.LoadBalancer
	TargetGroups   []*alb.TargetGroup
	Subnets        []*subnet.Subnet
}

ServiceResources struct

func (*ServiceResources) ToServiceResourceNames

func (sr *ServiceResources) ToServiceResourceNames() *ServiceResourceNames

ToServiceResourceNames returns

func (*ServiceResources) Validate

func (sr *ServiceResources) Validate(service *Service) error

Validate returns

type Strategy

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

Strategy describes the way in which Odin brings up instances in an Autoscaling Group pulling it out into this struct helps isolate code from the rest of the service

func NewStrategy

func NewStrategy(autoscaling *AutoScalingConfig, previousDesiredCapacity *int64) *Strategy

func (*Strategy) CalculateMinDesired

func (strategy *Strategy) CalculateMinDesired(instances aws.Instances) (int64, int64)

func (*Strategy) DesiredCapacity

func (strategy *Strategy) DesiredCapacity() int64

DesiredCapacity is the REAL amount of instances we want. This is later altered for practicality by spread

func (*Strategy) InitialDesiredCapacity

func (strategy *Strategy) InitialDesiredCapacity() *int64

func (*Strategy) InitialMinSize

func (strategy *Strategy) InitialMinSize() *int64

func (*Strategy) ReachedMaxTerminations

func (strategy *Strategy) ReachedMaxTerminations(instances aws.Instances) bool

func (*Strategy) TargetCapacity

func (strategy *Strategy) TargetCapacity() int64

TargetCapacity is the number of launched instances including the spread

func (*Strategy) TargetHealthy

func (strategy *Strategy) TargetHealthy() int64

TargetHealthy is the number of instances the service needs to be Healthy

type StrategyType

type StrategyType string

type XRelease

type XRelease Release

The goal here is to raise an error if a key is sent that is not supported. This should stop many dangerous problems, like misspelling a parameter.

type XReleaseExceptions

type XReleaseExceptions struct {
	XRelease
	Task *string // Do not include the Task because that can be implemented
}

But the problem is that there are exceptions that we have

Jump to

Keyboard shortcuts

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