-
Notifications
You must be signed in to change notification settings - Fork 838
Register the connector-service (webapi) plugin in the Flyte 2 executor #7565
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
Open
dejanzele
wants to merge
3
commits into
flyteorg:main
Choose a base branch
from
dejanzele:armada
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,45 @@ | ||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| pluginsCore "github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/pluginmachinery/core" | ||
| ) | ||
|
|
||
| // The webapi plugin machinery requires the host to supply a ResourceRegistrar at plugin setup and a | ||
| // ResourceManager at task execution, for its allocation-token quota feature. FlytePropeller (v1) | ||
| // always supplied them, defaulting to a no-op manager when no quota backend is configured. The v2 | ||
| // executor never reimplemented this, so a webapi plugin that declares ResourceQuotas dereferences a | ||
| // nil registrar or manager. These no-op types restore the contract and grant every allocation. Swap | ||
| // in a real ResourceManager to enforce quotas without touching any plugin. | ||
|
|
||
| // noopResourceRegistrar accepts quota registrations without recording them. | ||
| type noopResourceRegistrar struct{} | ||
|
|
||
| var _ pluginsCore.ResourceRegistrar = noopResourceRegistrar{} | ||
|
|
||
| func (noopResourceRegistrar) RegisterResourceQuota(_ context.Context, _ pluginsCore.ResourceNamespace, _ int) error { | ||
| return nil | ||
| } | ||
|
|
||
| // noopResourceManager grants every allocation request and ignores releases. | ||
| type noopResourceManager struct{} | ||
|
|
||
| var _ pluginsCore.ResourceManager = noopResourceManager{} | ||
|
|
||
| func (noopResourceManager) GetID() string { return "executor-noop-resource-manager" } | ||
|
|
||
| func (noopResourceManager) AllocateResource(_ context.Context, _ pluginsCore.ResourceNamespace, _ string, _ pluginsCore.ResourceConstraintsSpec) (pluginsCore.AllocationStatus, error) { | ||
| return pluginsCore.AllocationStatusGranted, nil | ||
| } | ||
|
|
||
| func (noopResourceManager) ReleaseResource(_ context.Context, _ pluginsCore.ResourceNamespace, _ string) error { | ||
| return nil | ||
| } | ||
|
|
||
| // NewNoopResourceRegistrar returns a ResourceRegistrar that accepts quota declarations without | ||
| // enforcing them. | ||
| func NewNoopResourceRegistrar() pluginsCore.ResourceRegistrar { return noopResourceRegistrar{} } | ||
|
|
||
| // NewNoopResourceManager returns a ResourceManager that grants every allocation. | ||
| func NewNoopResourceManager() pluginsCore.ResourceManager { return noopResourceManager{} } |
This file contains hidden or 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,30 @@ | ||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
|
|
||
| pluginsCore "github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/pluginmachinery/core" | ||
| ) | ||
|
|
||
| func TestNoopResourceRegistrar(t *testing.T) { | ||
| r := NewNoopResourceRegistrar() | ||
| assert.NotNil(t, r) | ||
| // Accepts a quota declaration (the connector ships ResourceQuotas{"default":1000}) without error. | ||
| assert.NoError(t, r.RegisterResourceQuota(context.Background(), "default", 1000)) | ||
| } | ||
|
|
||
| func TestNoopResourceManager(t *testing.T) { | ||
| m := NewNoopResourceManager() | ||
| assert.NotNil(t, m) | ||
| assert.Equal(t, "executor-noop-resource-manager", m.GetID()) | ||
|
|
||
| // Every allocation is granted, matching v1 propeller with no quota backend configured. | ||
| status, err := m.AllocateResource(context.Background(), "default", "token", pluginsCore.ResourceConstraintsSpec{}) | ||
| assert.NoError(t, err) | ||
| assert.Equal(t, pluginsCore.AllocationStatusGranted, status) | ||
|
|
||
| assert.NoError(t, m.ReleaseResource(context.Background(), "default", "token")) | ||
| } |
This file contains hidden or 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,25 @@ | ||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| pluginsCore "github.com/flyteorg/flyte/v2/flyteplugins/go/tasks/pluginmachinery/core" | ||
| ) | ||
|
|
||
| // The webapi plugin machinery resolves task secrets through a SecretManager supplied by the host, at | ||
| // both plugin setup and task execution. The v2 executor never wired one up, so a connector task that | ||
| // references a secret dereferences a nil SecretManager and panics. This no-op restores the contract. | ||
| // It has no secret backend, so Get fails loudly with an error rather than handing a task a blank | ||
| // value. Swap in a real SecretManager to resolve secrets. | ||
| type noopSecretManager struct{} | ||
|
|
||
| var _ pluginsCore.SecretManager = noopSecretManager{} | ||
|
|
||
| func (noopSecretManager) Get(_ context.Context, key string) (string, error) { | ||
| return "", fmt.Errorf("secrets are not supported by the executor's no-op secret manager, cannot resolve %q", key) | ||
| } | ||
|
|
||
| // NewNoopSecretManager returns a SecretManager with no backend that fails every lookup with a clear | ||
| // error, so a connector task referencing a secret does not silently receive an empty value. | ||
| func NewNoopSecretManager() pluginsCore.SecretManager { return noopSecretManager{} } |
This file contains hidden or 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,19 @@ | ||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestNoopSecretManager(t *testing.T) { | ||
| m := NewNoopSecretManager() | ||
| assert.NotNil(t, m) | ||
|
|
||
| // No backend: a lookup fails with an error instead of returning an empty secret, so a connector | ||
| // task that references a secret fails loudly rather than running with a blank value. | ||
| val, err := m.Get(context.Background(), "my-secret") | ||
| assert.Error(t, err) | ||
| assert.Empty(t, val) | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.