Skip to content

Commit

Permalink
Merge pull request #69 from zalando-incubator/remove-senza-cluster-cr…
Browse files Browse the repository at this point in the history
…eate

Remove senza based cluster creation
  • Loading branch information
mikkeloscar authored Aug 5, 2018
2 parents 1fb1676 + 2e5d468 commit 5ffcb46
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 93 deletions.
74 changes: 0 additions & 74 deletions provisioner/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,80 +185,6 @@ func decodeUserData(encodedUserData string) (string, error) {
return string(data), nil
}

// CreateOrUpdateClusterStackSenza creates or updates a cluster cloudformation
// stack. This function is idempotent.
func (a *awsAdapter) CreateOrUpdateClusterStackSenza(parentCtx context.Context, stackName, stackDefinitionPath string, cluster *api.Cluster) error {
name, version, err := splitStackName(stackName)
if err != nil {
return err
}

// create bucket name with aws account ID to ensure uniqueness across
// accounts.
s3BucketName := fmt.Sprintf(clmCFBucketPattern, strings.TrimPrefix(cluster.InfrastructureAccount, "aws:"), cluster.Region)

hostedZone, err := getHostedZone(cluster.APIServerURL)
if err != nil {
return err
}

args := []string{
"print",
stackDefinitionPath,
version,
"KmsKey=*",
fmt.Sprintf("StackName=%s", name),
fmt.Sprintf("HostedZone=%s", hostedZone),
fmt.Sprintf("ClusterID=%s", cluster.ID),
}

if bucket, ok := cluster.ConfigItems[etcdS3BackupBucketKey]; ok {
args = append(args, fmt.Sprintf("EtcdS3BackupBucket=%s", bucket))
}

cmd := exec.Command("senza", args...)

if a.dryRun {
cmd.Args = append(cmd.Args, "--dry-run")
}

enVars, err := a.getEnvVars()
if err != nil {
return err
}

cmd.Env = enVars

output, err := cmd.Output()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("%v: %s", err, string(exitErr.Stderr))
}
return err
}

var stackBuffer bytes.Buffer
// save as many bytes as possible
err = json.Compact(&stackBuffer, output)
if err != nil {
return err
}

err = a.applyClusterStack(stackName, stackBuffer.String(), cluster, s3BucketName)
if err != nil {
return err
}

ctx, cancel := context.WithTimeout(parentCtx, maxWaitTimeout)
defer cancel()
err = a.waitForStack(ctx, waitTime, stackName)
if err != nil {
return err
}

return nil
}

// applyClusterStack creates or updates a stack specified by stackName and
// stackTemplate.
// If the stackTemplate exceeds the max size, it will automatically upload it
Expand Down
21 changes: 2 additions & 19 deletions provisioner/clusterpy.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,31 +242,14 @@ func (p *clusterpyProvisioner) Provision(ctx context.Context, logger *log.Entry,
}

cfgBasePath := path.Join(channelConfig.Path, "cluster")
stackDefinitionPath := path.Join(cfgBasePath, "senza-definition.yaml")

// create bucket name with aws account ID to ensure uniqueness across
// accounts.
bucketName := fmt.Sprintf(clmCFBucketPattern, strings.TrimPrefix(cluster.InfrastructureAccount, "aws:"), cluster.Region)

// TODO(tech-depth): remove this once all clusters are switched away
// from senza.
// if the senza-definition.yaml exists we create a stack based on that,
// otherwise we create it from the cluster.yaml
_, err = os.Stat(stackDefinitionPath)
err = createOrUpdateClusterStack(awsAdapter, ctx, cfgBasePath, cluster, values, bucketName)
if err != nil {
if !os.IsNotExist(err) {
return err
}

err = createOrUpdateClusterStack(awsAdapter, ctx, cfgBasePath, cluster, values, bucketName)
if err != nil {
return err
}
} else {
err = awsAdapter.CreateOrUpdateClusterStackSenza(ctx, cluster.LocalID, stackDefinitionPath, cluster)
if err != nil {
return err
}
return err
}

if err = ctx.Err(); err != nil {
Expand Down

0 comments on commit 5ffcb46

Please sign in to comment.