Skip to content

Commit

Permalink
mvp add ttl
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Christoff <[email protected]>
  • Loading branch information
schristoff committed Jul 12, 2023
1 parent 6306b6f commit 9930cc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions api/v1/agentconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ type AgentConfigSpec struct {
// +optional
VolumeSize string `json:"volumeSize,omitempty" mapstructure:"volumeSize,omitempty"`

// TTLSecondsAfterFinished mechanism to limit the lifetime of Job
// objects that have finished execution.
// todo(schristoff): update that ^
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty" mapstructure:"ttlSecondsAftterFinished,omitempty"`

// PullPolicy specifies when to pull the Porter Agent image. The default
// is to use PullAlways when the tag is canary or latest, and PullIfNotPresent
// otherwise.
Expand Down Expand Up @@ -346,6 +351,12 @@ func (c AgentConfigSpecAdapter) ToPorterDocument() ([]byte, error) {
return yaml.Marshal(raw)
}

// GetTTL
// todo(schristoff): comment and prob should set sane defaults?
func (c AgentConfigSpecAdapter) GetTTLSecondsAfterFinished() *int32 {
return c.original.TTLSecondsAfterFinished

Check warning on line 357 in api/v1/agentconfig_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1/agentconfig_types.go#L357

Added line #L357 was not covered by tests
}

// PluginConfigList is the list implementation of the Plugins map.
// The list is sorted based on the plugin names alphabetically.
type PluginsConfigList struct {
Expand Down
5 changes: 3 additions & 2 deletions controllers/agentaction_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,9 @@ func (r *AgentActionReconciler) createAgentJob(ctx context.Context, log logr.Log
},
},
Spec: batchv1.JobSpec{
Completions: pointer.Int32(1),
BackoffLimit: agentCfg.GetRetryLimit(),
Completions: pointer.Int32(1),
BackoffLimit: agentCfg.GetRetryLimit(),
TTLSecondsAfterFinished: agentCfg.GetTTLSecondsAfterFinished(),
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
GenerateName: action.Name + "-",
Expand Down

0 comments on commit 9930cc5

Please sign in to comment.