Skip to content

Conversation

@mitchell-as
Copy link
Collaborator

@mitchell-as mitchell-as commented Aug 25, 2025

StoryCP-956 State Tool: Design ecosystem artifact remove and untrack.

I could not test Java and Rust because the language cores are not building. However, Rust is pretty much identical to .NET with how we are vendoring artifacts and Java is also similar, but with individual jars instead of directories. I am confident they work as expected.

@mitchell-as mitchell-as requested a review from Naatan August 25, 2025 21:27
@mitchell-as mitchell-as marked this pull request as ready for review August 25, 2025 21:27
Copy link
Contributor

@Naatan Naatan left a comment

Choose a reason for hiding this comment

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

Nice work! Just some minor churn.

func (d *depot) Track(id strfmt.UUID, deploy *deployment) error {
// The artifact parameter is only necessary for tracking dynamically imported artifacts after being
// added by an ecosystem.
func (d *depot) Track(id strfmt.UUID, deploy *deployment, artifact *buildplan.Artifact) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (d *depot) Track(id strfmt.UUID, deploy *deployment, artifact *buildplan.Artifact) error {
func (d *depot) Track(artifact *buildplan.Artifact, deploy *deployment) error {

Could you try to make this the behaviour? The reason this was using id was to keep it as dumb as possible. Obviously for artifacts that ship has now sailed, I'd prefer we're consistent then in so far as that is possible.

This also means updating the Deploy functions. The real question mark here is going to be the Save() function, which far as I can tell is "abusing" the Track() function in order to clean up the cache. I don't recall specifically what the exact behaviour is there nor can I quickly grok it, but I would suggest spending some time there to try and see if we can remove its reliance on Track(). If this turns into a deep rabbit hole please push back.

}

// If this is a dynamically imported artifact, tell the ecosystem to remove/undeploy it.
if artifact, exists := s.depot.config.Cache[id]; exists && artifact.Namespace != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you update the depot.Exists() function to return the artifact? I'd prefer we don't access private properties on the depot to keep the responsibilities clear.

if ecosys := filterEcosystemMatchingNamespace(s.ecosystems, artifact.Namespace); ecosys != nil {
installedFiles := []string{}
// Find record of our deployment
if deployments, ok := s.depot.config.Deployments[id]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make a public method on the depot to access this. Possibly you could even combine this with the artifact,extists logic above seeing as the deployment has the namespace in it. Something like depot.GetDeployments(id) []Deployment. Then check the namespace off os those.

installedFiles := []string{}
// Find record of our deployment
if deployments, ok := s.depot.config.Deployments[id]; ok {
deployments = sliceutils.Filter(deployments, func(d deployment) bool { return d.Path == s.path })
Copy link
Contributor

Choose a reason for hiding this comment

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

Might need fileutils.ResolveUniquePath() here. Note I thought we had something like fileutils.IsEqualPath() but apparently not, could be worth adding.

@mitchell-as mitchell-as requested a review from Naatan August 27, 2025 18:06
Copy link
Contributor

@Naatan Naatan left a comment

Choose a reason for hiding this comment

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

Nice work! Definitely feel like the depot is in a poor state right now due to the mix of responsibilities with DI, and the Deploy methods / Track methods stick out like a sore thumb. But that's a bigger issue, I like that this PR is going as far as reasonable to keep those painpoints minimal.

@mitchell-as
Copy link
Collaborator Author

I completely agree that the responsibilities need to be reworked. It definitely feels dirty.

@mitchell-as mitchell-as merged commit 905974f into master Aug 28, 2025
3 of 8 checks passed
@mitchell-as mitchell-as deleted the mitchell/cp-956 branch August 28, 2025 14:21
@mitchell-as mitchell-as restored the mitchell/cp-956 branch September 5, 2025 20:27
@mitchell-as mitchell-as deleted the mitchell/cp-956 branch December 8, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants