Skip to content

Commit

Permalink
Merge pull request #8951 from olemarkus/automated-cherry-pick-of-#894…
Browse files Browse the repository at this point in the history
…5-origin-release-1.17

Automated cherry pick of #8945: Load the correct certificate before deleting
  • Loading branch information
k8s-ci-robot committed Apr 22, 2020
2 parents df11e39 + 59b6c16 commit 5ece47b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions upup/pkg/fi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ go_test(
],
embed = [":go_default_library"],
deps = [
"//pkg/apis/kops:go_default_library",
"//pkg/pki:go_default_library",
"//util/pkg/vfs:go_default_library",
],
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/vfs_castore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ func (c *VFSCAStore) deletePrivateKey(name string, id string) (bool, error) {
func (c *VFSCAStore) deleteCertificate(name string, id string) (bool, error) {
// Update the bundle
{
p := c.buildPrivateKeyPoolPath(name)
p := c.buildCertificatePoolPath(name)
ks, err := c.loadCertificates(p, false)
if err != nil {
return false, err
Expand Down
17 changes: 17 additions & 0 deletions upup/pkg/fi/vfs_castore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"
"time"

"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/pki"
"k8s.io/kops/util/pkg/vfs"
)
Expand Down Expand Up @@ -214,4 +215,20 @@ spec:
}
}

// Check that keyset gets deleted
{
keyset := &kops.Keyset{}
keyset.Name = "ca"
keyset.Spec.Type = kops.SecretTypeKeypair

s.DeleteKeysetItem(keyset, "237054359138908419352140518924933177492")

_, err := pathMap["memfs://tests/private/ca/237054359138908419352140518924933177492.key"].ReadFile()
pathMap["memfs://tests/private/ca/237054359138908419352140518924933177492.key"].ReadFile()
if err == nil {
t.Fatalf("File memfs://tests/private/ca/237054359138908419352140518924933177492.key still exists")
}

}

}

0 comments on commit 5ece47b

Please sign in to comment.