Skip to content

fpga: make admission webhook mode-less #358

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

Merged
merged 4 commits into from
May 5, 2020

Conversation

rojkov
Copy link
Contributor

@rojkov rojkov commented Apr 6, 2020

closes #301

@bart0sh
Copy link
Member

bart0sh commented Apr 9, 2020

@rojkov looks good to me so far. What about kustomise yamls? Do they need to be updated?

@kad can you review this PR please?

@rojkov
Copy link
Contributor Author

rojkov commented Apr 9, 2020

@rojkov looks good to me so far. What about kustomise yamls? Do they need to be updated?

Yes. There's #318 for that.

@rojkov
Copy link
Contributor Author

rojkov commented Apr 14, 2020

@kad ping. Could you please review the updates to README.md at least?

kad
kad previously approved these changes Apr 14, 2020
Copy link
Member

@kad kad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits, otherwise LGTM

@@ -20,3 +20,9 @@ spec:
afuId:
type: string
pattern: '^[0-9a-f]{8,128}$'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this might be overkill. we don't expect such long UUIDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limited to 32.

is the first 31 characters of the region interface ID for Arria10 with DCP1.1
firmware. The next 32 characters (`d8424dc4a4a3c413f89e433683f9040b`) is an accelerator function ID.

The same mapping, but with its mode field set to `orchestrated`, translates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "orchestrated" might be not the best choice of the terminology here for cluster admin UX, but I don't have right now better word. Also, it might be good idea to accept "pre-programmed" as alias to "programmed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm.. dunno. "programmed" can be read as "just in time programmed" aka orchestrated.
Maybe "static" and "dynamic"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it might be good idea to accept "pre-programmed" as alias to "programmed"

(This meant to say accept both pre-programmed and preprogrammed?)

Maybe "static" and "dynamic"

this would work, IMO, but it might be good to start using "programming mode" in documentation where we just say only "mode" today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked the docs, there's no place where just "mode" is mentioned. But in fpga_plugin's README.md af and preprogrammed are used interchangeably. The same with region and orchestrated. And "orchestration programmed" is an alias for orchestrated.

Probably we could rename pregrogrammed and af to static; orchestrated and region - to dynamic; regiondevel - to just devel. Also I'd avoid accepting aliases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep using 'region' and 'af' modes in order not to break compatibility with the currently used plugin modes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bart0sh Yes, that's correct. I've added 03b815c. Could you check if it's clearer now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's correct now. Thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rojkov As for mode name I think we can continue using 'af' and 'region' as we got rid of webhook mode names 'preprogrammed' and 'orchestrated'. Although webhook names look better in my opinion, using plugin names would help us to avoid possible user confusions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'll stick to the plugin mode names everywhere. Will update the PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, +1

@@ -138,13 +120,31 @@ $ ./scripts/webhook-deploy.sh --ca-bundle-path /var/run/kubernetes/server-ca.crt

# Mappings

Requested FPGA resources are translated to AF resources. For example,
`fpga.intel.com/arria10.dcp1.1-nlb0` is translated to `fpga.intel.com/af-d8424dc4a4a3c413f89e433683f9040b`.
For the following mapping
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to say a sentence or two, kind of "introduction", that mappings are essential part of the setup and give cluster administrator flexible instrument for managing FPGA bitstreams and access control for them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! added

Copy link
Contributor

@mythi mythi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs rebase

is the first 31 characters of the region interface ID for Arria10 with DCP1.1
firmware. The next 32 characters (`d8424dc4a4a3c413f89e433683f9040b`) is an accelerator function ID.

The same mapping, but with its mode field set to `orchestrated`, translates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it might be good idea to accept "pre-programmed" as alias to "programmed"

(This meant to say accept both pre-programmed and preprogrammed?)

Maybe "static" and "dynamic"

this would work, IMO, but it might be good to start using "programming mode" in documentation where we just say only "mode" today.

@rojkov rojkov force-pushed the webhook-modeless branch from 6b29065 to 10054b0 Compare April 21, 2020 07:48
@rojkov
Copy link
Contributor Author

