Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Fix spot fleets after the multi-part userdata improvement #732

Closed
wants to merge 2 commits into from

Conversation

mumoshu
Copy link
Contributor

@mumoshu mumoshu commented Jul 4, 2017

This is currently a POC of the possible fix for #727 with ignition, probably simplified/replaced/enhanced with a more simpler solution without ignition.

This is a POC of the possible fix for kubernetes-retired#727 with ignition, probably simplified/replaced/enhanced with a more simpler solution without ignition
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 4, 2017

head, err := json.Marshal(`{
"ignition": {
"version": "2.0.0"
Copy link
Contributor Author

@mumoshu mumoshu Jul 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, to allow customizing the ignition config on user-side i.e. retain the flexibility of having all configs in a text form, we can add ignition.config.append.source which points to the user-customizable ignition config json uploaded to s3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, we can also utilize the user-customizable ignition config to gradually migrate from our current cloud-configs to ignition.

// once it supports sourcing from a s3 object
// https://coreos.com/ignition/docs/0.14.0/configuration-v2_0.html

head, err := json.Marshal(`{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@redbaron I've thrown away the quoteForCfn func 😉

@mumoshu
Copy link
Contributor Author

mumoshu commented Jul 4, 2017

Verified that this does fix #727 😉

@codecov-io
Copy link

codecov-io commented Jul 4, 2017

Codecov Report

Merging #732 into master will decrease coverage by 0.7%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #732      +/-   ##
==========================================
- Coverage   34.33%   33.63%   -0.71%     
==========================================
  Files          55       55              
  Lines        3073     3137      +64     
==========================================
  Hits         1055     1055              
- Misses       1859     1923      +64     
  Partials      159      159
Impacted Files Coverage Δ
model/userdata.go 29.26% <0%> (-31.75%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b542fb1...eabfe9e. Read the comment docs.

… userdata improvement

Our original fix incorporated ignition, which introduces an another moving part which is not strictly necessary for now
@@ -101,7 +101,7 @@
{{end}}
],
"SubnetId": {{$workerSubnet.Ref}},
"UserData": {{ $.UserDataWorker.Parts.instance.Base64 true | checkSizeLessThan 16384 | quote }}
"UserData": {{ $.UserDataWorker.Parts.instance.Base64UserDataRef }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've introduced Base64UserDataRef to inject {"Ref":"AWS::StackName"} into nodes by modifying the user-provided cloud-config(bash script)

"Name=key,Values=aws:cloudformation:stack-name" \
--output json \
| jq -r ".Tags[].Value") >> {{.StackNameEnvFileName}}'
echo "{{.StackNameEnvVarName}}=$(cat /kube-aws-stack-name)" >> {{.StackNameEnvFileName}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instance part of userdata now reads the stack name from a text file which is written by a bash snippet automatically injected by kube-aws

"files": [
{
"filesystem": "root",
"path": "/kube-aws-stack-name",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path should be somewhere else like /var/run/coreos/kube-aws-stack-name. However, /var/run is a tmpfs other than the root filesystem, which requires me to provide ignition an another filesystem name other than "root".
The problem doing so is that I'm not sure that names of filesystems other than "root" is stable i.e. safe to be hard-coded.
So, I'm rather wanting to leave this undecided for now.


func (self UserDataPart) Base64UserDataRef() (string, error) {
// Change this to Base64IgnitionConfigRef to test with ignition
return self.Base64BashScriptRef()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignition is not used by default for now. However, I like to leave the ignition support able to be enabled in code so that we can start testing with it toward #728 🤓

splits = append(splits, jsonStrings[:1]...)
splits = append(splits, `"echo \""`)
splits = append(splits, `{"Ref":"AWS::StackName"}`)
splits = append(splits, `"\" >> /kube-aws-stack-name\n"`)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This func is used to inject {"Ref":"AWS::StackName"} into nodes by modifying the "instance" parts of userdata.

@mumoshu
Copy link
Contributor Author

mumoshu commented Jul 5, 2017

Implemented, enabled, and verified the simpler fix without ignition.

@redbaron Could you review this? This solution with Base64UserDataRef seemed to be a minimum possible fix for #727 for now. My originally proposed solution with ignition is disabled by default and can be enabled only by modifying code and rebuilding kube-aws.

Also, please let me sync with you that I'd like to address #727 before releasing v0.9.7 final 🙇

@mumoshu mumoshu changed the title WIP: Fix spot fleets after the multi-part userdata improvement Fix spot fleets after the multi-part userdata improvement Jul 5, 2017
@mumoshu
Copy link
Contributor Author

mumoshu commented Jul 5, 2017

Closing this in favor of #735

@mumoshu mumoshu closed this Jul 5, 2017
@mumoshu mumoshu deleted the fix-spot-fleet branch August 22, 2017 03:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants