Skip to content

Commit 65adfa0

Browse files
committed
chore: merge 3.6 to main
2 parents 5175f08 + 8a560af commit 65adfa0

File tree

29 files changed

+329
-57
lines changed

29 files changed

+329
-57
lines changed

.github/workflows/docs-sphinx-python-dependency-build-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install dependencies
3131
run: |
3232
set -ex
33-
sudo apt update
33+
sudo apt -y update
3434
sudo apt -y install \
3535
cargo \
3636
libpython3-dev \

api/apiclient.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ func (c *conn) connectStream(path string, attrs url.Values, extraHeaders http.He
359359
return nil, errors.Trace(err)
360360
}
361361
requestHeader.Set(params.JujuClientVersion, jujuversion.Current.String())
362-
requestHeader.Set("Origin", "http://localhost/")
363362
for header, values := range extraHeaders {
364363
for _, value := range values {
365364
requestHeader.Add(header, value)

apiserver/server_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ func dialWebsocket(c *gc.C, addr, path string) (*websocket.Conn, error) {
201201
// TODO(rogpeppe) merge this with the very similar dialWebsocketFromURL function.
202202
url := fmt.Sprintf("wss://%s%s", addr, path)
203203
header := make(http.Header)
204-
header.Set("Origin", "http://localhost/")
205204
caCerts := x509.NewCertPool()
206205
c.Assert(caCerts.AppendCertsFromPEM([]byte(coretesting.CACert)), jc.IsTrue)
207206
tlsConfig := jujuhttp.SecureTLSConfig()

cmd/juju/application/refresh.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ type refreshCommand struct {
130130
NewRefresherFactory func(refresher.RefresherDependencies) refresher.RefresherFactory
131131

132132
ApplicationName string
133+
134+
// Base represents the base (eg [email protected]) of the new charm to use
135+
Base string
133136
// Force should be ubiquitous and we should eventually deprecate both
134137
// ForceUnits and ForceBase; instead just using "force"
135138
Force bool
@@ -181,12 +184,12 @@ updated copy of the charm.
181184
182185
Deploying from a path is intended to suit the workflow of a charm author working
183186
on a single client machine; use of this deployment method from multiple clients
184-
is not supported and may lead to confusing behaviour. Each local packaged charm
185-
gets uploaded with the revision specified in the charm, if possible, otherwise
187+
is not supported and may lead to confusing behaviour. Each local packaged charm
188+
gets uploaded with the revision specified in the charm, if possible, otherwise
186189
it gets a unique revision (highest in state + 1).
187190
188191
When deploying from a path, the --path option is used to specify the location
189-
of the packaged charm. Note that the charm must match what was originally used
192+
of the packaged charm. Note that the charm must match what was originally used
190193
to deploy the charm as a superficial check that the updated charm is compatible.
191194
192195
Resources may be uploaded at upgrade time by specifying the --resource option.
@@ -290,8 +293,10 @@ func (c *refreshCommand) SetFlags(f *gnuflag.FlagSet) {
290293
f.BoolVar(&c.ForceUnits, "force-units", false, "Refresh all units immediately, even if in error state")
291294
f.StringVar(&c.channelStr, "channel", "", "Channel to use when getting the charm from Charmhub")
292295
f.BoolVar(&c.ForceBase, "force-series", false, "Refresh even if series of deployed applications are not supported by the new charm")
296+
f.BoolVar(&c.ForceBase, "force-base", false, "Refresh even if the base of the deployed application is not supported by the new charm")
293297
f.StringVar(&c.SwitchURL, "switch", "", "Crossgrade to a different charm")
294-
f.StringVar(&c.CharmPath, "path", "", "Refresh to a charm package located at path")
298+
f.StringVar(&c.CharmPath, "path", "", "Refresh to a charm located at path")
299+
f.StringVar(&c.Base, "base", "", "Select a different base than what is currently running.")
295300
f.IntVar(&c.Revision, "revision", -1, "Explicit revision of current charm")
296301
f.Var(stringMap{mapping: &c.Resources}, "resource", "Resource to be uploaded to the controller")
297302
f.Var(storageFlag{stores: &c.Storage, bundleStores: nil}, "storage", "Charm storage directives")
@@ -397,6 +402,17 @@ func (c *refreshCommand) Run(ctx *cmd.Context) error {
397402
return errors.Errorf("%q deploy incomplete, please try refresh again in a little bit.", c.ApplicationName)
398403
}
399404

405+
newOrigin := oldOrigin
406+
if c.Base != "" {
407+
if newBase, err := corebase.ParseBaseFromString(c.Base); err != nil {
408+
return errors.Trace(err)
409+
} else {
410+
newOrigin.Base.OS = newBase.OS
411+
newOrigin.Base.Channel = newBase.Channel
412+
413+
}
414+
}
415+
400416
// Set a default URL schema for charm URLs that don't provide one.
401417
var defaultCharmSchema = charm.CharmHub
402418

@@ -453,7 +469,7 @@ func (c *refreshCommand) Run(ctx *cmd.Context) error {
453469
cfg := refresher.RefresherConfig{
454470
ApplicationName: c.ApplicationName,
455471
CharmURL: oldURL,
456-
CharmOrigin: oldOrigin.CoreCharmOrigin(),
472+
CharmOrigin: newOrigin.CoreCharmOrigin(),
457473
CharmRef: newRef,
458474
Channel: c.Channel,
459475
Force: c.Force,

cmd/juju/application/refresh_test.go

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,9 @@ func (s *RefreshSuite) TestForcedSeriesUpgrade(c *gc.C) {
722722
c.Fatal(errors.Annotate(err, "cannot write to metadata.yaml"))
723723
}
724724

725+
// TODO (jam) 2024-11-15: this test is kept for backward compatibility,
726+
// in 3.x the --force-series argument exists, though it is being
727+
// replaced by --force-base
725728
_, err = s.runRefresh(c, "multi-series", "--path", s.archivePath(c, repoPath), "--force-series")
726729
c.Assert(err, jc.ErrorIsNil)
727730

@@ -744,6 +747,94 @@ func (s *RefreshSuite) TestForcedSeriesUpgrade(c *gc.C) {
744747
})
745748
}
746749

750+
// func (s *RefreshSuite) TestForcedBaseUpgrade(c *gc.C) {
751+
// repoPath := testcharms.RepoWithSeries("jammy").ClonedDirPath(c.MkDir(), "multi-base")
752+
// err := runDeploy(c, repoPath, "multi-base", "--base", "[email protected]")
753+
// c.Assert(err, jc.ErrorIsNil)
754+
// app, err := s.State.Application("multi-base")
755+
// c.Assert(err, jc.ErrorIsNil)
756+
// ch, _, err := app.Charm()
757+
// c.Assert(err, jc.ErrorIsNil)
758+
// c.Assert(ch.Revision(), gc.Equals, 1)
759+
760+
// units, err := app.AllUnits()
761+
// c.Assert(err, jc.ErrorIsNil)
762+
// c.Assert(units, gc.HasLen, 1)
763+
// unit := units[0]
764+
// tags := []names.UnitTag{unit.UnitTag()}
765+
// errs, err := unitassigner.New(s.APIState).AssignUnits(tags)
766+
// c.Assert(err, jc.ErrorIsNil)
767+
// c.Assert(errs, gc.DeepEquals, make([]error, len(units)))
768+
769+
// // Overwrite the manifest.yaml to change the supported series.
770+
// manifestPath := filepath.Join(repoPath, "manifest.yaml")
771+
// file, err := os.OpenFile(manifestPath, os.O_TRUNC|os.O_RDWR, 0666)
772+
// if err != nil {
773+
// c.Fatal(errors.Annotate(err, "cannot open manifest.yaml for overwriting"))
774+
// }
775+
// defer func() { _ = file.Close() }()
776+
777+
// // We deployed a version of the charm that supported jammy (22.04), but
778+
// // now we declare that this charm only supports focal, but with a
779+
// // --force-base we are allowed to target it anyway.
780+
// manifest := strings.Join(
781+
// []string{
782+
// `bases:`,
783+
// `- architectures:`,
784+
// ` - amd64`,
785+
// // Now only supports focal
786+
// ` channel: '20.04'`,
787+
// ` name: ubuntu`,
788+
// },
789+
// "\n",
790+
// )
791+
// if _, err := file.WriteString(manifest); err != nil {
792+
// c.Fatal(errors.Annotate(err, "cannot write to manifest.yaml"))
793+
// }
794+
795+
// s.charmClient.charmInfo = &apicommoncharms.CharmInfo{
796+
// URL: ch.URL(),
797+
// Meta: ch.Meta(),
798+
// Revision: ch.Revision(),
799+
// }
800+
// // First confirm that normal refresh would be refused
801+
// _, err = s.runRefresh(c, s.cmd, "multi-base", "--path", repoPath)
802+
// c.Check(err, gc.NotNil)
803+
// c.Check(err, gc.ErrorMatches, `.*base "[email protected]" not supported by charm, the charm supported bases are: [email protected]`)
804+
// // jam (2024-11-15): The structure of this test suite is that you can only run
805+
// // Refresh one time without reinitializing it. Since we are doing it 2x to test
806+
// // that it fails properly before succeeding, we have to reset the internal structure
807+
// // commands report back errors about "no model selected"
808+
// s.cmd = NewRefreshCommandForStateTest(
809+
// newCharmAdder,
810+
// func(conn base.APICallCloser) utils.CharmClient {
811+
// return &s.charmClient
812+
// },
813+
// deployer.DeployResources,
814+
// nil,
815+
// )
816+
817+
// err = app.Refresh()
818+
// c.Assert(err, jc.ErrorIsNil)
819+
// ch, _, err = app.Charm()
820+
// c.Assert(err, jc.ErrorIsNil)
821+
// // The charm should not have changed
822+
// c.Check(ch.Revision(), gc.Equals, 1)
823+
824+
// // But with --force-base we are happy
825+
// _, err = s.runRefresh(c, s.cmd, "multi-base", "--path", repoPath, "--force-base")
826+
// c.Assert(err, jc.ErrorIsNil)
827+
828+
// err = app.Refresh()
829+
// c.Assert(err, jc.ErrorIsNil)
830+
831+
// ch, force, err := app.Charm()
832+
// c.Assert(err, jc.ErrorIsNil)
833+
// // Check charm is at revision 3 because the local charm is uploaded twice more.
834+
// c.Check(ch.Revision(), gc.Equals, 3)
835+
// c.Check(force, gc.Equals, false)
836+
// }
837+
747838
func (s *RefreshSuite) TestForcedUnitsUpgrade(c *gc.C) {
748839
s.BaseRefreshSuite.setup(c, corebase.MustParseBaseFromString("[email protected]"), charm.MustParseURL("ch:riak"), charm.MustParseURL("ch:riak"))
749840
s.charmAPIClient.charmOrigin = commoncharm.Origin{Base: corebase.MustParseBaseFromString("[email protected]")}

cmd/juju/user/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func (c *loginCommand) publicControllerLogin(
398398
})
399399
},
400400
),
401-
api.NewLegacyLoginProvider(names.UserTag{}, "", "", nil, bclient, cookieURL),
401+
api.NewLegacyLoginProvider(nil, "", "", nil, bclient, cookieURL),
402402
)
403403

404404
// Keep track of existing interactors as the dial callback will create

cmd/plugins/juju-metadata/imagemetadata.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ func (c *imageMetadataCommand) setParams(context *cmd.Context, base corebase.Bas
164164
c.Endpoint = cloudSpec.Endpoint
165165
}
166166
}
167-
cfg := environ.Config()
168167

169-
// If we have a base, overwrite that from the environment.
170-
if b := config.PreferredBase(cfg); !b.Empty() {
171-
base = b
168+
// If we don't have a base set, then look up the one from the
169+
// environment configuration.
170+
if c.Base == "" {
171+
cfg := environ.Config()
172+
173+
if b := config.PreferredBase(cfg); !b.Empty() {
174+
base = b
175+
}
172176
}
173177
} else {
174178
logger.Warningf("bootstrap parameters could not be opened: %v", err)

cmd/plugins/juju-metadata/imagemetadata_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,23 @@ func (s *ImageMetadataSuite) TestImageMetadataFilesUsingEnv(c *gc.C) {
184184
s.assertCommandOutput(c, expected, out, defaultIndexFileName, defaultImageFileName)
185185
}
186186

187+
func (s *ImageMetadataSuite) TestImageMetadataFilesUsingEnvWithoutUsingBase(c *gc.C) {
188+
ctx, err := runImageMetadata(c, s.store,
189+
"-d", s.dir, "-c", "ec2-controller", "-i", "1234", "--virt-type=pv", "--storage=root", "[email protected]",
190+
)
191+
c.Assert(err, jc.ErrorIsNil)
192+
out := cmdtesting.Stdout(ctx)
193+
expected := expectedMetadata{
194+
version: "20.04",
195+
arch: "amd64",
196+
region: "us-east-1",
197+
endpoint: "https://ec2.us-east-1.amazonaws.com",
198+
virtType: "pv",
199+
storage: "root",
200+
}
201+
s.assertCommandOutput(c, expected, out, defaultIndexFileName, defaultImageFileName)
202+
}
203+
187204
func (s *ImageMetadataSuite) TestImageMetadataFilesUsingEnvWithRegionOverride(c *gc.C) {
188205
ctx, err := runImageMetadata(c, s.store,
189206
"-d", s.dir, "-c", "ec2-controller", "-r", "us-west-1", "-u", "https://ec2.us-west-1.amazonaws.com", "-i", "1234",

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ require (
1414
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0
1515
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.1.0
1616
github.com/EvilSuperstars/go-cidrman v0.0.0-20190607145828-28e79e32899a
17-
github.com/aws/aws-sdk-go-v2 v1.24.0
17+
github.com/aws/aws-sdk-go-v2 v1.32.5
1818
github.com/aws/aws-sdk-go-v2/config v1.26.2
1919
github.com/aws/aws-sdk-go-v2/credentials v1.16.13
20-
github.com/aws/aws-sdk-go-v2/service/ec2 v1.142.0
20+
github.com/aws/aws-sdk-go-v2/service/ec2 v1.193.0
2121
github.com/aws/aws-sdk-go-v2/service/ecr v1.24.6
2222
github.com/aws/aws-sdk-go-v2/service/iam v1.28.6
2323
github.com/aws/aws-sdk-go-v2/service/s3 v1.47.7
24-
github.com/aws/smithy-go v1.19.0
24+
github.com/aws/smithy-go v1.22.1
2525
github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f
2626
github.com/canonical/go-dqlite v1.21.0
2727
github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a
28-
github.com/canonical/pebble v1.16.0
2928
github.com/canonical/sqlair v0.0.0-20240417091145-13970327005b
29+
github.com/canonical/pebble v1.17.0
3030
github.com/chzyer/readline v1.5.1
3131
github.com/coreos/go-systemd/v22 v22.5.0
3232
github.com/docker/distribution v2.8.3+incompatible
@@ -147,13 +147,13 @@ require (
147147
github.com/adrg/xdg v0.3.3 // indirect
148148
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
149149
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.10 // indirect
150-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
151-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
150+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect
151+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect
152152
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 // indirect
153153
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.9 // indirect
154-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
154+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect
155155
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.9 // indirect
156-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.9 // indirect
156+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect
157157
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9 // indirect
158158
github.com/aws/aws-sdk-go-v2/service/sso v1.18.5 // indirect
159159
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.5 // indirect

0 commit comments

Comments
 (0)