rojkov commented Apr 21, 2020

Thanks! Rebased.

@rojkov rojkov force-pushed the webhook-modeless branch from 325dea1 to dbf5a35 Compare April 22, 2020 08:08
@rojkov
Copy link
Contributor Author

rojkov commented Apr 22, 2020

Updated to use consistent mode names across the FPGA webhook and plugin.

bart0sh
bart0sh previously approved these changes Apr 22, 2020
@bart0sh
Copy link
Member

bart0sh commented Apr 22, 2020

I'm going to give other reviewers one day for their comments/approvals. Then I'll merge this.

@bart0sh
Copy link
Member

bart0sh commented Apr 22, 2020

@mythi @kad please review last time and approve/merge.

@mythi
Copy link
Contributor

mythi commented Apr 22, 2020

this looks good to me but should we squash commits?

@kad
Copy link
Member

kad commented Apr 22, 2020

I agree with @mythi, let's squash and lgtm.

fpga: make AFU resource name 63 char long

webhook: drop mode from README

webhook: extend mappings description

webhook: tighten CRD definitions

webhook: drop mapping to non-existing afuId

explicitly state mappings names can be in any format

use consistent terminology across fpga webhook and plugin
@bart0sh
Copy link
Member

bart0sh commented Apr 23, 2020

@rojkov Plugin is failing in af mode due to incorrect socket file name:

> kubectl get pods
NAME                      READY   STATUS             RESTARTS   AGE
intel-fpga-plugin-rk69j   0/1     CrashLoopBackOff   4          2m23s

> kubectl logs intel-fpga-plugin-rk69j
E0423 09:13:28.819373       1 manager.go:125] Failed to serve fpga.intel.com/69528db6eb31577a8c3668f9faa081ff7df405cbd7acf7222f144b0b93acd18: listen unix /var/lib/kubelet/device-plugins/fpga.intel.com-69528db6eb31577a8c3668f9faa081ff7df405cbd7acf7222f144b0b93acd18.sock: bind: invalid argument
Failed to listen to plugin socket
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*server).setupAndServe
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/server.go:211
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*server).Serve
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/server.go:163
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*Manager).handleUpdate.func1
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/manager.go:123
runtime.goexit
	/usr/lib/golang/src/runtime/asm_amd64.s:1357

However, it seems to work in region mode.

@rojkov
Copy link
Contributor Author

rojkov commented Apr 23, 2020 via email

@rojkov
Copy link
Contributor Author

rojkov commented Apr 23, 2020

Failed to listen to plugin socket

Too bad unix socket addresses can be 108 chars long in Linux. /var/lib/kubelet/device-plugins/fpga.intel.com-69528db6eb31577a8c3668f9faa081ff7df405cbd7acf7222f144b0b93acd18.sock is 115 chars.

Should I strip the interface ID part even further from 31 to 16? Are we ok with that?

@bart0sh
Copy link
Member

bart0sh commented Apr 23, 2020

@rojkov Do you think 16 chars would make unique enough id? Any other ways to solve this?

@rojkov
Copy link
Contributor Author

rojkov commented Apr 24, 2020

The limit is not 115, but 108 (including a trailing zero I presume), so the practical limit, as I tested, is 107. I've just updated the PR. Could you please check it once more?

return "", errors.Wrapf(err, "failed to decode %q and %q", interfaceID, afuID)
}

return fmt.Sprintf("%s.%s.%s", interfaceID[:3], afuID[:3], base64.RawURLEncoding.EncodeToString(bin)), nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have 4 characters long prefixes and '-' delimiters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike dots '-' can be in the encoded section, so dots do a better job at separating the sections visually imho.
But ok, will update.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Feel free to use dots then. Just increase prefixes to 4 chars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Done.

@bart0sh
Copy link
Member

bart0sh commented Apr 24, 2020

The limit is not 115, but 108

We can still use 4 chars long prefixes, right?

In [1]: len('/var/lib/kubelet/device-plugins/fpga.intel.com-') + len('ce48-d842-zkiWk5jwXzOUbVYHCL4QithCTcSko8QT-J5DNoP5BAs') + len('.sock')                                      
Out[1]: 105

@rojkov rojkov force-pushed the webhook-modeless branch from 76c9c0e to cf2acb8 Compare April 24, 2020 10:59
@bart0sh
Copy link
Member

bart0sh commented Apr 24, 2020

/LGTM

I'll run e2e tests and report here if it works or not.

@mythi @kad please review this PR again. Hopefully last time.

@bart0sh
Copy link
Member

bart0sh commented Apr 24, 2020

@rojkov Could it be that mappings are setup incorrectly?

When I run plugin in af mode the node has these af resources:

Allocatable:

  fpga.intel.com/6952.d842.aVKNtusxV3qMNmj5-qCB9thCTcSko8QT-J5DNoP5BAs:  1
  fpga.intel.com/6952.f7df.aVKNtusxV3qMNmj5-qCB9vffQFy9es9yIvFEsLk6zRg:  1

However, the pod resource requests are mutated to region- resources:

> cat <<END | kubectl create -f-
> apiVersion: v1
> kind: Pod
> metadata:
>   name: test-nlb0
> spec:
>   containers:
>   - name: test-nlb0
>     image: intel/opae-nlb-demo:devel
>     imagePullPolicy: IfNotPresent
>     command: ['nlb0']
>     securityContext:
>       capabilities:
>         add:
>           [IPC_LOCK]
>     resources:
>       limits:
>         fpga.intel.com/arria10.dcp1.2-nlb0: 1
>         cpu: 1
>         hugepages-2Mi: 20Mi
> 
>   restartPolicy: Never
> END
pod/test-nlb0 created
> kubectl describe pod test-nlb0 |grep -A10 Limits
    Limits:
      cpu:                                                     1
      fpga.intel.com/region-69528db6eb31577a8c3668f9faa081f6:  1
      hugepages-2Mi:                                           20Mi
    Requests:
      cpu:                                                     1
      fpga.intel.com/region-69528db6eb31577a8c3668f9faa081f6:  1
      hugepages-2Mi:                                           20Mi
    Environment:
      FPGA_AFU_1:     d8424dc4a4a3c413f89e433683f9040b
      FPGA_REGION_1:  69528db6eb31577a8c3668f9faa081f6

Side note - we may want to add 'af-' prefix to af resource names to make the resource naming consistent. We can do that by reducing af id and interface id prefixes to 3 chars each.

@rojkov
Copy link
Contributor Author

rojkov commented Apr 24, 2020

Could it be that mappings are setup incorrectly?

The arria10.dcp1.2-nlb0 mapping is configured to translate to region mode in deployments/fpga_admissionwebhook/mappings-collection.yaml. Just update the mapping.

I can add one more mapping arria10.dcp.1.2-nlb0-preprogrammed for testing purposes to the collection.

Regarding the af- prefix. Yes, will add.

@bart0sh
Copy link
Member

bart0sh commented Apr 24, 2020

I can add one more mapping arria10.dcp.1.2-nlb0-preprogrammed for testing purposes to the collection.

Yes, please do. I'd also suggest renaming arria10.dcp.1.2-nlb0 to arria10.dcp.1.2-nlb0-orchestrated to be more explicit.

@rojkov rojkov force-pushed the webhook-modeless branch from cf2acb8 to bafc207 Compare April 27, 2020 07:34
@rojkov
Copy link
Contributor Author

rojkov commented Apr 27, 2020

Ok, added. Also I've added -orchestrated suffix to all mappings with region mode for consistency.

@bart0sh
Copy link
Member

bart0sh commented Apr 27, 2020

@rojkov It's still failing. Looks like 4 symbols for afu and interface ids is too much:

