This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update server with nri injection points
This allows development with container to be done for NRI without the need for custom builds. This is an experimental feature and is not enabled unless a user has a global `/etc/nri/conf.json` config setup with plugins on the system. No NRI code will be executed if this config file does not exist. Signed-off-by: Michael Crosby <michael@thepasture.io>
- Loading branch information
1 parent
b777982
commit fbd5faa
Showing
4 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
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
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,51 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package server | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/containerd/containerd" | ||
"github.com/containerd/containerd/log" | ||
"github.com/containerd/nri" | ||
v1 "github.com/containerd/nri/types/v1" | ||
) | ||
|
||
// WithNRISandboxDelete calls delete for a sandbox'd task | ||
func WithNRISandboxDelete(sandboxID string) containerd.ProcessDeleteOpts { | ||
return func(ctx context.Context, p containerd.Process) error { | ||
task, ok := p.(containerd.Task) | ||
if !ok { | ||
return nil | ||
} | ||
nric, err := nri.New() | ||
if err != nil { | ||
log.G(ctx).WithError(err).Error("unable to create nri client") | ||
return nil | ||
} | ||
if nric == nil { | ||
return nil | ||
} | ||
sb := &nri.Sandbox{ | ||
ID: sandboxID, | ||
} | ||
if _, err := nric.InvokeWithSandbox(ctx, task, v1.Delete, sb); err != nil { | ||
log.G(ctx).WithError(err).Errorf("Failed to delete nri for %q", task.ID()) | ||
} | ||
return nil | ||
} | ||
} |
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