Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Remove sys_ptrace dependency #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/containerwatcher/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ const (
// Uses a success file to determine if the container has completed.
// CAUTION: Does not work if the container exits because of OOM, etc
WatcherTypeFile WatcherType = "file"
// Uses Kube 1.17 feature - https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/
// To look for pid in the shared namespace.
WatcherTypeSharedProcessNS WatcherType = "shared-process-ns"
// Dummy watcher. Exits immediately, assuming success
WatcherTypeNoop WatcherType = "noop"
)

var AllWatcherTypes = []WatcherType{
WatcherTypeKubeAPI,
WatcherTypeSharedProcessNS,
WatcherTypeFile,
WatcherTypeNoop,
}
133 changes: 0 additions & 133 deletions cmd/containerwatcher/spns_watcher.go

This file was deleted.

34 changes: 18 additions & 16 deletions cmd/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ type UploadOptions struct {
// Local directory path where the sidecar should look for outputs.
localDirectoryPath string
// Non primitive types will be dumped in this output format
metadataFormat string
uploadMode string
timeout time.Duration
containerStartTimeout time.Duration
typedInterface []byte
startWatcherType containerwatcher.WatcherType
exitWatcherType containerwatcher.WatcherType
containerInfo containerwatcher.ContainerInformation
metadataFormat string
uploadMode string
timeout time.Duration
containerStartTimeout time.Duration
containerFinishTimeout time.Duration
typedInterface []byte
startWatcherType containerwatcher.WatcherType
exitWatcherType containerwatcher.WatcherType
containerInfo containerwatcher.ContainerInformation
}

func (u *UploadOptions) createWatcher(ctx context.Context, w containerwatcher.WatcherType) (containerwatcher.Watcher, error) {
Expand All @@ -51,8 +52,6 @@ func (u *UploadOptions) createWatcher(ctx context.Context, w containerwatcher.Wa
return containerwatcher.NewKubeAPIWatcher(ctx, u.RootOptions.kubeClient.CoreV1(), u.containerInfo)
case containerwatcher.WatcherTypeFile:
return containerwatcher.NewSuccessFileWatcher(ctx, u.localDirectoryPath, StartFile, SuccessFile, ErrorFile)
case containerwatcher.WatcherTypeSharedProcessNS:
return containerwatcher.NewSharedProcessNSWatcher(ctx, time.Second*2, 2)
case containerwatcher.WatcherTypeNoop:
return containerwatcher.NoopWatcher{}, nil
}
Expand Down Expand Up @@ -113,9 +112,11 @@ func (u *UploadOptions) uploader(ctx context.Context) error {
}
}

logger.Infof(ctx, "Waiting for Container to exit.")
if err := w.WaitToExit(ctx); err != nil {
logger.Errorf(ctx, "Failed waiting for container to exit. Err: %s", err)
logger.Infof(ctx, "Waiting for Container to complete with timeout %s.", u.containerFinishTimeout)
childCtx, cancelFn = context.WithTimeout(ctx, u.containerFinishTimeout)
defer cancelFn()
err = w.WaitToExit(childCtx)
if err != nil && err != containerwatcher.ErrTimeout {
return err
}

Expand Down Expand Up @@ -161,7 +162,7 @@ func NewUploadCommand(opts *RootOptions) *cobra.Command {
// deleteCmd represents the delete command
uploadCmd := &cobra.Command{
Use: "sidecar <opts>",
Short: "uploads flyteData from the localpath to a remote dir.",
Short: "uploads flyteData from the local path to a remote dir.",
Long: `Currently it looks at the outputs.pb and creates one file per variable.`,
RunE: func(cmd *cobra.Command, args []string) error {
return uploadOptions.Sidecar(context.Background())
Expand All @@ -177,8 +178,9 @@ func NewUploadCommand(opts *RootOptions) *cobra.Command {
uploadCmd.Flags().DurationVarP(&uploadOptions.timeout, "timeout", "t", time.Hour*1, "Max time to allow for uploads to complete, default is 1H")
uploadCmd.Flags().BytesBase64VarP(&uploadOptions.typedInterface, "interface", "i", nil, "Typed Interface - core.TypedInterface, base64 encoded string of the serialized protobuf")
uploadCmd.Flags().DurationVarP(&uploadOptions.containerStartTimeout, "start-timeout", "", 0, "Max time to allow for container to startup. 0 indicates wait for ever.")
uploadCmd.Flags().StringVarP(&uploadOptions.startWatcherType, "start-watcher-type", "", containerwatcher.WatcherTypeSharedProcessNS, fmt.Sprintf("Sidecar will wait for container before starting upload process. Watcher type makes the type configurable. Available Type %+v", containerwatcher.AllWatcherTypes))
uploadCmd.Flags().StringVarP(&uploadOptions.exitWatcherType, "exit-watcher-type", "", containerwatcher.WatcherTypeSharedProcessNS, fmt.Sprintf("Sidecar will wait for completion of the container before starting upload process. Watcher type makes the type configurable. Available Type %+v", containerwatcher.AllWatcherTypes))
uploadCmd.Flags().DurationVarP(&uploadOptions.containerFinishTimeout, "finish-timeout", "", time.Hour*24, "Max time to allow for container to execute. 0 indicates wait for ever.")
uploadCmd.Flags().StringVarP(&uploadOptions.startWatcherType, "start-watcher-type", "", containerwatcher.WatcherTypeFile, fmt.Sprintf("Sidecar will wait for container before starting upload process. Watcher type makes the type configurable. Available Type %+v", containerwatcher.AllWatcherTypes))
uploadCmd.Flags().StringVarP(&uploadOptions.exitWatcherType, "exit-watcher-type", "", containerwatcher.WatcherTypeFile, fmt.Sprintf("Sidecar will wait for completion of the container before starting upload process. Watcher type makes the type configurable. Available Type %+v", containerwatcher.AllWatcherTypes))
uploadCmd.Flags().StringVarP(&uploadOptions.containerInfo.Name, "watch-container", "", "", "For KubeAPI watcher, Wait for this container to exit.")
uploadCmd.Flags().StringVarP(&uploadOptions.containerInfo.Namespace, "namespace", "", "", "For KubeAPI watcher, Namespace of the pod [optional]")
uploadCmd.Flags().StringVarP(&uploadOptions.containerInfo.Name, "pod-name", "", "", "For KubeAPI watcher, Name of the pod [optional].")
Expand Down