in cmd/aws-vpc-cni/main.go [416:473]
func _main() int {
log.Debug("Started aws-node container")
if !validateEnvVars() {
return 1
}
pluginBins := []string{"aws-cni", "egress-cni"}
hostCNIBinPath := utils.GetEnv(envHostCniBinPath, defaultHostCniBinPath)
err := cp.InstallBinaries(pluginBins, hostCNIBinPath)
if err != nil {
log.WithError(err).Error("Failed to install CNI binaries")
return 1
}
log.Infof("Starting IPAM daemon... ")
cmd := "./aws-k8s-agent"
// Exec redirects stdout and stderr to /dev/null, redirecting to os.Stdout and os.Stderr is done explicitly.
// This enables the output of the aws-k8s-agent to be displayed in the kubectl logs for the aws-node container via stdout and stderr.
ipamdDaemon := exec.Command(cmd)
ipamdDaemon.Stdout = os.Stdout
ipamdDaemon.Stderr = os.Stderr
err = ipamdDaemon.Start()
if err != nil {
log.WithError(err).Errorf("Failed to execute command: %s", cmd)
return 1
}
log.Infof("Checking for IPAM connectivity... ")
if !waitForIPAM() {
log.Errorf("Timed out waiting for IPAM daemon to start")
return 1
}
log.Infof("Copying config file... ")
err = generateJSON(defaultAWSconflistFile, tmpAWSconflistFile, getPrimaryIP)
if err != nil {
log.WithError(err).Errorf("Failed to generate 10-awsconflist")
return 1
}
hostCniConfDirPath := utils.GetEnv(envHostCniConfDirPath, defaultHostCniConfDirPath)
err = cp.CopyFile(tmpAWSconflistFile, hostCniConfDirPath+awsConflistFile)
if err != nil {
log.WithError(err).Errorf("Failed to copy %s", awsConflistFile)
return 1
}
log.Infof("Successfully copied CNI plugin binary and config file.")
err = ipamdDaemon.Wait()
if err != nil {
log.WithError(err).Errorf("Failed to wait for IPAM daemon to complete")
return 1
}
log.Infof("IPAMD stopped hence exiting ...")
return 0
}