-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
pkg/destroy/bootstrap: Separate load-balancer target teardown #1148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"time" | ||
|
||
"github.com/openshift/installer/pkg/asset/cluster" | ||
"github.com/openshift/installer/pkg/terraform" | ||
|
@@ -24,17 +25,12 @@ func Destroy(dir string) (err error) { | |
return errors.New("no platform configured in metadata") | ||
} | ||
|
||
copyNames := []string{terraform.StateFileName, cluster.TfVarsFileName} | ||
|
||
if platform == "libvirt" { | ||
err = ioutil.WriteFile(filepath.Join(dir, "disable-bootstrap.tfvars"), []byte(`{ | ||
"bootstrap_dns": false | ||
err = ioutil.WriteFile(filepath.Join(dir, "disable-bootstrap-load-balancer-targets.tfvars"), []byte(`{ | ||
"bootstrap_load_balancer_targets": false | ||
} | ||
`), 0666) | ||
if err != nil { | ||
return err | ||
} | ||
copyNames = append(copyNames, "disable-bootstrap.tfvars") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tempDir, err := ioutil.TempDir("", "openshift-install-") | ||
|
@@ -43,20 +39,24 @@ func Destroy(dir string) (err error) { | |
} | ||
defer os.RemoveAll(tempDir) | ||
|
||
for _, filename := range copyNames { | ||
for _, filename := range []string{ | ||
terraform.StateFileName, | ||
cluster.TfVarsFileName, | ||
"disable-bootstrap-load-balancer-targets.tfvars", | ||
} { | ||
err = copy(filepath.Join(dir, filename), filepath.Join(tempDir, filename)) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to copy %s to the temporary directory", filename) | ||
} | ||
} | ||
|
||
if platform == "libvirt" { | ||
_, err = terraform.Apply(tempDir, platform, fmt.Sprintf("-var-file=%s", filepath.Join(tempDir, "disable-bootstrap.tfvars"))) | ||
if err != nil { | ||
return errors.Wrap(err, "Terraform apply") | ||
} | ||
_, err = terraform.Apply(tempDir, platform, fmt.Sprintf("-var-file=%s", filepath.Join(tempDir, "disable-bootstrap-load-balancer-targets.tfvars"))) | ||
if err != nil { | ||
return errors.Wrap(err, "Terraform apply") | ||
} | ||
|
||
time.Sleep(10 * time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is
from my topic post. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the AWS network load-balancer docs:
And from here:
The Terraform attachment-deletion logic is here, and while it fires a deregister request, it does not wait around for draining to complete. I don't see any issues in the provider repository about waiting for the unused state, but we could push something like that if we wanted more finesse here than a 10-second cross-platform sleep. I'm also fine just saying "we know who our consumers are at this point, and none of them will keep an open request going for more than 10 seconds", which is how I have it now. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
err = terraform.Destroy(tempDir, platform, "-target=module.bootstrap") | ||
if err != nil { | ||
return errors.Wrap(err, "Terraform destroy") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you have to send tear down event. Otherwise no draining will happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't for draining. This is waiting for the production control plane to enter the load balancer. The 10-second sleep in the destroy logic is for draining.