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
Need to handle error when writing /etc/hosts #170
Conversation
Hey mattcui! Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA. |
We have created an issue in Pivotal Tracker to manage this: https://www.pivotaltracker.com/story/show/133721557 The labels on this github issue will be updated when the story is started. |
@maximilien The code is ready for review. Thanks. |
@mattcui please address each comment. I cannot review if you just ignore comments. What's the point? |
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.
Please address each and I will review again
vm, err := creator.Create(agentID, stemcell, cloudProps, networks, env) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(vm.ID()).To(Equal(1234567)) | ||
}) | ||
It("returns error when creating a new SoftLayerVM without bosh ip using non-root user", func() { |
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.
I think this It
description is incorrect
@@ -154,7 +154,7 @@ func UpdateEtcHostsOfBoshInit(record string) (err error) { | |||
logger := boshlog.NewWriterLogger(boshlog.LevelError, os.Stderr, os.Stderr) | |||
fs := boshsys.NewOsFileSystem(logger) | |||
|
|||
err = fs.WriteFile("/etc/hosts", buffer.Bytes()) | |||
err = fs.WriteFile(fileName, buffer.Bytes()) |
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.
You might want to mv
file instead of writing. So write to a temp file and mv
to the /etc/hosts
this is because mv
operation is atomic but cp
is not. This matters if there is an error during cp
. For mv
you will either have success or failure but not a file that is corrupted or half written.
LengthOfHostName int | ||
TIMEOUT time.Duration | ||
POLLING_INTERVAL time.Duration | ||
LocalDiskFlagNotSet bool |
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.
I am uncomfortable why these globals exist. I can understand if they need to be set. But the LocalDNSConfigurationFile
is always /etc/hosts
why not make it a constant? Is there a case where it will be different?
@mattcui see my submitted reviews. Please address each so we can move further. Thanks. |
@mattcui still waiting for changes on this one that addresses my comments. |
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.
I am merging to expedite but you need to address each comment by also stating what you did.
Cannot merge. You need to rebase and resolve conflicts |
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.
Cannot merge. You need to rebase and resolve conflicts
Still have conflicts |
@maximilien I solved all conflicts, it's ready for review and merge now, thanks. |
To address #133650831, the problem is reported from issue #168