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

Update to support agent version 1.13.0 #66

Merged
merged 4 commits into from Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -40,6 +40,7 @@ build-mock-images:
docker build -t "test.localhost/amazon/exit-success" -f "scripts/dockerfiles/exit-success.dockerfile" .

sources:
./scripts/update-version.sh
cp packaging/amazon-linux-ami/ecs-init.spec ecs-init.spec
cp packaging/amazon-linux-ami/ecs.conf ecs.conf
tar -czf ./sources.tgz ecs-init scripts
Expand Down
1 change: 1 addition & 0 deletions ecs-init/VERSION
@@ -0,0 +1 @@
1.13.0
2 changes: 1 addition & 1 deletion ecs-init/config/common.go
Expand Up @@ -77,7 +77,7 @@ func AgentTarball() string {

// AgentRemoteTarball is the remote location of the Agent image, used for populating the cache
func AgentRemoteTarball() string {
return "https://s3.amazonaws.com/" + s3Bucket + "/ecs-agent-v1.12.2.tar"
return "https://s3.amazonaws.com/" + s3Bucket + "/ecs-agent-v1.13.0.tar"
}

// AgentRemoteTarballMD5 is the remote location of a md5sum used to verify the integrity of the AgentRemoteTarball
Expand Down
29 changes: 24 additions & 5 deletions ecs-init/ecs-init.go
Expand Up @@ -20,10 +20,21 @@ import (

"github.com/aws/amazon-ecs-init/ecs-init/config"
"github.com/aws/amazon-ecs-init/ecs-init/engine"
"github.com/aws/amazon-ecs-init/ecs-init/version"

log "github.com/cihub/seelog"
)

// all supported commands
const (
VERSION = "version"
PRESTART = "pre-start"
START = "start"
PRESTOP = "pre-stop"
POSTSTOP = "post-stop"
RECACHE = "reload-cache"
)

func main() {
defer log.Flush()
flag.Parse()
Expand All @@ -40,6 +51,14 @@ func main() {
}
log.ReplaceLogger(logger)

if args[0] == VERSION {
err := version.PrintVersion()
if err != nil {
log.Errorf("failed print version info, err: %v", err)
}
return
}

init, err := engine.New()
if err != nil {
die(err)
Expand All @@ -64,23 +83,23 @@ type action struct {

func actions(engine *engine.Engine) map[string]action {
return map[string]action{
"pre-start": action{
PRESTART: action{
function: engine.PreStart,
description: "Prepare the ECS Agent for starting",
},
"start": action{
START: action{
function: engine.StartSupervised,
description: "Start the ECS Agent and wait for it to stop",
},
"pre-stop": action{
PRESTOP: action{
function: engine.PreStop,
description: "Stop the ECS Agent",
},
"reload-cache": action{
RECACHE: action{
function: engine.ReloadCache,
description: "Reload the cached image of the ECS Agent into Docker",
},
"post-stop": action{
POSTSTOP: action{
function: engine.PostStop,
description: "Cleanup procedure for the ECS Agent",
},
Expand Down
36 changes: 36 additions & 0 deletions ecs-init/version/formatting.go
@@ -0,0 +1,36 @@
// Copyright 2014-2016 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 version

import "fmt"

// String construct the version info of ecs-init
func String() string {
dirtyMark := ""
if GitDirty {
dirtyMark = "*"
}
return fmt.Sprintf("ecs-init version %s (%s%s)", Version, dirtyMark, GitShortHash)
}

// PrintVersion print out the
func PrintVersion() error {
if Version == "" || GitShortHash == "" {
return fmt.Errorf("Version info not set")
}

fmt.Println(String())

return nil
}
27 changes: 27 additions & 0 deletions ecs-init/version/version.go
@@ -0,0 +1,27 @@
// This is an autogenerated file and should not be edited.

// Copyright 2014-2016 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 version contains constants to indicate the current version of the
// ecs-init. It is autogenerated.
package version

// Version is the version of the ecs-init
const Version = "1.13.0"

// GitDirty indicates the cleanliness of the git repo when this ecs-init was built
const GitDirty = true

// GitShortHash is the short hash of this ecs-init build
const GitShortHash = "UNKNOWN"
2 changes: 2 additions & 0 deletions packaging/amazon-linux-ami/ecs-init.spec
Expand Up @@ -149,6 +149,8 @@ if [ -e %{running_semaphore} ]; then
fi

%changelog
* Tue Sep 27 2016 Noah Meyerhans <nmeyerha@amazon.com> - 1.13.0-1
- Cache Agent version 1.13.0
* Tue Sep 13 2016 Anirudh Aithal <aithal@amazon.com> - 1.12.2-1
- Cache Agent version 1.12.2
* Wed Aug 17 2016 Peng Yin <penyin@amazon.com> - 1.12.1-1
Expand Down
56 changes: 56 additions & 0 deletions scripts/update-version.sh
@@ -0,0 +1,56 @@
#!/bin/bash

# Copyright 2014-2016 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.

# This script will update the information of the ecs-init during building
set -e -x

CURRENTDIR=$(dirname "${0}")
version=$(cat "${CURRENTDIR}"/../ecs-init/VERSION)
git_hash=$(git rev-parse --short HEAD)
git_dirty=false

if [[ "$(git status --porcelain)" != "" ]]; then
git_dirty=true
fi

cat << EOF > "${CURRENTDIR}"/../ecs-init/version/version.go
// This is an autogenerated file and should not be edited.

// Copyright 2014-2016 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 version contains constants to indicate the current version of the
// ecs-init. It is autogenerated.
package version

// Version is the version of the ecs-init
const Version = "${version}"

// GitDirty indicates the cleanliness of the git repo when this ecs-init was built
const GitDirty = ${git_dirty}

// GitShortHash is the short hash of this ecs-init build
const GitShortHash = "${git_hash}"
EOF