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

Unlink unit charm dir symlink for application deployed before 2.8 bec… #11539

Closed
wants to merge 1 commit into from

Conversation

ycliuhw
Copy link
Member

@ycliuhw ycliuhw commented May 6, 2020

Checklist

  • Checked if it requires a pylibjuju change?
  • Added integration tests for the PR?
  • Added or updated doc.go related to packages changed?
  • Do comments answer the question of why design decisions were made?

Description of change

Unlink unit charm dir symlink for applications deployed before 2.8;

QA steps

  • Deploy k8s application on a 2.7 model;
  • upgrade controller then model to 2.8
  • check the model log to see if this error occur or not: cannot upgrade charm: rename /var/lib/juju/agents/unit-mariadb-k8s-0/charm/.juju-deploying /var/lib/juju/agents/unit-mariadb-k8s-0/charm/.juju-charm: no such file or directory

Documentation changes

No

Bug reference

https://bugs.launchpad.net/juju/+bug/1877025

@ycliuhw ycliuhw requested a review from wallyworld May 6, 2020 07:30
@ycliuhw
Copy link
Member Author

ycliuhw commented May 6, 2020

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

Is there a simple test that can be added?

@ycliuhw
Copy link
Member Author

ycliuhw commented May 6, 2020

Sure, I was about to add one today actually.

@@ -291,6 +290,23 @@ func (op *caasOperator) makeAgentSymlinks(unitTag names.UnitTag) error {
}
}

// Ensure legacy charm symlinks created before 2.8 getting unlinked.
Copy link
Member

Choose a reason for hiding this comment

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

I'd refactor this like to keep the success flow to the end of the function.
Makes it easier for the next person to add to the function.

	// Ensure legacy charm symlinks created before 2.8 getting unlinked.
	unitCharmDir := filepath.Join(op.config.DataDir, "agents", unitTag.String(), "charm")
	isUnitCharmDirSymlink, err := jujusymlink.IsSymlink(unitCharmDir)
	if os.IsNotExist(errors.Cause(err)) || os.IsPermission(errors.Cause(err)) {
		// Ignore permission denied as this won't happen in production
		// but may happen in testing depending on setup of /tmp	
	} else if err != nil {
		return errors.Trace(err)
	} else if isUnitCharmDirSymlink {
		op.config.Logger.Debugf("unlinking legacy charm symlink for unit %q", unitTag)
		if err := os.Remove(unitCharmDir); err != nil {
			return errors.Trace(err)
		}
	}

@ycliuhw
Copy link
Member Author

ycliuhw commented May 8, 2020

This PR has been merged to #11544, so close it now

@ycliuhw ycliuhw closed this May 8, 2020
@ycliuhw ycliuhw deleted the fix/lp-1877025 branch May 8, 2020 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants