Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stale "prestart" branch in repository #56

Open
thaJeztah opened this issue Sep 22, 2023 · 0 comments
Open

stale "prestart" branch in repository #56

thaJeztah opened this issue Sep 22, 2023 · 0 comments

Comments

@thaJeztah
Copy link
Member

thaJeztah commented Sep 22, 2023

I just noticed there's a stale prestart branch in this repository; AFAICS, it contains a single commit that's not in main (main...prestart (patch below)) created by @crosbymichael

Do we know

  • if that branch / commit was ever used anywhere outside of this repository (so commit-she needs to be preserved somehow?)
  • is it part of ongoing work that was never finished?
  • Or can it be removed altogether (not worth keeping)?

@crosbymichael (👋 👋 ) perhaps you recall?

197b471

From 197b471dec087c78c80300bc51c64ad06a88c018 Mon Sep 17 00:00:00 2001
From: Michael Crosby <[email protected]>
Date: Wed, 2 Sep 2020 04:32:00 -0400
Subject: [PATCH] Add precreate state and invoke func

Signed-off-by: Michael Crosby <[email protected]>
---
 client.go         | 35 +++++++++++++++++++++++++++++++++++
 types/v1/types.go |  3 +++
 2 files changed, 38 insertions(+)

diff --git a/client.go b/client.go
index 6b6c6e40..8c54064f 100644
--- a/client.go
+++ b/client.go
@@ -50,6 +50,41 @@ type Sandbox struct {
 	Labels map[string]string
 }
 
+// InvokePre the ConfList of nri plugins before a runtime object has been created.
+func (c *Client) InvokePre(ctx context.Context, container containerd.Container, sandbox *Sandbox) ([]*types.Result, error) {
+	if len(c.conf.Plugins) == 0 {
+		return nil, nil
+	}
+	spec, err := container.Spec(ctx)
+	if err != nil {
+		return nil, err
+	}
+	rs, err := createSpec(spec)
+	if err != nil {
+		return nil, err
+	}
+	r := &types.Request{
+		Version: c.conf.Version,
+		ID:      container.ID(),
+		Pid:     -1,
+		State:   types.PreCreate,
+		Spec:    rs,
+	}
+	if sandbox != nil {
+		r.SandboxID = sandbox.ID
+		r.Labels = sandbox.Labels
+	}
+	for _, p := range c.conf.Plugins {
+		r.Conf = p.Conf
+		result, err := c.invokePlugin(ctx, p.Type, r)
+		if err != nil {
+			return nil, errors.Wrapf(err, "plugin: %s", p.Type)
+		}
+		r.Results = append(r.Results, result)
+	}
+	return r.Results, nil
+}
+
 // Invoke the ConfList of nri plugins
 func (c *Client) Invoke(ctx context.Context, task containerd.Task, state types.State) ([]*types.Result, error) {
 	return c.InvokeWithSandbox(ctx, task, state, nil)
diff --git a/types/v1/types.go b/types/v1/types.go
index e0703f5a..3dbbd16d 100644
--- a/types/v1/types.go
+++ b/types/v1/types.go
@@ -41,6 +41,9 @@ type Spec struct {
 type State string
 
 const (
+	// PreCreate happens before any runtime tasks are created
+	// from the calling runtime/process
+	PreCreate State = "pre-create"
 	// Create the initial resource for the container
 	Create State = "create"
 	// Delete any resources for the container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant