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

initdata: migrate key release test cases to initdata #2006

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions src/cloud-api-adaptor/cmd/cloud-api-adaptor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import (
)

const (
programName = "cloud-api-adaptor"
AA_KBC_PARAMS_DEFAULT = "cc_kbc::http://127.0.0.1:8080"
programName = "cloud-api-adaptor"
)

type daemonConfig struct {
Expand Down Expand Up @@ -122,7 +121,6 @@ func (cfg *daemonConfig) Setup() (cmd.Starter, error) {
flags.StringVar(&cfg.networkConfig.HostInterface, "host-interface", "", "Host Interface")
flags.IntVar(&cfg.networkConfig.VXLANPort, "vxlan-port", vxlan.DefaultVXLANPort, "VXLAN UDP port number (VXLAN tunnel mode only")
flags.IntVar(&cfg.networkConfig.VXLANMinID, "vxlan-min-id", vxlan.DefaultVXLANMinID, "Minimum VXLAN ID (VXLAN tunnel mode only")
flags.StringVar(&cfg.serverConfig.AAKBCParams, "aa-kbc-params", "", "attestation-agent KBC parameters")
flags.BoolVar(&cfg.serverConfig.EnableCloudConfigVerify, "cloud-config-verify", false, "Enable cloud config verify - should use it for production")

cloud.ParseCmd(flags)
Expand All @@ -142,8 +140,6 @@ func (cfg *daemonConfig) Setup() (cmd.Starter, error) {
cfg.serverConfig.SecureCommsInbounds = secureCommsInbounds
cfg.serverConfig.SecureCommsOutbounds = secureCommsOutbounds
cfg.serverConfig.SecureCommsKbsAddress = secureCommsKbsAddr

cfg.serverConfig.AAKBCParams = AA_KBC_PARAMS_DEFAULT
} else {
if !disableTLS {
cfg.serverConfig.TLSConfig = &tlsConfig
Expand Down
3 changes: 1 addition & 2 deletions src/cloud-api-adaptor/docs/addnewprovider.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ optionals+=""
[[ "${CERT_FILE}" ]] && [[ "${CERT_KEY}" ]] && optionals+="-cert-file ${CERT_FILE} -cert-key ${CERT_KEY} "
[[ "${TLS_SKIP_VERIFY}" ]] && optionals+="-tls-skip-verify "
[[ "${PROXY_TIMEOUT}" ]] && optionals+="-proxy-timeout ${PROXY_TIMEOUT} "
[[ "${AA_KBC_PARAMS}" ]] && optionals+="-aa-kbc-params ${AA_KBC_PARAMS} "
[[ "${FORWARDER_PORT}" ]] && optionals+="-forwarder-port ${FORWARDER_PORT} "
[[ "${CLOUD_CONFIG_VERIFY}" == "true" ]] && optionals+="-cloud-config-verify "

Expand Down Expand Up @@ -396,7 +395,7 @@ cloud-api-adaptor version v0.8.2-dev
cloud-api-adaptor: starting Cloud API Adaptor daemon for "libvirt"
2024/04/17 04:34:56 [adaptor/cloud/libvirt] libvirt config: &libvirt.Config{URI:"qemu+ssh://root@192.168.122.1/system?no_verify=1", PoolName:"default", NetworkName:"default", DataDir:"/opt/data-dir", DisableCVM:true, VolName:"podvm-base.qcow2", LaunchSecurity:"", Firmware:"/usr/share/edk2/ovmf/OVMF_CODE.fd"}
2024/04/17 04:34:56 [adaptor/cloud/libvirt] Created libvirt connection
2024/04/17 04:34:56 [adaptor] server config: &adaptor.ServerConfig{TLSConfig:(*tlsutil.TLSConfig)(0xc0000d4080), SocketPath:"/run/peerpod/hypervisor.sock", CriSocketPath:"", PauseImage:"", PodsDir:"/run/peerpod/pods", ForwarderPort:"15150", ProxyTimeout:300000000000, AAKBCParams:"", EnableCloudConfigVerify:false}
2024/04/17 04:34:56 [adaptor] server config: &adaptor.ServerConfig{TLSConfig:(*tlsutil.TLSConfig)(0xc0000d4080), SocketPath:"/run/peerpod/hypervisor.sock", CriSocketPath:"", PauseImage:"", PodsDir:"/run/peerpod/pods", ForwarderPort:"15150", ProxyTimeout:300000000000, EnableCloudConfigVerify:false}
2024/04/17 04:34:56 [util/k8sops] initialized PeerPodService
2024/04/17 04:34:56 [probe/probe] Using port: 8000
2024/04/17 04:34:56 [adaptor] server started
Expand Down
1 change: 0 additions & 1 deletion src/cloud-api-adaptor/docs/initdata.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

The document describes the implementation of the [initdata](https://github.com/confidential-containers/trustee/blob/main/kbs/docs/initdata.md) spec in PeerPods.

Initdata is used when `AA_KBC_PARAMS` is not set at the moment, the plan is to remove `AA_KBC_PARAMS` support after `initdata` function works completely.

## Initdata example

Expand Down
1 change: 0 additions & 1 deletion src/cloud-api-adaptor/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ optionals+=""
[[ "${CERT_FILE}" ]] && [[ "${CERT_KEY}" ]] && optionals+="-cert-file ${CERT_FILE} -cert-key ${CERT_KEY} "
[[ "${TLS_SKIP_VERIFY}" ]] && optionals+="-tls-skip-verify "
[[ "${PROXY_TIMEOUT}" ]] && optionals+="-proxy-timeout ${PROXY_TIMEOUT} "
[[ "${AA_KBC_PARAMS}" ]] && optionals+="-aa-kbc-params ${AA_KBC_PARAMS} "
[[ "${FORWARDER_PORT}" ]] && optionals+="-forwarder-port ${FORWARDER_PORT} "
[[ "${CLOUD_CONFIG_VERIFY}" == "true" ]] && optionals+="-cloud-config-verify "
[[ "${SECURE_COMMS}" == "true" ]] && optionals+="-secure-comms "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ configMapGenerator:
# /subscriptions/<AZURE_SUBSCRIPTION_ID>/resourceGroups/<AZURE_RESOURCE_GROUP>/providers/Microsoft.Compute/images/<AZURE_IMAGE>
- AZURE_IMAGE_ID="" #set
- SSH_USERNAME="" #set peer pod vm admin user name
- AA_KBC_PARAMS="" #set KBC params for podvm
#- DISABLECVM="" # Uncomment it if you want a generic VM
#- PAUSE_IMAGE="" # Uncomment and set if you want to use a specific pause image
#- VXLAN_PORT="" # Uncomment and set if you want to use a specific vxlan port. Defaults to 4789
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ configMapGenerator:
- LIBVIRT_POOL="default" # set
- DISABLECVM="true" # set as false to enable confidential VM
- SECURE_COMMS="false" # set as true to enable Secure Comms
- AA_KBC_PARAMS="" #set KBC params for podvm
#- LIBVIRT_LAUNCH_SECURITY="" #sev or s390-pv
#- LIBVIRT_FIRMWARE="" # Uncomment and set if you want to change the firmware path. Defaults to /usr/share/edk2/ovmf/OVMF_CODE.fd
#- LIBVIRT_VOL_NAME="" # Uncomment and set if you want to use a specific volume name. Defaults to podvm-base.qcow2
Expand Down
51 changes: 0 additions & 51 deletions src/cloud-api-adaptor/pkg/aa/config.go

This file was deleted.

36 changes: 0 additions & 36 deletions src/cloud-api-adaptor/pkg/aa/config_test.go

This file was deleted.

42 changes: 7 additions & 35 deletions src/cloud-api-adaptor/pkg/adaptor/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ import (
"github.com/containerd/containerd/pkg/cri/annotations"
pb "github.com/kata-containers/kata-containers/src/runtime/protocols/hypervisor"

"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/aa"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/adaptor/k8sops"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/adaptor/proxy"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/agent"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/cdh"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/forwarder"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/podnetwork"
"github.com/confidential-containers/cloud-api-adaptor/src/cloud-api-adaptor/pkg/securecomms/wnssh"
Expand All @@ -35,7 +33,9 @@ import (

const (
SrcAuthfilePath = "/root/containers/auth.json"
AaFilePath = "/run/peerpod/aa.toml"
huoqifeng marked this conversation as resolved.
Show resolved Hide resolved
AuthFilePath = "/run/peerpod/auth.json"
CdhFilePath = "/run/peerpod/cdh.toml"
huoqifeng marked this conversation as resolved.
Show resolved Hide resolved
InitdataPath = "/run/peerpod/initdata"
Version = "0.0.0"
)
Expand Down Expand Up @@ -79,8 +79,7 @@ func (s *cloudService) removeSandbox(id sandboxID) error {
}

func NewService(provider provider.Provider, proxyFactory proxy.Factory, workerNode podnetwork.WorkerNode,
secureComms bool, secureCommsInbounds, secureCommsOutbounds, kbsAddress, podsDir, daemonPort, aaKBCParams, sshport string,
) Service {
secureComms bool, secureCommsInbounds, secureCommsOutbounds, kbsAddress, podsDir, daemonPort, sshport string) Service {
var err error
var sshClient *wnssh.SshClient

Expand All @@ -100,7 +99,6 @@ func NewService(provider provider.Provider, proxyFactory proxy.Factory, workerNo
podsDir: podsDir,
daemonPort: daemonPort,
workerNode: workerNode,
aaKBCParams: aaKBCParams,
sshClient: sshClient,
}
s.cond = sync.NewCond(&s.mutex)
Expand Down Expand Up @@ -292,39 +290,13 @@ func (s *cloudService) CreateVM(ctx context.Context, req *pb.CreateVMRequest) (r
}
}

if s.aaKBCParams != "" { // Keep AA_KBC_PARAMS support as it is used by e2e test, KBS is dynamic k8s service in e2e test
bpradipt marked this conversation as resolved.
Show resolved Hide resolved
logger.Printf("aaKBCParams: %s, support cc_kbc::*", s.aaKBCParams)
toml, err := cdh.CreateConfigFile(s.aaKBCParams)
if err != nil {
return nil, fmt.Errorf("creating CDH config: %w", err)
}
cloudConfig.WriteFiles = append(cloudConfig.WriteFiles, cloudinit.WriteFile{
Path: cdh.ConfigFilePath,
Content: toml,
})

toml, err = aa.CreateConfigFile(s.aaKBCParams)
if err != nil {
return nil, fmt.Errorf("creating attestation agent config: %w", err)
}
cloudConfig.WriteFiles = append(cloudConfig.WriteFiles, cloudinit.WriteFile{
Path: aa.ConfigFilePath,
Content: toml,
})
}

initdataStr := util.GetInitdataFromAnnotation(req.Annotations)
logger.Printf("initdata: %s", initdataStr)
if initdataStr != "" {
if s.aaKBCParams != "" {
logger.Printf("Initdata ignored because AA_KBC_PARAMS set")
} else {
logger.Printf("Set and use initdata when no AA_KBC_PARAMS")
cloudConfig.WriteFiles = append(cloudConfig.WriteFiles, cloudinit.WriteFile{
Path: InitdataPath,
Content: initdataStr,
})
}
cloudConfig.WriteFiles = append(cloudConfig.WriteFiles, cloudinit.WriteFile{
Path: InitdataPath,
Content: initdataStr,
})
}

sandbox := &sandbox{
Expand Down
4 changes: 2 additions & 2 deletions src/cloud-api-adaptor/pkg/adaptor/cloud/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestCloudService(t *testing.T) {
podsDir: dir,
}

s := NewService(&mockProvider{}, proxyFactory, &mockWorkerNode{}, false, "", "", "", dir, forwarder.DefaultListenPort, "", "")
s := NewService(&mockProvider{}, proxyFactory, &mockWorkerNode{}, false, "", "", "", dir, forwarder.DefaultListenPort, "")

assert.NotNil(t, s)

Expand Down Expand Up @@ -172,7 +172,7 @@ func TestCloudServiceWithSecureComms(t *testing.T) {
podsDir: dir,
}

s := NewService(&mockProvider{}, proxyFactory, &mockWorkerNode{}, true, "", "", "127.0.0.1:9009", dir, forwarder.DefaultListenPort, "", sshport)
s := NewService(&mockProvider{}, proxyFactory, &mockWorkerNode{}, true, "", "", "127.0.0.1:9009", dir, forwarder.DefaultListenPort, sshport)

assert.NotNil(t, s)

Expand Down
1 change: 0 additions & 1 deletion src/cloud-api-adaptor/pkg/adaptor/cloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type cloudService struct {
daemonPort string
mutex sync.Mutex
ppService *k8sops.PeerPodService
aaKBCParams string
sshClient *wnssh.SshClient
}

Expand Down
3 changes: 1 addition & 2 deletions src/cloud-api-adaptor/pkg/adaptor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type ServerConfig struct {
PodsDir string
ForwarderPort string
ProxyTimeout time.Duration
AAKBCParams string
EnableCloudConfigVerify bool
SecureComms bool
SecureCommsInbounds string
Expand Down Expand Up @@ -71,7 +70,7 @@ func NewServer(provider provider.Provider, cfg *ServerConfig, workerNode podnetw

agentFactory := proxy.NewFactory(cfg.PauseImage, cfg.TLSConfig, cfg.ProxyTimeout)
cloudService := cloud.NewService(provider, agentFactory, workerNode,
cfg.SecureComms, cfg.SecureCommsInbounds, cfg.SecureCommsOutbounds, cfg.SecureCommsKbsAddress, cfg.PodsDir, cfg.ForwarderPort, cfg.AAKBCParams, sshutil.SSHPORT)
cfg.SecureComms, cfg.SecureCommsInbounds, cfg.SecureCommsOutbounds, cfg.SecureCommsKbsAddress, cfg.PodsDir, cfg.ForwarderPort, sshutil.SSHPORT)
vmInfoService := vminfo.NewService(cloudService)

return &server{
Expand Down
48 changes: 0 additions & 48 deletions src/cloud-api-adaptor/pkg/cdh/config.go

This file was deleted.

42 changes: 0 additions & 42 deletions src/cloud-api-adaptor/pkg/cdh/config_test.go

This file was deleted.

Loading