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

Track deployment namespaces in Deployer #6170

Merged
merged 3 commits into from
Jul 13, 2021

Conversation

nkubala
Copy link
Contributor

@nkubala nkubala commented Jul 8, 2021

Related: #6117

Description

Currently, the Deploy() method defined on all Deployer implementations returns two values: any error seen during the deployment, and a list of namespaces deployed to. This list of namespaces is then returned back to the Runner, which updates them on the RunContext to be used later. This pattern is:

  1. Unnecessary, because all of the components that use runContext.GetNamespaces() live inside the Deployer implementation, and
  2. Problematic, because it defines a messy API for future Deployer implementations that have no use for the concept of a namespace

This change moves the tracking of all deployed namespaces into the Deployer, which can then feed those namespaces to any subcomponents that require them to function properly.

This changes the Deploy call to a very simple API:

Deploy(context.Context, io.Writer, []graph.Artifact) error

Additionally, all sub-components that provide a Start() method for orchestration by the Runner (Accessor, Debugger, Monitor, and Logger have had the namespaces parameter removed from their signatures. Using Accessor as an example:

type Accessor interface {
  Start(context.Context, io.Writer)
}

All Kubernetes-based Deployer implementations provide a trackNamespaces() method, called at the end of a Deploy(), which will update an internal []string with the new namespaces. This []string is then passed by reference to all subcomponents, which can consume whatever the contents are as the effective namespaces.

NOTE: We can safely use a *[]string to represent the active namespaces, as we know that no subcomponents will be activated by the Runner until the Deploy() call exits successfully.

This change is a non-functional refactor.

@nkubala nkubala requested review from yuwenma and a team as code owners July 8, 2021 22:25
@google-cla google-cla bot added the cla: yes label Jul 8, 2021
@nkubala nkubala force-pushed the deploy-namespaces branch 2 times, most recently from 58701ac to 35ef4ad Compare July 8, 2021 22:45
@codecov
Copy link

codecov bot commented Jul 8, 2021

Codecov Report

Merging #6170 (b6debf8) into master (634ad08) will increase coverage by 0.06%.
The diff coverage is 68.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6170      +/-   ##
==========================================
+ Coverage   71.20%   71.27%   +0.06%     
==========================================
  Files         481      479       -2     
  Lines       21587    21550      -37     
==========================================
- Hits        15371    15359      -12     
+ Misses       5235     5212      -23     
+ Partials      981      979       -2     
Impacted Files Coverage Δ
pkg/skaffold/access/access_mux.go 0.00% <0.00%> (ø)
pkg/skaffold/debug/debugger_mux.go 0.00% <0.00%> (ø)
pkg/skaffold/log/logger_mux.go 0.00% <0.00%> (ø)
pkg/skaffold/runner/notification.go 0.00% <0.00%> (ø)
pkg/skaffold/runner/runcontext/context.go 90.07% <ø> (+0.52%) ⬆️
pkg/skaffold/runner/v1/apply.go 0.00% <0.00%> (ø)
pkg/skaffold/runner/v1/dev.go 73.12% <0.00%> (ø)
pkg/skaffold/sync/sync.go 73.21% <0.00%> (ø)
pkg/skaffold/runner/v1/deploy.go 76.47% <33.33%> (-0.35%) ⬇️
pkg/skaffold/deploy/deploy_mux.go 45.45% <50.00%> (-3.30%) ⬇️
... and 15 more

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 634ad08...b6debf8. Read the comment docs.

tejal29
tejal29 previously requested changes Jul 8, 2021
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

Can we get rid of all the Provider interfaces before this. That would help clean up few interfaces.

Copy link
Contributor

@MarlonGamez MarlonGamez left a comment

Choose a reason for hiding this comment

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

couple small nits, nothing major

@nkubala
Copy link
Contributor Author

nkubala commented Jul 8, 2021

Can we get rid of all the Provider interfaces before this. That would help clean up few interfaces.

@tejal29 should that block this change? not saying we shouldn't clean it up, but I'm not convinced it needs to happen before this, it seems a bit orthogonal.

@tejal29
Copy link
Contributor

tejal29 commented Jul 8, 2021

All Kubernetes-based Deployer implementations provide a trackNamespaces() method, called at the end of a Deploy(), which will update an internal []string with the new namespaces. This []string is then passed by reference to all subcomponents, which can consume whatever the contents are as the effective namespaces.

Is this namespace now part of Deploy Object. Can we remove it from RunContext?
Also a bunch of methods in PortForwarder, Logger and Debugger have changed right?
Can you list them in the description

@tejal29
Copy link
Contributor

tejal29 commented Jul 8, 2021

Can we get rid of all the Provider interfaces before this. That would help clean up few interfaces.

@tejal29 should that block this change? not saying we shouldn't clean it up, but I'm not convinced it needs to happen before this, it seems a bit orthogonal.

The number of unnecessary changes in this PR will reduce. If we do them later, we will be adding a bunch of changes and then deleting them in the later PR.

@nkubala nkubala force-pushed the deploy-namespaces branch from 0e1a3ac to c2b042f Compare July 13, 2021 20:14
@nkubala
Copy link
Contributor Author

nkubala commented Jul 13, 2021

@tejal29

Is this namespace now part of Deploy Object. Can we remove it from RunContext?

Good catch, meant to do this. Updated

Also a bunch of methods in PortForwarder, Logger and Debugger have changed right? Can you list them in the description?

Done.

#6190 has also been merged to remove the Provider interfaces, which should make this PR easier to review.

@nkubala nkubala dismissed tejal29’s stale review July 13, 2021 21:00

addressed all requested changes

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

LGMT.

Testing deploy now.

// cluster. Returns the list of impacted namespaces.
Deploy(context.Context, io.Writer, []graph.Artifact) ([]string, error)
// cluster.
Deploy(context.Context, io.Writer, []graph.Artifact) error
Copy link
Contributor

Choose a reason for hiding this comment

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

yay!

@tejal29
Copy link
Contributor

tejal29 commented Jul 13, 2021

Testing Notes

  1. trackNamespaces is called in all 4 deployers.
    image

  2. Debug works for cloudcode-samples/nodejs/ in default namespace.

  • debugging break point hit.
  • portfowarded urls working.
  1. Debug works for cloudcode-samples/nodejs/ in a test namespace using SKAFFOLD_NAMESPACE environment variable in debug config.
  • debugging break point hit.
  • portfowarded urls working.
  1. Testing helm deplyer
➜  helm-deployment git:(deploy-namespaces) ✗ skaffold dev --namespace test
 - test:deployment/skaffold-helm is ready.
Deployments stabilized in 2.235 seconds
Press Ctrl+C to exit
Watching for changes...
[skaffold-helm] Hello world! 0
[skaffold-helm] Hello world! 1
[skaffold-helm] Hello world! 0
[skaffold-helm] Hello world! 1
[skaffold-helm] Hello world! 2
[skaffold-helm] Hello world! 2

@nkubala nkubala merged commit 7b18b11 into GoogleContainerTools:master Jul 13, 2021
@nkubala nkubala deleted the deploy-namespaces branch July 13, 2021 22:06
@gsquared94
Copy link
Contributor

a bad merge seems to have reverted #6135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants