audit

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const CurrentSchemaVersion int = 1

Variables

This section is empty.

Functions

func NewDaemonSetDetails

func NewDaemonSetDetails(ds fields.DaemonSet, user string) (json.RawMessage, error)

func NewNodeTransferCompletionDetails

func NewNodeTransferCompletionDetails(
	nodeTransferID rcstatus.NodeTransferID,
	rcID rcfields.ID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	nodeSelector klabels.Selector,
	oldNode types.NodeName,
	newNode types.NodeName,
	replicaCount int,
) (json.RawMessage, error)

func NewNodeTransferRollbackDetails

func NewNodeTransferRollbackDetails(
	nodeTransferID rcstatus.NodeTransferID,
	rcID rcfields.ID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	nodeSelector klabels.Selector,
	oldNode types.NodeName,
	newNode types.NodeName,
	replicaCount int,
	rollbackReason RollbackReason,
) (json.RawMessage, error)

func NewNodeTransferStartDetails

func NewNodeTransferStartDetails(
	nodeTransferID rcstatus.NodeTransferID,
	rcID rcfields.ID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	nodeSelector klabels.Selector,
	oldNode types.NodeName,
	newNode types.NodeName,
	replicaCount int,
) (json.RawMessage, error)

func NewP2BalancerCompletionDetails

func NewP2BalancerCompletionDetails(
	podTransferID PodTransferID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	oldNode types.NodeName,
	newNode types.NodeName,
) (json.RawMessage, error)

func NewP2BalancerFailureDetails

func NewP2BalancerFailureDetails(
	podTransferID PodTransferID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	oldNode types.NodeName,
	newNode types.NodeName,
	errorMessage P2BalancerErrorMessage,
) (json.RawMessage, error)

func NewP2BalancerInProgressDetails

func NewP2BalancerInProgressDetails(
	podTransferID PodTransferID,
	podID types.PodID,
	availabilityZone pcfields.AvailabilityZone,
	clusterName pcfields.ClusterName,
	oldNode types.NodeName,
	newNode types.NodeName,
) (json.RawMessage, error)

func NewRCRetargetingEventDetails

func NewRCRetargetingEventDetails(
	podID types.PodID,
	az pc_fields.AvailabilityZone,
	name pc_fields.ClusterName,
	nodes []types.NodeName,
) (json.RawMessage, error)

func NewRUCompletionEventDetails

func NewRUCompletionEventDetails(
	rollingUpdateID roll_fields.ID,
	succeeded bool,
	canceled bool,
	labeler Labeler,
) (json.RawMessage, error)

func NewRUCreationEventDetails

func NewRUCreationEventDetails(
	podID types.PodID,
	az pc_fields.AvailabilityZone,
	name pc_fields.ClusterName,
	deployer string,
	manifest manifest.Manifest,
	rollingUpdateID roll_fields.ID,
) (json.RawMessage, error)

Types

type AuditLog

type AuditLog struct {
	EventType     EventType        `json:"event_type"`
	EventDetails  *json.RawMessage `json:"event_details"`
	Timestamp     time.Time        `json:"timestamp"`
	SchemaVersion SchemaVersion    `json:"schema_version"`
}

AuditLog represents a stored value in consul expressing an event for which audit records are desired. An AuditLog consists of an event type, a json message with details which will have a different schema for each event type, a timestamp and a schema version.

type CommonNodeTransferDetails

type CommonNodeTransferDetails struct {
	// NodeTransferID is a uuid that will be the same for all audit log records
	// associated with the same node transfer.  It can be used to match up
	// "start" events with "rollback" or "completion" events
	NodeTransferID rcstatus.NodeTransferID `json:"node_transfer_id"`

	// ReplicationControllerID is the ID of the replication controller that
	// started the node transfer
	ReplicationControllerID rcfields.ID `json:"replication_controller_id"`

	// PodID denotes the pod ID of the pod cluster that the RC belongs to
	PodID types.PodID `json:"pod_id"`

	// AvailabilityZone is the availability zone of the pod cluster that
	// the RC belongs to
	AvailabilityZone pcfields.AvailabilityZone `json:"availability_zone"`

	// ClusterName is the name of the pod cluster that the RC belongs to
	ClusterName pcfields.ClusterName `json:"cluster_name"`

	// RCNodeSelector is the node selector the RC had when the event was
	// created.  This is a klabels.Selector represented as a string because
	// that type does not cleanly marshal into JSON without some tricks
	RCNodeSelector string `json:"replication_controller_node_selector"`

	// OldNode denotes the node that is no longer eligible and should have
	// its pod transferred off of it
	OldNode types.NodeName `json:"old_node"`

	// NewNode denotes the node returned by the scheduler to which a pod is
	// being transferred
	NewNode types.NodeName `json:"new_node"`

	// ReplicaCount denotes the replica count of the RC at the time the
	// node transfer was started
	ReplicaCount int `json:"replica_count"`
}

