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

cmd/destroy: delete cluster asset after destroying cluster #547

Merged
merged 2 commits into from
Nov 3, 2018

Conversation

abhinavdahiya
Copy link
Contributor

@abhinavdahiya abhinavdahiya commented Oct 26, 2018

  1. asset/store: trim Store interface
    Save and Purge functions don't really seem to belong to Store interface.

Fetch fetches the asset, checkpoints the state file to disk and consumes
all the assets that were loaded from disk to create the asset.

Also fixes the error in save() where it would only save the assets in memory and
drops all the other assets present in the state file but were not fetched into the store's
asset map
eg:

./openshift-install ign configs # state has everything
./openshift-install install-config # state now only has assets uptill install-config, all the ign config assets are lost from statefile

./openshift-install ign configs # state has everything
./openshift-install install-config # state still includes all the state from 'ign-config' run.
  1. asset/store: add Destroy func to Store interface that allows destroying asset
    Destroy deletes the asset from all the possible sources, state file and disk.

  2. cmd/destroy: delete cluster asset after destroying cluster
    Regarding changes to cmd/create.go, each target is a variable to preserve the order when
    creating subcommands and still allow other functions to directly access each target individually.
    If could have stored them in maps, but maps returns in random order causing the cli options to look
    different on each run

/cc @rajatchopra @crawford

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 26, 2018
pkg/asset/asset.go Outdated Show resolved Hide resolved
pkg/asset/asset.go Outdated Show resolved Hide resolved
cmd/openshift-install/destroy.go Outdated Show resolved Hide resolved
cmd/openshift-install/destroy.go Outdated Show resolved Hide resolved
@abhinavdahiya
Copy link
Contributor Author

/retest

pkg/asset/store.go Outdated Show resolved Hide resolved
pkg/asset/asset.go Outdated Show resolved Hide resolved
pkg/asset/asset.go Outdated Show resolved Hide resolved
pkg/asset/store.go Outdated Show resolved Hide resolved
pkg/asset/asset.go Outdated Show resolved Hide resolved
pkg/asset/store.go Outdated Show resolved Hide resolved
@wking
Copy link
Member

wking commented Nov 2, 2018

Needs a rebase, now that #579 has landed and also touched cmd/openshift-install/create.go.

@abhinavdahiya
Copy link
Contributor Author

@wking green again :P

pkg/asset/store.go Outdated Show resolved Hide resolved
Save and Purge functions don't really seem to belong to Store interface.

Fetch fetches the asset, checkpoints the state file to disk and consumes
all the assets that were loaded from disk to create the asset.

Also fixes the error in save() where it would only save the assets in memory and
drops all the other assets present in the state file but were not fetched into the store's
asset map
eg:
```console
./openshift-install ign configs # state has everything
./openshift-install install-config # state now only has assets uptill install-config, all the ign config assets are lost from statefile

./openshift-install ign configs # state has everything
./openshift-install install-config # state still includes all the state from 'ign-config' run.
```

Destroy deletes the asset from all the possible sources, state file and disk.
regarding changes to cmd/create.go, each target is a variable to preserve the order when
creating subcommands and still allow other functions to directly access each target individually.
If could have stored them in maps, but maps returns in random order causing the cli options to look
different on each run
@wking
Copy link
Member

wking commented Nov 2, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 2, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,wking]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@abhinavdahiya
Copy link
Contributor Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 0f78fad into openshift:master Nov 3, 2018
@wking
Copy link
Member

wking commented Nov 3, 2018

I'd expected us to recurse through parents when pruning, but testing this now I see:

$ openshift-install --dir=wking --log-level=debug destroy cluster
DEBUG Deleting libvirt network                     
...
DEBUG goroutine deleteNetwork complete             
DEBUG Purging asset "Terraform Variables" from disk 
DEBUG Purging asset "Kubeconfig Admin" from disk   
DEBUG Purging asset "Cluster" from disk            

So it looks like we only remove the writeable assets. At least, there's certainly still a lot in the state file:

$ jq keys wking/.openshift_install_state.json 
[
  "*bootstrap.Bootstrap",
  "*installconfig.InstallConfig",
  "*installconfig.baseDomain",
  "*installconfig.clusterID",
  "*installconfig.clusterName",
  "*installconfig.emailAddress",
  "*installconfig.password",
  "*installconfig.platform",
  "*installconfig.pullSecret",
  "*installconfig.sshPublicKey",
  "*kubeconfig.Kubelet",
  "*machine.Master",
  "*machine.Worker",
  "*machines.ClusterK8sIO",
  "*machines.Master",
  "*machines.Worker",
  "*manifests.Manifests",
  "*manifests.Tectonic",
  "*manifests.kubeAddonOperator",
  "*manifests.networkOperator",
  "*tls.APIServerCertKey",
  "*tls.APIServerProxyCertKey",
  "*tls.AdminCertKey",
  "*tls.AggregatorCA",
  "*tls.EtcdCA",
  "*tls.EtcdClientCertKey",
  "*tls.IngressCertKey",
  "*tls.KubeCA",
  "*tls.KubeletCertKey",
  "*tls.MCSCertKey",
  "*tls.RootCA",
  "*tls.ServiceAccountKeyPair",
  "*tls.ServiceServingCA"
]

Was that intentional? Won't those entries (e.g. the 30-minute-valid kubelet cert) still pollute subsequent runs unless the state file is removed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants