Skip to content

feat(cli): add dagger update command - #8839

Merged
jedevc merged 2 commits into
dagger:mainfrom
rajatjindal:update-cmd2
Jan 6, 2025
Merged

jedevc merged 2 commits into
dagger:mainfrom
rajatjindal:update-cmd2

Conversation

@rajatjindal

@rajatjindal rajatjindal commented Nov 2, 2024 •

Copy link
Copy Markdown
Contributor

This PR adds the dagger update command. Based on discussion in this ticket, we have decided not to update the version of the dependency (unless explicitly asked) but instead move the pin to the latest commit of the current version.

e.g.

given current dependency of <github.com/path/name>@<branch/tag>:

  • if the update command is dagger update github.com/path/name, it will update the pin to latest commit of the branch/tag.
  • however, if the update command is dagger update github.com/path/name@<diff-version>, it will update the pin to the latest commit for <diff-version> branch/tag.

potentially also fixes #8821

@rajatjindal
rajatjindal force-pushed the update-cmd2 branch 10 times, most recently from e6c3c89 to a6bf41a Compare November 8, 2024 02:36
Comment thread core/schema/module.go Resolved
@rajatjindal
rajatjindal force-pushed the update-cmd2 branch 2 times, most recently from 15f89de to 9d22635 Compare November 21, 2024 13:50
@rajatjindal
rajatjindal force-pushed the update-cmd2 branch 3 times, most recently from 13aae6e to 08a6a56 Compare December 3, 2024 10:31
@jedevc jedevc mentioned this pull request Dec 3, 2024
1 of 2 tasks
@marcosnils marcosnils added this to the v0.15.0 milestone Dec 3, 2024
@jedevc

jedevc commented Dec 3, 2024

Copy link
Copy Markdown
Contributor

As discussed in today's call earlier - currently an upgrade should only repin.

So if a user installs dep@v1 or dep@branch to install the v1 tag of the branch branch, then this will stay the same, and we'll just refetch that data from git, and set the pin differently.

We won't (for now) update the versions listed in dagger.json - e.g. v1.2.3 won't be upgraded to v1.2.4.

  • These semantics are a bit trickier to define - should we upgrade only patch? minor? major? etc.
  • There's space in the API / CLI for where to attach these later - this might look like dagger update --minor to update to the most recent minor version.
  • But I think this probably needs wider discussion with the team (especially those actively working on daggerverse) before we go ahead and make those changes.
  • We can ship an initial version of this ASAP which should help users who need the core update functionality.

@rajatjindal

rajatjindal commented Dec 3, 2024 •

Copy link
Copy Markdown
Contributor Author

based on the discussion today, following would be the end UX for dagger update after this PR:

Note: The current PR changes don't handle all the scenarios listed below yet.

tl;dr;

if user specifies a version update to that version, otherwise just re-pin to the latest commit of current branch/tag.

testcases

Current version in dagger.json mod provided by user for update After update comment
(no version specified) [email protected] [email protected]
[email protected] [email protected] [email protected]
...@foo-bar [email protected] [email protected]
(no version specified) (no version specified) (no version updated) re-pinned to latest of default branch
[email protected] (no version specified) [email protected] re-pinned to latest of v0.4.1
...@foo-bar (no version specified) ...@foo-bar re-pinned to latest of foo-bar
(no version specified) <just-name> (no version updated) re-pinned to latest of default branch
[email protected] <just-name> [email protected] re-pinned to latest of v0.4.1
...@foo-bar <just-name> ...@foo-bar re-pinned to latest of foo-bar
(no version specified) <just-name>@v0.4.2 [email protected]
[email protected] <just-name>@v0.4.2 [email protected]
...@foo-bar <just-name>@v0.4.2 [email protected]
...@foo-bar NO MOD PROVIDED re-pin all deps to the latest of their current version
dep does not exist with/without version error that dep not found in dep list

@jedevc

jedevc commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Gonna move this out of the milestone - it's not a release blocker, and its still in draft.

@shykes

shykes commented Dec 5, 2024

Copy link
Copy Markdown
Contributor

The dependency update UX makes sense to me.

Can we talk about engine and SDK update?

  • A module can specify any module as SDK. Presumably that dependency is also pinned. How do I update it?
  • A module can also specify an engine version. Updating that engine version is a common and important task for module devs. At the moment the UX for it is opaque and hard to guess (no command to do it explicitly; then we sneak it in when you develop). This seems like a good time to discuss how that UX might be improved and how it might fit with this.

@jedevc

jedevc commented Dec 5, 2024 •

Copy link
Copy Markdown
Contributor

A module can specify any module as SDK. Presumably that dependency is also pinned. How do I update it?

Hm, good point. #8587 didn't actually include the SDK.

We don't track the version separately from the pin, so we can't actually do it easily.

However, dagger update should upgrade the SDK similarly to all the modules I think (but we need to track source and pin separately).

Essentially:

// The SDK this module uses
SDK string `json:"sdk,omitempty"`

should become

	// The SDK this module uses
	SDK ModuleConfigDependency `json:"sdk,omitempty"`

Though, maybe the name field doesn't make as much sense 🤔 We could make name omitempty, which should resolve that.

I think this can be a follow-up after this, maybe @rajatjindal would be able to help out with this one too?

A module can also specify an engine version. Updating that engine version is a common and important task for module devs. At the moment the UX for it is opaque and hard to guess (no command to do it explicitly; then we sneak it in when you develop).