type CommonP2BalancerDetails

type CommonP2BalancerDetails struct {
	// PodTransferID is a uuid that will be the same for all audit log records
	// associated with the same pod transfer. It can be used to match up
	// "start" events with "failure" or "completion" events
	PodTransferID PodTransferID `json:"pod_transfer_id"`

	// PodID denotes the pod ID of the pod cluster that the RC belongs to
	PodID types.PodID `json:"pod_id"`

	// AvailabilityZone is the availability zone of the pod cluster that
	// the RC belongs to
	AvailabilityZone pcfields.AvailabilityZone `json:"availability_zone"`

	// ClusterName is the name of the pod cluster that the RC belongs to
	ClusterName pcfields.ClusterName `json:"cluster_name"`

	// OldNode denotes the node that is above healthy threshold
	// and needs a pod moved off of it
	OldNode types.NodeName `json:"old_node"`

	// NewNode denotes the node that has resource capacity for a pod to be moved onto it
	NewNode types.NodeName `json:"new_node"`
}

type DSEventDetails

type DSEventDetails struct {
	// DaemonSet is the daemon set that resulted from the event (e.g. after
	// the update was applied) for all event types other than deletions. In
	// the case of deletions, it will be the contents of the daemon set
	// BEFORE deletion
	DaemonSet fields.DaemonSet `json:"daemon_set"`

	// User represents the name of the user who executed the action to
	// which the event record pertains
	User string `json:"user"`
}

DsEventDetails defines a JSON structure for the details related to a daemon set event. For now the schema is the same for every event type but this may change in the future

type EventType

type EventType string
const (
	// DSCreatedEvent signifies that the daemon set was created.
	DSCreatedEvent EventType = "DAEMON_SET_CREATED"

	// DSManifestUpdatedEvent signifies that the daemon set had its pod
	// manifest modified. This typically kicks off a replication to update
	// the manifests for all the nodes matched by the daemon set's node
	// selector
	DSManifestUpdatedEvent EventType = "DAEMON_SET_MANIFEST_UPDATED"

	// DSNodeSelectorUpdatedEvent signifies that the node selector of the
	// daemon set was changed. This will result in adding the daemon set's
	// pod manifest to new nodes that are matched, or removing it from
	// nodes that are no longer matched.
	DSNodeSelectorUpdatedEvent EventType = "DAEMON_SET_NODE_SELECTOR_UPDATED"

	// DSDeletedEvent signifies that the daemon set was deleted
	DSDeletedEvent EventType = "DAEMON_SET_DELETED"

	// DSEnabledEvent signifies that the daemon set was enabled. This might
	// kick off a manifest update to the nodes matched by the daemon set's
	// manifest
	DSEnabledEvent EventType = "DAEMON_SET_ENABLED"

	// DSEnabledEvent signifies that the daemon set was enabled. This might
	// pause a manifest update to the nodes matched by the daemon set's
	// manifest
	DSDisabledEvent EventType = "DAEMON_SET_DISABLED"

	// DSModifiedEvent signifies an update to the daemon set that doesn't
	// fit in any of the other event types. For example, changing the
	// timeout value will result in an event of this type (because it's
	// neither a manifest or "disabled" update)
	DSModifiedEvent EventType = "DAEMON_SET_MODIFIED"
)
const (
	// NodeTransferStartEvent denotes the start of a node transfer
	NodeTransferStartEvent EventType = "NODE_TRANSFER_START"

	// NodeTransferCompletionEvent denotes the successful completion of a
	// node transfer
	NodeTransferCompletionEvent EventType = "NODE_TRANSFER_COMPLETION"

	// NodeTransferRollbackEvent denotes a node transfer being rolled back
	// due to unrecoverable errors or cancellation
	NodeTransferRollbackEvent EventType = "NODE_TRANSFER_ROLLBACK"
)
const (
	// P2BalancerInProgressEvent denotes the start of a P2 Balancer pod move
	P2BalancerInProgressEvent EventType = "P2_BALANCER_START"

	// P2BalancerCompletionEvent denotes the successful completion of a
	// pod move
	P2BalancerCompletionEvent EventType = "P2_BALANCER_COMPLETION"

	// P2BalancerFailureEvent denotes a pod move failure due
	// to unrecoverable errors
	P2BalancerFailureEvent EventType = "P2_BALANCER_FAILURE"
)
const (
	RUCreationEvent   EventType = "ROLLING_UPDATE_CREATION"
	RUCompletionEvent EventType = "ROLLING_UPDATE_COMPLETION"
)
const (
	// RcRetargetingEvent represents events in which an RC changes the set of
	// nodes that it is targeting. This can be used to log the set of nodes that
	// an RC or pod cluster manages over time
	RCRetargetingEvent EventType = "REPLICATION_CONTROLLER_RETARGET"
)