> kubectl logs intel-fpga-plugin-87nrj --namespace fpgaplugin-e2e-8081
E0427 15:34:01.842986       1 manager.go:125] Failed to serve fpga.intel.com/af-6952.f7df.aVKNtusxV3qMNmj5-qCB9vffQFy9es9yIvFEsLk6zRg: listen unix /var/lib/kubelet/device-plugins/fpga.intel.com-af-6952.f7df.aVKNtusxV3qMNmj5-qCB9vffQFy9es9yIvFEsLk6zRg.sock: bind: invalid argument
Failed to listen to plugin socket
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*server).setupAndServe
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/server.go:211
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*server).Serve
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/server.go:163
github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin.(*Manager).handleUpdate.func1
	/intel-device-plugins-for-kubernetes/pkg/deviceplugin/manager.go:123
runtime.goexit
	/usr/lib/golang/src/runtime/asm_amd64.s:1357

@bart0sh
Copy link
Member

bart0sh commented Apr 27, 2020

@rojkov I'll try to reduce length of ids to 3. Hopefully this should be enough.

@bart0sh
Copy link
Member

bart0sh commented Apr 27, 2020

@rojkov worked for me with this change:

diff --git a/pkg/fpga/devtypes.go b/pkg/fpga/devtypes.go
index 87bbc44..5fc2b8f 100644
--- a/pkg/fpga/devtypes.go
+++ b/pkg/fpga/devtypes.go
@@ -32,5 +32,5 @@ func GetAfuDevType(interfaceID, afuID string) (string, error) {
                return "", errors.Wrapf(err, "failed to decode %q and %q", interfaceID, afuID)
        }
 
-       return fmt.Sprintf("af-%s.%s.%s", interfaceID[:4], afuID[:4], base64.RawURLEncoding.EncodeToString(bin)), nil
+       return fmt.Sprintf("af-%s.%s.%s", interfaceID[:3], afuID[:3], base64.RawURLEncoding.EncodeToString(bin)), nil
 }

Please, update the PR.

P.S. I'll send e2e test update as a PR to your branch rojkov:webhook-modeless

@bart0sh
Copy link
Member

bart0sh commented Apr 27, 2020

done: rojkov#5

@rojkov rojkov force-pushed the webhook-modeless branch from 2bc66d6 to c15734f Compare April 28, 2020 07:11
@rojkov
Copy link
Contributor Author

rojkov commented Apr 28, 2020

@rojkov It's still failing. Looks like 4 symbols for afu and interface ids is too much:

Oops, my bad. Reduced to 3 symbols now and cherry-picked your commit. Could you please try again?

bart0sh
bart0sh previously approved these changes Apr 28, 2020
@bart0sh
Copy link
Member

bart0sh commented Apr 28, 2020

@rojkov Thank you for the update! e2e tests worked!

@mythi @kad please review/approve/merge. Only you two can do that.

Comment on lines 20 to 24
type AcceleratorFunctionSpec struct {
AfuID string `json:"afuId"`
AfuID string `json:"afuId"`
InterfaceID string `json:"interfaceId"`
Mode string `json:"mode"`
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about the need for v2 API version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose in this case we'd need to maintain two versions of the webhook: "mode-ful" and "mode-less". Making the webhook modeless is already a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the webhook modeless is already a breaking change.

I was thinking v2 because of the breakage but did not think of the need to have both versions maintained (beyond what we have in the release branches).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That makes sense if there are installed old mappings in a cluster. Will update the version on Monday.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kad @bart0sh your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the fpga.intel.com API group to v2. It increased the size of the patch, but all tests pass.

Comment on lines 150 to 151
The same mapping, but with its mode field set to `region`, translates
`fpga.intel.com/arria10.dcp1.1-nlb0` to `fpga.intel.com/region-9926ab6d6c925a68aabca7d84c545738`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes the reader confused when we use the same resource name as the example for both modes. Perhaps add -orchestrated suffix here as it's in the default CRDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I forgot to reflect the compressed resource name in README.
Fixed now and used a real mapping from mappings-collection.yaml for the example.

Dmitry Rozhkov and others added 2 commits April 29, 2020 11:59
@bart0sh bart0sh merged commit 8b429fd into intel:master May 5, 2020
@rojkov rojkov deleted the webhook-modeless branch June 25, 2020 14:22
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

Successfully merging this pull request may close these issues.

Eliminate FPGA admission webhook's mode
5 participants