Mm, dagger develop was chosen as a point to do this to encourage it to be more automagic (instead of having lots of modules on very old versions which are difficult to support) - and to keep the existing behavior of the command.

I don't think dagger update should update the engine version - I think we should keep that command limited to our dependencies.

I think when originally working on module compat, I was hoping it would be mostly invisible from users - when you work on a module, you run dagger develop to get the API bindings - the API might have changed for the engine you're working against, so you might have to apply some backwards incompat changes yourself. The purpose of recording the engineVersion is more to keep old modules on daggerverse working, and to prevent running modules that might be incompatible - not really to allow users to target old versions.

Updating that engine version is a common and important task for module devs.

I think we should maybe unpack this more - why is this a common and important task for devs? It wasn't originally intended to be, so I think I'm missing something. I think we should try and make the experience smoother (and keep it relatively hidden), if that's at all possible, instead of trying to surface it more in the API.

One potential reason for surfacing it more would be to explicitly allow users to target old versions of the API - e.g. I want to write a module that works with dagger versions v0.12.0+, but I'm using v0.14.0. This doesn't work today though - we only guarantee to supply a compatible API to old versions, we don't guarantee to supply exactly the same API. We could change that though, if we were interested in that use case (though personally I'm hesitant to prioritize features that keep users on old dagger versions).

@rajatjindal
rajatjindal force-pushed the update-cmd2 branch 4 times, most recently from cf47446 to 3cef1c1 Compare December 6, 2024 05:56
@rajatjindal
rajatjindal marked this pull request as ready for review December 6, 2024 05:58
@rajatjindal
rajatjindal requested review from a team as code owners December 6, 2024 05:58
Comment thread .dagger/main.go Resolved
Comment thread cmd/dagger/module.go Resolved
Comment thread core/integration/module_cli_test.go Outdated
Comment on lines +1353 to +1364
name: "existing dep has version, update cmd has version",
initCmd: []string{"init", "--sdk=go", "--name=foo", "--source=."},
installCmds: [][]string{
{"install", "github.com/shykes/daggerverse/[email protected]"},
},
verifySetup: daggerjsonContains([]string{`"github.com/shykes/daggerverse/docker@docker/v0.4.1"`}),
updateCmd: []string{"update", "github.com/shykes/daggerverse/[email protected]"},
verifyFns: []func(t *testctx.T, daggerjson string){
daggerjsonContains([]string{`"github.com/shykes/daggerverse/docker@docker/v0.4.2"`}),
daggerjsonNotContains([]string{`github.com/shykes/daggerverse/docker@docker/v0.4.1`}),
},
expectedError: "",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • initCmd is always the same - so can be removed.
  • We don't need verifySetup - testing this behavior should actually be done in TestDaggerInstall (we shouldn't duplicate the testing)
  • daggerjsonContains is kinda neat, but I think we could just have contains and notContains properties right?
  • The default value of expectedErr is "" anyways - so we don't need to manually set it (same with all other zero values)

Just a heads-up - if the tests start to feel tricky to get all into one giant table test, that's not an issue - you can split up testing into subtests (e.g. you could one that tests the pin updating, another that tests upgrading to a specified branch/tag, etc). Not required, but that's another option if the table tests start to feel too large.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

initCmd is always the same - so can be removed.

This is done now.

We don't need verifySetup - testing this behavior should actually be done in TestDaggerInstall (we shouldn't duplicate the testing)

removed the verifySetup step. Also removed the dagger install step by using prebaked dagger.json files.

daggerjsonContains is kinda neat, but I think we could just have contains and notContains properties right?

done 👍

The default value of expectedErr is "" anyways - so we don't need to manually set it (same with all other zero values)

done.

Comment thread core/integration/module_cli_test.go Resolved
})
})

t.Run("installing a dependency with duplicate name is not allowed", func(ctx context.Context, t *testctx.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sure to add a test for two dependencies without explicit --names.

(though, note, this will probably fail until #9052 is merged - since at the point of checking, the name is actually empty 😢)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do we want to move the fix for this change to the other PR to keep similar functionality in same PR?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

added into fdb3eb5 (#9052)

Comment thread core/schema/modulesource.go Resolved
Comment thread core/schema/modulesource.go Resolved
Comment thread core/schema/modulesource.go Resolved
Comment thread core/schema/modulesource.go Resolved
@marcosnils

Copy link
Copy Markdown
Contributor

I think this can be a follow-up after this, maybe @rajatjindal would be able to help out with this one too?

SGTM! @rajatjindal let us know how's your backlog coming to tackle this one 🙏

@jedevc

jedevc commented Dec 10, 2024

Copy link
Copy Markdown
Contributor

I think this can be a follow-up after this, maybe @rajatjindal would be able to help out with this one too?

SGTM! @rajatjindal let us know how's your backlog coming to tackle this one 🙏

@marcosnils, I created a new issue for this: #9156

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
jedevc merged commit b4520c8 into dagger:main Jan 6, 2025
@jedevc jedevc added this to the v0.15.2 milestone Jan 6, 2025
@jedevc

jedevc commented Jan 6, 2025

Copy link
Copy Markdown
Contributor

Oops, realized this didn't have a changelog - @rajatjindal feel free to add one as a follow-up, otherwise I'll add one during the release process.

pjmagee pushed a commit to pjmagee/dagger that referenced this pull request Jan 9, 2025
Co-authored-by: Justin Chadwell <[email protected]>
Signed-off-by: Patrick Magee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dagger install should not allow duplicate deps

5 participants