func (EventType) String

func (e EventType) String() string

type ID

type ID string

func (ID) String

func (i ID) String() string

type Labeler

type Labeler interface {
	GetLabels(labelType labels.Type, id string) (labels.Labeled, error)
}

type NodeTransferCompletionDetails

type NodeTransferCompletionDetails struct {
	CommonNodeTransferDetails
}

type NodeTransferRollbackDetails

type NodeTransferRollbackDetails struct {
	CommonNodeTransferDetails

	// RollbackReason indicates why the node transfer was rolled back
	RollbackReason RollbackReason `json:"rollback_reason"`
}

type NodeTransferStartDetails

type NodeTransferStartDetails struct {
	CommonNodeTransferDetails
}

type P2BalancerCompletionDetails

type P2BalancerCompletionDetails struct {
	CommonP2BalancerDetails
}

type P2BalancerErrorMessage

type P2BalancerErrorMessage string

type P2BalancerFailureDetails

type P2BalancerFailureDetails struct {
	CommonP2BalancerDetails

	// This will be set to the error message at the point of failure
	ErrorMessage P2BalancerErrorMessage `json:"error_message"`
}

type P2BalancerInProgressDetails

type P2BalancerInProgressDetails struct {
	CommonP2BalancerDetails
}

type PodTransferID

type PodTransferID string

type RCRetargetingDetails

type RCRetargetingDetails struct {
	PodID            types.PodID                `json:"pod_id"`
	AvailabilityZone pc_fields.AvailabilityZone `json:"availability_zone"`
	ClusterName      pc_fields.ClusterName      `json:"cluster_name"`
	Nodes            []types.NodeName           `json:"nodes"`
}

type RUCompletionDetails

type RUCompletionDetails struct {
	PodID            types.PodID                `json:"pod_id"`
	AvailabilityZone pc_fields.AvailabilityZone `json:"availability_zone"`
	ClusterName      pc_fields.ClusterName      `json:"cluster_name"`
	RollingUpdateID  roll_fields.ID             `json:"rolling_update_id"`
	Succeeded        bool                       `json:"succeeded"`
	Canceled         bool                       `json:"canceled"`
}

type RUCreationDetails

type RUCreationDetails struct {
	PodID            types.PodID                `json:"pod_id"`
	AvailabilityZone pc_fields.AvailabilityZone `json:"availability_zone"`
	ClusterName      pc_fields.ClusterName      `json:"cluster_name"`
	Deployer         string                     `json:"deployer"`
	Manifest         string                     `json:"manifest"`
	RollingUpdateID  roll_fields.ID             `json:"rolling_update_id"`
}

type RollbackReason

type RollbackReason string

type SchemaVersion

type SchemaVersion int

func (SchemaVersion) Int

func (s SchemaVersion) Int() int

func (SchemaVersion) MarshalJSON

func (s SchemaVersion) MarshalJSON() ([]byte, error)

SchemaVersion implements MarshalJSON() so that every JSON representation of AuditLog has the correct schema version, even if the AuditLog struct has a different value set when it is marshaled

Jump to

Keyboard shortcuts

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