-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build SparkApplicationSpec using ToK8sPodSpec
Signed-off-by: Andrew Dye <[email protected]>
- Loading branch information
1 parent
4a780c3
commit b326791
Showing
5 changed files
with
384 additions
and
193 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
flyteplugins/go/tasks/pluginmachinery/flytek8s/non_interruptible.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package flytek8s | ||
|
||
import ( | ||
v1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
|
||
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" | ||
pluginsCore "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" | ||
) | ||
|
||
// Wraps a regular TaskExecutionMetadata and overrides the IsInterruptible method to always return false | ||
// This is useful as the runner and the scheduler pods should never be interruptible | ||
type NonInterruptibleTaskExecutionMetadata struct { | ||
metadata pluginsCore.TaskExecutionMetadata | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetOwnerID() types.NamespacedName { | ||
return n.metadata.GetOwnerID() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetTaskExecutionID() pluginsCore.TaskExecutionID { | ||
return n.metadata.GetTaskExecutionID() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetNamespace() string { | ||
return n.metadata.GetNamespace() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetOwnerReference() metav1.OwnerReference { | ||
return n.metadata.GetOwnerReference() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetOverrides() pluginsCore.TaskOverrides { | ||
return n.metadata.GetOverrides() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetLabels() map[string]string { | ||
return n.metadata.GetLabels() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetMaxAttempts() uint32 { | ||
return n.metadata.GetMaxAttempts() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetAnnotations() map[string]string { | ||
return n.metadata.GetAnnotations() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetK8sServiceAccount() string { | ||
return n.metadata.GetK8sServiceAccount() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetSecurityContext() core.SecurityContext { | ||
return n.metadata.GetSecurityContext() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetPlatformResources() *v1.ResourceRequirements { | ||
return n.metadata.GetPlatformResources() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetInterruptibleFailureThreshold() int32 { | ||
return n.metadata.GetInterruptibleFailureThreshold() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) GetEnvironmentVariables() map[string]string { | ||
return n.metadata.GetEnvironmentVariables() | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionMetadata) IsInterruptible() bool { | ||
return false | ||
} | ||
|
||
// A wrapper around a regular TaskExecutionContext allowing to inject a custom TaskExecutionMetadata which is | ||
// non-interruptible | ||
type NonInterruptibleTaskExecutionContext struct { | ||
pluginsCore.TaskExecutionContext | ||
metadata NonInterruptibleTaskExecutionMetadata | ||
} | ||
|
||
func (n NonInterruptibleTaskExecutionContext) TaskExecutionMetadata() pluginsCore.TaskExecutionMetadata { | ||
return n.metadata | ||
} | ||
|
||
func NewNonInterruptibleTaskExecutionContext(ctx pluginsCore.TaskExecutionContext) NonInterruptibleTaskExecutionContext { | ||
return NonInterruptibleTaskExecutionContext{ | ||
TaskExecutionContext: ctx, | ||
metadata: NonInterruptibleTaskExecutionMetadata{ | ||
metadata: ctx.TaskExecutionMetadata(), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.