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

Revert "Add apparmor support" #3993

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
95 changes: 0 additions & 95 deletions ecs-init/apparmor/apparmor.go

This file was deleted.

103 changes: 0 additions & 103 deletions ecs-init/apparmor/apparmor_test.go

This file was deleted.

51 changes: 51 additions & 0 deletions ecs-init/config/development.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//go:build development
// +build development

// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
// not use this file except in compliance with the License. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file accompanying this file. This file 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 config

import (
"fmt"
"os"
)

var directoryPrefix string
var s3Bucket string

func init() {
fmt.Println("****************")
fmt.Println("DEVELOPMENT MODE")
directoryPrefix = getDirectoryPrefix()
s3Bucket = getS3Bucket()
fmt.Println("****************")
}

func getDirectoryPrefix() string {
return getEnvWithDefault("PATH_PREFIX", "/tmp")
}

func getS3Bucket() string {
return getEnvWithDefault("S3_BUCKET_OVERRIDE", "amazon-ecs-agent")
}

func getEnvWithDefault(environmentVariable, defaultIfMissing string) string {
env := os.Getenv(environmentVariable)
if env == "" {
fmt.Printf("%s not set, using %s\n", environmentVariable, defaultIfMissing)
return defaultIfMissing
}
fmt.Printf("%s set as %s\n", environmentVariable, env)
return env
}
3 changes: 3 additions & 0 deletions ecs-init/config/release.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build !development
// +build !development

// Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"). You may
Expand Down
8 changes: 0 additions & 8 deletions ecs-init/docker/docker_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
package docker

import (
"fmt"

"github.com/aws/amazon-ecs-agent/ecs-init/apparmor"
"github.com/aws/amazon-ecs-agent/ecs-init/config"
ctrdapparmor "github.com/containerd/containerd/pkg/apparmor"
godocker "github.com/fsouza/go-dockerclient"
)

Expand Down Expand Up @@ -66,10 +62,6 @@ func createHostConfig(binds []string) *godocker.HostConfig {
Init: true,
}

if ctrdapparmor.HostSupports() {
hostConfig.SecurityOpt = []string{fmt.Sprintf("apparmor:%s", apparmor.ECSDefaultProfileName)}
}

if config.RunPrivileged() {
hostConfig.Privileged = true
}
Expand Down
27 changes: 3 additions & 24 deletions ecs-init/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"os"
"time"

"github.com/aws/amazon-ecs-agent/ecs-init/apparmor"
"github.com/aws/amazon-ecs-agent/ecs-init/backoff"
"github.com/aws/amazon-ecs-agent/ecs-init/cache"
"github.com/aws/amazon-ecs-agent/ecs-init/config"
Expand All @@ -32,7 +31,6 @@ import (
"github.com/aws/amazon-ecs-agent/ecs-init/gpu"

log "github.com/cihub/seelog"
ctrdapparmor "github.com/containerd/containerd/pkg/apparmor"
)

const (
Expand All @@ -51,13 +49,9 @@ const (
)

// Injection point for testing purposes
var (
getDockerClient = func() (dockerClient, error) {
return docker.Client()
}
hostSupports = ctrdapparmor.HostSupports
loadDefaultProfile = apparmor.LoadDefaultProfile
)
var getDockerClient = func() (dockerClient, error) {
return docker.Client()
}

func dockerError(err error) error {
return engineError("could not create docker client", err)
Expand Down Expand Up @@ -119,11 +113,6 @@ func (e *Engine) PreStart() error {
if err != nil {
return err
}
// setup AppArmor if necessary
err = e.PreStartAppArmor()
if err != nil {
return err
}
// Enable use of loopback addresses for local routing purposes
log.Info("pre-start: enabling loopback routing")
err = e.loopbackRouting.Enable()
Expand Down Expand Up @@ -206,16 +195,6 @@ func (e *Engine) PreStartGPU() error {
return nil
}

// PreStartAppArmor sets up the ecs-default AppArmor profile if we're running
// on an AppArmor-enabled system.
func (e *Engine) PreStartAppArmor() error {
if hostSupports() {
log.Infof("pre-start: setting up %s AppArmor profile", apparmor.ECSDefaultProfileName)
return loadDefaultProfile(apparmor.ECSDefaultProfileName)
}
return nil
}

// ReloadCache reloads the cached image of the ECS Agent into Docker
func (e *Engine) ReloadCache() error {
docker, err := getDockerClient()
Expand Down
Loading