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

Add support to secrets #449

Merged
merged 7 commits into from
Mar 14, 2018
Merged

Add support to secrets #449

merged 7 commits into from
Mar 14, 2018

Conversation

drgarcia1986
Copy link
Contributor

There is a problem, change one secret that already exists doesn't perform the rolling update (because the deploy spec doesn't change).

@codecov-io
Copy link

codecov-io commented Mar 13, 2018

Codecov Report

Merging #449 into master will decrease coverage by 0.26%.
The diff coverage is 38.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #449      +/-   ##
==========================================
- Coverage   49.64%   49.38%   -0.27%     
==========================================
  Files          63       63              
  Lines        4083     4299     +216     
==========================================
+ Hits         2027     2123      +96     
- Misses       1913     2019     +106     
- Partials      143      157      +14
Impacted Files Coverage Δ
pkg/server/k8s/client.go 0% <0%> (ø) ⬆️
pkg/server/app/fake.go 98.72% <100%> (+0.14%) ⬆️
pkg/server/spec/pod.go 84.28% <100%> (ø) ⬆️
pkg/server/app/handlers.go 91.11% <100%> (+1.23%) ⬆️
pkg/server/k8s/converters.go 88.69% <100%> (+0.48%) ⬆️
pkg/server/spec/container.go 55% <100%> (+0.76%) ⬆️
pkg/client/cmd/app.go 10.37% <6.06%> (-0.06%) ⬇️
pkg/server/app/app.go 73.31% <60%> (-3.73%) ⬇️
pkg/server/app/models.go 86.07% <60%> (-2.74%) ⬇️

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 fa39e49...fd94268. Read the comment docs.

@drgarcia1986
Copy link
Contributor Author

There's a way to "hack" this problem, according to this comment, we can change (or create) an annotation inside of the spec of deploy (spec.template.metadata.annotations) with a random value or the current date (doesn't matter).
I made some simple tests and works fine, but, every env-[un]set and secret-[un]set will perform a rolling update, what do you think guys?

aguerra
aguerra previously approved these changes Mar 14, 2018
Copy link
Contributor

@aguerra aguerra left a comment

Choose a reason for hiding this comment

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

LGTM

ops.(*AppOperations).kops = &errK8sOperations{
CreateOrUpdateDeploySecretEnvVarsErr: ErrInvalidEnvVarName,
GetSecretErr: ErrNotFound,
NamespaceErr: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess NamespaceErr is already nil, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, my fault

if _, err := cli.SetSecret(context.Background(), req); err != nil {
client.PrintErrorAndExit(client.GetErrorMsg(err))
}
fmt.Println("Env vars updated with success")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe Secrets updated? As a secret is exposed as env var I don't know which is best

@@ -712,9 +861,15 @@ func init() {

appEnvSetCmd.Flags().String("app", "", "app name")
appEnvSetCmd.Flags().Bool("no-input", false, "set env vars without warning")
// App unset env vars
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

CHANGELOG.md Outdated
- support to filter app logs by container name
- Support for internal apps
- Support to filter app logs by container name
- Support to Secrets as env var
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe Support to set secrets as env vars

currentClusterName := cfgCluster
if currentClusterName == "" {
var err error
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 why?

Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to solve go build issue:

pkg/client/cmd/app.go|418| 30: currentClusterName declared and not used

😢

@aguerra
Copy link
Contributor

aguerra commented Mar 14, 2018

For me there's no problem in always doing a rolling update.

yagonobre
yagonobre previously approved these changes Mar 14, 2018
Copy link
Contributor

@yagonobre yagonobre left a comment

Choose a reason for hiding this comment

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

LGTM

currentClusterName := cfgCluster
if currentClusterName == "" {
var err error
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔

@@ -784,6 +796,35 @@ func (c *Client) patchCronJobEnvVars(namespace, name string, v interface{}) erro
return errors.Wrap(err, "patch cronjob failed")
}

func convertAppSecretEnvVar(secretName string, secrets []string) interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe put this on converters.go

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'm not sure, converters.go is for teresa struct -> k8s struct

@yagonobre
Copy link
Contributor

Agree with @aguerra

@drgarcia1986
Copy link
Contributor Author

Thanks @aguerra and @yagonobre I'll add the "fake" annotation to forces the rolling update

This change forces an rolling update on each [env|secret]-[un]set command
@drgarcia1986 drgarcia1986 dismissed stale reviews from yagonobre and aguerra via fd94268 March 14, 2018 19:24
@drgarcia1986
Copy link
Contributor Author

@aguerra @yagonobre UPDATED

Copy link
Contributor

@yagonobre yagonobre left a comment

Choose a reason for hiding this comment

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

🔁

Copy link
Contributor

@aguerra aguerra left a comment

Choose a reason for hiding this comment

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

🔁

@drgarcia1986 drgarcia1986 merged commit 81bb53c into master Mar 14, 2018
@drgarcia1986 drgarcia1986 deleted the secrets branch March 14, 2018 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants