Skip to content

Commit

Permalink
[ci skip] 2019.01.18-1364
Browse files Browse the repository at this point in the history
  • Loading branch information
cybozu-neco committed Jan 18, 2019
2 parents 6e371ec + 3c9befc commit 31106bb
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 28 deletions.
15 changes: 13 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,15 @@ jobs:
command: |
./bin/watch_boot0
background: true
- run:
name: Watch neco-updater logs
command: |
./bin/watch_service neco-updater
background: true
- run:
name: Watch neco-worker logs
command: |
./bin/watch_neco_worker
./bin/watch_service neco-worker
background: true
- run:
command: |
Expand Down Expand Up @@ -120,11 +125,17 @@ jobs:
if [ ! -f .diff ]; then exit 0; fi
./bin/watch_boot0
background: true
- run:
name: Watch neco-updater logs
command: |
if [ ! -f .diff ]; then exit 0; fi
./bin/watch_service neco-updater
background: true
- run:
name: Watch neco-worker logs
command: |
if [ ! -f .diff ]; then exit 0; fi
./bin/watch_neco_worker
./bin/watch_service neco-worker
background: true
- run:
command: |
Expand Down
19 changes: 11 additions & 8 deletions bin/watch_neco_worker → bin/watch_service
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

. $(dirname $0)/env

tail_neco_worker_once() {
test $# -eq 1
service="$1"

tail_once() {
host="$1"
$GCLOUD 2>/dev/null compute ssh --zone=${ZONE} cybozu@${INSTANCE_NAME} -- \
sudo nsenter -n -t '$(sudo pmctl pod show operation | jq .pid)' ssh -F ssh_config \
${host} journalctl -f -u neco-worker.service
${host} journalctl -f -u ${service}.service
}

tail_neco_worker() {
tail_forever() {
host="$1"

while true; do
tail_neco_worker_once $host || continue
tail_once $host || continue
sleep 3
done
}
Expand All @@ -23,9 +26,9 @@ while ! $GCLOUD 2>/dev/null compute scp --zone=${ZONE} ./dctest/dctest_key ./dct
sleep 1
done

tail_neco_worker boot-0 | sed -e s/^/$(tput -Txterm setaf 1)/ &
tail_neco_worker boot-1 | sed -e s/^/$(tput -Txterm setaf 2)/ &
tail_neco_worker boot-2 | sed -e s/^/$(tput -Txterm setaf 3)/ &
tail_neco_worker boot-3 | sed -e s/^/$(tput -Txterm setaf 4)/ &
tail_forever boot-0 | sed -e s/^/$(tput -Txterm setaf 1)/ &
tail_forever boot-1 | sed -e s/^/$(tput -Txterm setaf 2)/ &
tail_forever boot-2 | sed -e s/^/$(tput -Txterm setaf 3)/ &
tail_forever boot-3 | sed -e s/^/$(tput -Txterm setaf 4)/ &

wait
4 changes: 3 additions & 1 deletion docs/neco.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ These configurations are stored in etcd database.

### `env`

Specify the cluster environment. The default is `staging`.
Specify the cluster environment.
Possible values are: `staging` and `prod`.

`staging` environment will be updated with pre-releases of `neco` package.

Update never happens until this config is set.

### `slack`

Specify [Slack WebHook](https://api.slack.com/incoming-webhooks) URL.
Expand Down
2 changes: 1 addition & 1 deletion docs/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use the version number `2018.11.07-1` on a comparison of the tags.
must select the environment by `neco config set env ENV` sub-command.
If `production` is set, `neco-updater` downloads latest release excluding
pre-release version. Otherwise if `staging` is set, `neco-updater` downloads
latest pre-release version.
latest version from among releases and pre-releases.

Implementation of update process
--------------------------------
Expand Down
1 change: 1 addition & 0 deletions ignitions/roles/cs/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: ../../common/common.yml
2 changes: 1 addition & 1 deletion pkg/neco/cmd/config_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var configSetCmd = &cobra.Command{
Long: `Store a configuration value to etcd.
Possible keys are:
env - "staging" or "prod". Default is "staging".
env - "staging" or "prod".
slack - Slack WebHook URL.
proxy - HTTP proxy server URL to access Internet.
quay-username - Username to authenticate to quay.io from QUAY_USER. This does not take VALUE.
Expand Down
2 changes: 1 addition & 1 deletion storage/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s Storage) PutEnvConfig(ctx context.Context, env string) error {
func (s Storage) GetEnvConfig(ctx context.Context) (string, error) {
env, err := s.get(ctx, KeyEnv)
if err == ErrNotFound {
return neco.StagingEnv, nil
return neco.NoneEnv, nil
}
return env, err
}
Expand Down
12 changes: 6 additions & 6 deletions storage/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ func testEnvConfig(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if env != neco.StagingEnv {
t.Error(`env != neco.StagingEnv`, env)
if env != neco.NoneEnv {
t.Error(`env != neco.NoneEnv`, env)
}

err = st.PutEnvConfig(ctx, "http://squid.example.com:3128")
err = st.PutEnvConfig(ctx, neco.StagingEnv)
if err != nil {
t.Fatal(err)
}

proxy, err := st.GetEnvConfig(ctx)
env, err = st.GetEnvConfig(ctx)
if err != nil {
t.Fatal(err)
}
if proxy != "http://squid.example.com:3128" {
t.Error(`proxy != "http://squid.example.com:3128"`, proxy)
if env != neco.StagingEnv {
t.Error(`env != neco.StagingEnv"`, env)
}
}

Expand Down
1 change: 1 addition & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "time"

// Environments to use release or pre-release neco
const (
NoneEnv = "none"
TestEnv = "test"
StagingEnv = "staging"
ProdEnv = "prod"
Expand Down
8 changes: 4 additions & 4 deletions updater/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ReleaseClient struct {
http *http.Client
}

// GetLatestReleaseTag returns latest tag in GitHub Releases of neco repository
// GetLatestReleaseTag returns latest published release tag in GitHub Releases of neco repository
func (c ReleaseClient) GetLatestReleaseTag(ctx context.Context) (string, error) {
client := neco.NewGitHubClient(c.http)
release, resp, err := client.Repositories.GetLatestRelease(ctx, c.owner, c.repo)
Expand All @@ -46,8 +46,8 @@ func (c ReleaseClient) GetLatestReleaseTag(ctx context.Context) (string, error)
return *release.TagName, nil
}

// GetLatestPreReleaseTag returns latest pre-released tag in GitHub Releases of neco repository
func (c ReleaseClient) GetLatestPreReleaseTag(ctx context.Context) (string, error) {
// GetLatestPublishedTag returns latest published release/pre-release tag in GitHub Releases of neco repository
func (c ReleaseClient) GetLatestPublishedTag(ctx context.Context) (string, error) {
client := neco.NewGitHubClient(c.http)

opt := &github.ListOptions{
Expand All @@ -68,7 +68,7 @@ func (c ReleaseClient) GetLatestPreReleaseTag(ctx context.Context) (string, erro
}
versions := make([]*version.Version, 0, len(releases))
for _, r := range releases {
if r.TagName == nil || !r.GetPrerelease() {
if r.TagName == nil || r.GetDraft() {
continue
}
s := *r.TagName
Expand Down
6 changes: 3 additions & 3 deletions updater/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func testGetLatestReleaseTag(t *testing.T) {
t.Logf("version = %s", ver)
}

func testGetLatestPreReleaseTag(t *testing.T) {
func testGetLatestPublishedTag(t *testing.T) {
t.Skip()

c := ReleaseClient{owner: "kubernetes", repo: "kubernetes"}
ver, err := c.GetLatestPreReleaseTag(context.Background())
ver, err := c.GetLatestPublishedTag(context.Background())
if err != nil {
t.Fatal(err)
}
Expand All @@ -32,5 +32,5 @@ func testGetLatestPreReleaseTag(t *testing.T) {

func TestGitHub(t *testing.T) {
t.Run("GetLatestReleaseTag", testGetLatestReleaseTag)
t.Run("GetLatestPreReleaseTag", testGetLatestPreReleaseTag)
t.Run("GetLatestPublishedTag", testGetLatestPublishedTag)
}
6 changes: 5 additions & 1 deletion updater/release_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ func (c *ReleaseChecker) Run(ctx context.Context) error {
}

switch env {
case neco.NoneEnv:
c.check = func(ctx context.Context) (string, error) {
return "", ErrNoReleases
}
case neco.TestEnv:
c.check = func(ctx context.Context) (string, error) {
return "0.0.2", nil
}
case neco.StagingEnv:
c.check = github.GetLatestPreReleaseTag
c.check = github.GetLatestPublishedTag
case neco.ProdEnv:
c.check = github.GetLatestReleaseTag
default:
Expand Down

0 comments on commit 31106bb

Please sign in to comment.