From 99faf8bb437944e2c9b590991cb42b18441cd40f Mon Sep 17 00:00:00 2001 From: Vitaly Antonenko Date: Tue, 26 Mar 2024 17:03:58 +0300 Subject: [PATCH 1/7] Add condition for handling empty security groups This commit introduces a new condition to handle scenarios where the security group is empty. This enhances the robustness of our security group handling logic and prevents potential errors due to empty security groups. --- tests/includes/wait-for.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/includes/wait-for.sh b/tests/includes/wait-for.sh index 6a6ac15ecb0..7fef3fc846d 100644 --- a/tests/includes/wait-for.sh +++ b/tests/includes/wait-for.sh @@ -351,7 +351,7 @@ wait_for_aws_ingress_cidrs_for_port_range() { secgrp_list=$(aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=${from_port} Name=ip-permission.to-port,Values=${to_port}) # print the security group rules # shellcheck disable=SC2086 - got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -) + got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions // [] | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges // [] | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -) attempt=0 # shellcheck disable=SC2046,SC2143 @@ -360,7 +360,7 @@ wait_for_aws_ingress_cidrs_for_port_range() { # shellcheck disable=SC2086 secgrp_list=$(aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=${from_port} Name=ip-permission.to-port,Values=${to_port}) # shellcheck disable=SC2086 - got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -) + got_cidrs=$(echo ${secgrp_list} | jq -r ".SecurityGroups[0].IpPermissions // [] | .[] | select(.FromPort == ${from_port} and .ToPort == ${to_port}) | .Ip${ipV6Suffix}Ranges // [] | .[] | .CidrIp${ipV6Suffix}" | sort | paste -sd, -) sleep "${SHORT_TIMEOUT}" if [ "$got_cidrs" == "$exp_cidrs" ]; then From 3404cab4af9e4c007124768675e5d27e78e37e46 Mon Sep 17 00:00:00 2001 From: jujubot Date: Thu, 28 Mar 2024 05:16:07 +0000 Subject: [PATCH 2/7] Increment juju to 3.4.2 --- scripts/win-installer/setup.iss | 2 +- snap/snapcraft.yaml | 2 +- version/version.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/win-installer/setup.iss b/scripts/win-installer/setup.iss index cc95d5ec471..a566850ec62 100644 --- a/scripts/win-installer/setup.iss +++ b/scripts/win-installer/setup.iss @@ -4,7 +4,7 @@ #if GetEnv('JUJU_VERSION') != "" #define MyAppVersion=GetEnv('JUJU_VERSION') #else -#define MyAppVersion="3.4.1" +#define MyAppVersion="3.4.2" #endif #define MyAppName "Juju" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 64a63685078..dc80462204d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: juju -version: 3.4.1 +version: 3.4.2 summary: Juju - a model-driven operator lifecycle manager for K8s and machines license: AGPL-3.0 description: | diff --git a/version/version.go b/version/version.go index 34571fa5413..3e506bd7d49 100644 --- a/version/version.go +++ b/version/version.go @@ -18,7 +18,7 @@ import ( // The presence and format of this constant is very important. // The debian/rules build recipe uses this value for the version // number of the release package. -const version = "3.4.1" +const version = "3.4.2" // UserAgentVersion defines a user agent version used for communication for // outside resources. From d08bb1423f0dc3623e82b4c00b3ba6491ab70695 Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Wed, 3 Apr 2024 17:01:48 +1300 Subject: [PATCH 3/7] Bump Pebble version to v1.7.4 (require admin access for file pull API) This includes the fix to lock down the files "pull" (read) API to requires admin: https://github.com/canonical/pebble/commit/4ca343d3889533143477e21c63867f2f3c3b5645 Fixes CVE-2024-3250 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 186d45c4da5..d00ebde0681 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f github.com/canonical/go-dqlite v1.21.0 github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a - github.com/canonical/pebble v1.7.3 + github.com/canonical/pebble v1.7.4 github.com/chzyer/readline v1.5.1 github.com/coreos/go-systemd/v22 v22.5.0 github.com/docker/distribution v2.8.3+incompatible diff --git a/go.sum b/go.sum index d29c4a4db67..d9112160bf6 100644 --- a/go.sum +++ b/go.sum @@ -152,8 +152,8 @@ github.com/canonical/go-flags v0.0.0-20230403090104-105d09a091b8 h1:zGaJEJI9qPVy github.com/canonical/go-flags v0.0.0-20230403090104-105d09a091b8/go.mod h1:ZZFeR9K9iGgpwOaLYF9PdT44/+lfSJ9sQz3B+SsGsYU= github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a h1:Tfo/MzXK5GeG7gzSHqxGeY/669Mhh5ea43dn1mRDnk8= github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a/go.mod h1:UxfHGKFoRjgu1NUA9EFiR++dKvyAiT0h9HT0ffMlzjc= -github.com/canonical/pebble v1.7.3 h1:fpK/ut6FlNOjqqQ+9DjNSw43L4wl2aFMgRZGmAoHmnY= -github.com/canonical/pebble v1.7.3/go.mod h1:bROzibw902Vastd13S/H48BrVAjEUKnlRXv3ZIoFcPE= +github.com/canonical/pebble v1.7.4 h1:2/TTP1ORhRUp4xjP9eAOuWYlPjHMgkdhk3Wq2xYJhxk= +github.com/canonical/pebble v1.7.4/go.mod h1:bROzibw902Vastd13S/H48BrVAjEUKnlRXv3ZIoFcPE= github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b h1:Da2fardddn+JDlVEYtrzBLTtyzoyU3nIS0Cf0GvjmwU= github.com/canonical/x-go v0.0.0-20230522092633-7947a7587f5b/go.mod h1:upTK9n6rlqITN9rCN69hdreI37dRDFUk2thlGGD5Cg8= github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c= From 4afda98c4f16bdb0a336cfe7649d0d52851f671a Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Thu, 28 Mar 2024 18:15:37 +1300 Subject: [PATCH 4/7] Add support for Pebble change-update notice This is basically just adding the notice type in the right places, with the effect that we'll now respond to Pebble change-update notices by sending a pebble-change-updated event to the charm. This PR also updates "sidecar" integration tests and the pebble-notices test charm with a change-update notice test. For reference, Pebble Notices support (for the "custom" notice type) was originally introduced in PR #16428. --- testcharms/charms/pebble-notices/src/charm.py | 31 +++++++++ .../pebble-notices/tests/unit/test_charm.py | 68 +++++++++++++++++++ tests/suites/sidecar/sidecar.sh | 21 ++++++ tests/suites/sidecar/task.sh | 1 + worker/uniter/container/workload.go | 9 +++ worker/uniter/container/workload_test.go | 43 ++++++++++++ worker/uniter/hook/hook.go | 2 +- worker/uniter/hook/hook_test.go | 6 ++ worker/uniter/pebblenotices.go | 2 + worker/uniter/pebblenotices_test.go | 19 ++++++ .../uniter/runner/context/contextfactory.go | 2 +- 11 files changed, 202 insertions(+), 2 deletions(-) diff --git a/testcharms/charms/pebble-notices/src/charm.py b/testcharms/charms/pebble-notices/src/charm.py index b2e505be047..901ff94ee0a 100755 --- a/testcharms/charms/pebble-notices/src/charm.py +++ b/testcharms/charms/pebble-notices/src/charm.py @@ -16,6 +16,24 @@ def __init__(self, *args): self.framework.observe(self.on["redis"].pebble_ready, self._on_pebble_ready) self.framework.observe(self.on["redis"].pebble_custom_notice, self._on_custom_notice) + # TODO(benhoyt): update to use pebble_change_updated once ops supports that: + # https://github.com/canonical/operator/pull/1170 + import os + import pathlib + + dispatch_path = pathlib.Path(os.environ.get("JUJU_DISPATCH_PATH", "")) + event_name = dispatch_path.name.replace("-", "_") + logger.info(f"__init__: path={dispatch_path} event={event_name}") + if event_name == "redis_pebble_change_updated": + event = ops.PebbleNoticeEvent( + None, + self.unit.get_container(os.environ["JUJU_WORKLOAD_NAME"]), + os.environ["JUJU_NOTICE_ID"], + os.environ["JUJU_NOTICE_TYPE"], + os.environ["JUJU_NOTICE_KEY"], + ) + self._on_change_updated(event) + def _on_pebble_ready(self, event): self.unit.status = ops.ActiveStatus() @@ -28,6 +46,19 @@ def _on_custom_notice(self, event): # Don't include the (arbitrary) ID in the status message self.unit.status = ops.MaintenanceStatus(f"notice type={notice_type} key={notice_key}") + def _on_change_updated(self, event): + notice_id = event.notice.id + notice_type = ( + event.notice.type if isinstance(event.notice.type, str) else event.notice.type.value + ) + notice_key = event.notice.key + logger.info(f"_on_change_updated: id={notice_id} type={notice_type} key={notice_key}") + + change = event.workload.pebble.get_change(notice_key) + self.unit.status = ops.MaintenanceStatus( + f"notice type={notice_type} kind={change.kind} status={change.status}" + ) + if __name__ == "__main__": ops.main(PebbleNoticesCharm) diff --git a/testcharms/charms/pebble-notices/tests/unit/test_charm.py b/testcharms/charms/pebble-notices/tests/unit/test_charm.py index b7bbc39bfdc..9904dc56c22 100644 --- a/testcharms/charms/pebble-notices/tests/unit/test_charm.py +++ b/testcharms/charms/pebble-notices/tests/unit/test_charm.py @@ -1,8 +1,10 @@ import unittest +import unittest.mock import ops import ops.testing from charm import PebbleNoticesCharm +from ops import pebble class TestCharm(unittest.TestCase): @@ -10,6 +12,7 @@ def setUp(self): self.harness = ops.testing.Harness(PebbleNoticesCharm) self.addCleanup(self.harness.cleanup) self.harness.begin() + self._next_notice_id = 1 def test_pebble_ready(self): self.harness.container_pebble_ready("redis") @@ -27,3 +30,68 @@ def test_custom_notice(self): self.harness.model.unit.status, ops.MaintenanceStatus("notice type=custom key=ubuntu.com/bar/buzz"), ) + + @unittest.mock.patch("ops.testing._TestingPebbleClient.get_change") + def test_change_updated(self, mock_get_change): + # TODO(benhoyt): update to use pebble_change_updated once ops supports that: + # https://github.com/canonical/operator/pull/1170 + + import os + + os.environ["JUJU_DISPATCH_PATH"] = "hooks/redis-pebble-change-updated" + self.addCleanup(os.environ.__delitem__, "JUJU_DISPATCH_PATH") + self.addCleanup(os.environ.__delitem__, "JUJU_NOTICE_ID") + self.addCleanup(os.environ.__delitem__, "JUJU_NOTICE_TYPE") + self.addCleanup(os.environ.__delitem__, "JUJU_NOTICE_KEY") + + mock_get_change.return_value = pebble.Change.from_dict( + { + "id": "1", + "kind": "exec", + "summary": "", + "status": "Doing", + "ready": False, + "spawn-time": "2021-01-28T14:37:02.247202105+13:00", + } + ) + self._pebble_notify_change_updated("redis", "123") + self.assertEqual( + self.harness.model.unit.status, + ops.MaintenanceStatus("notice type=change-update kind=exec status=Doing"), + ) + mock_get_change.assert_called_once_with("123") + + mock_get_change.reset_mock() + mock_get_change.return_value = pebble.Change.from_dict( + { + "id": "2", + "kind": "changeroo", + "summary": "", + "status": "Done", + "ready": True, + "spawn-time": "2024-01-28T14:37:02.247202105+13:00", + "ready-time": "2024-01-28T14:37:04.291517768+13:00", + } + ) + self._pebble_notify_change_updated("redis", "42") + self.assertEqual( + self.harness.model.unit.status, + ops.MaintenanceStatus("notice type=change-update kind=changeroo status=Done"), + ) + mock_get_change.assert_called_once_with("42") + + def _pebble_notify_change_updated(self, container_name, notice_key): + import os + + os.environ["JUJU_NOTICE_ID"] = notice_id = str(self._next_notice_id) + self._next_notice_id += 1 + os.environ["JUJU_NOTICE_TYPE"] = notice_type = "change-update" + os.environ["JUJU_NOTICE_KEY"] = notice_key + event = ops.PebbleNoticeEvent( + None, + self.harness.model.unit.get_container(container_name), + notice_id, + notice_type, + notice_key, + ) + self.harness.charm._on_change_updated(event) diff --git a/tests/suites/sidecar/sidecar.sh b/tests/suites/sidecar/sidecar.sh index 65851b4ca5a..26db62d256f 100644 --- a/tests/suites/sidecar/sidecar.sh +++ b/tests/suites/sidecar/sidecar.sh @@ -89,3 +89,24 @@ test_pebble_notices() { # Clean up model destroy_model "${model_name}" } + +test_pebble_change_updated() { + echo + + # Ensure that a valid Juju controller exists + model_name="controller-model-sidecar" + file="${TEST_DIR}/test-${model_name}.log" + ensure "${model_name}" "${file}" + + # Deploy Pebble Notices test application + juju deploy juju-qa-pebble-notices + wait_for "active" '.applications["juju-qa-pebble-notices"].units["juju-qa-pebble-notices/0"]["workload-status"].current' + + # Check that charm is responding correctly to a change-update notice + juju ssh --container redis juju-qa-pebble-notices/0 /charm/bin/pebble exec -- echo foo + wait_for "maintenance" '.applications["juju-qa-pebble-notices"].units["juju-qa-pebble-notices/0"]["workload-status"].current' + wait_for "notice type=change-update kind=exec status=Done" '.applications["juju-qa-pebble-notices"].units["juju-qa-pebble-notices/0"]["workload-status"].message' + + # Clean up model + destroy_model "${model_name}" +} diff --git a/tests/suites/sidecar/task.sh b/tests/suites/sidecar/task.sh index 581ec57ba37..4812036a953 100644 --- a/tests/suites/sidecar/task.sh +++ b/tests/suites/sidecar/task.sh @@ -11,6 +11,7 @@ test_sidecar() { test_deploy_and_remove_application test_deploy_and_force_remove_application test_pebble_notices + test_pebble_change_updated ;; *) echo "==> TEST SKIPPED: sidecar charm tests, not a k8s provider" diff --git a/worker/uniter/container/workload.go b/worker/uniter/container/workload.go index e8318d69840..b77f33d46ae 100644 --- a/worker/uniter/container/workload.go +++ b/worker/uniter/container/workload.go @@ -32,6 +32,7 @@ const ( // ReadyEvent is triggered when the container/pebble starts up. ReadyEvent WorkloadEventType = iota CustomNoticeEvent + ChangeUpdatedEvent ) // WorkloadEvent contains information about the event type and data associated with @@ -197,6 +198,14 @@ func (r *workloadHookResolver) NextOp( NoticeType: evt.NoticeType, NoticeKey: evt.NoticeKey, }) + case ChangeUpdatedEvent: + op, err = opFactory.NewRunHook(hook.Info{ + Kind: hooks.PebbleChangeUpdated, + WorkloadName: evt.WorkloadName, + NoticeID: evt.NoticeID, + NoticeType: evt.NoticeType, + NoticeKey: evt.NoticeKey, + }) case ReadyEvent: op, err = opFactory.NewRunHook(hook.Info{ Kind: hooks.PebbleReady, diff --git a/worker/uniter/container/workload_test.go b/worker/uniter/container/workload_test.go index 58281b47ea3..d01eb9d79f2 100644 --- a/worker/uniter/container/workload_test.go +++ b/worker/uniter/container/workload_test.go @@ -131,3 +131,46 @@ func (s *workloadSuite) TestWorkloadCustomNoticeHook(c *gc.C) { NoticeKey: "example.com/foo", }) } + +func (s *workloadSuite) TestWorkloadChangeUpdatedHook(c *gc.C) { + events := container.NewWorkloadEvents() + expectedErr := errors.Errorf("expected error") + handler := func(err error) { + c.Assert(err, gc.Equals, expectedErr) + } + containerResolver := container.NewWorkloadHookResolver( + loggo.GetLogger("test"), + events, + events.RemoveWorkloadEvent) + localState := resolver.LocalState{ + State: operation.State{ + Kind: operation.Continue, + Step: operation.Pending, + }, + } + remoteState := remotestate.Snapshot{ + WorkloadEvents: []string{ + events.AddWorkloadEvent(container.WorkloadEvent{ + Type: container.ChangeUpdatedEvent, + WorkloadName: "test", + NoticeID: "123", + NoticeType: "change-update", + NoticeKey: "42", + }, handler), + }, + } + opFactory := &mockOperations{} + op, err := containerResolver.NextOp(localState, remoteState, opFactory) + c.Assert(err, jc.ErrorIsNil) + c.Assert(op, gc.NotNil) + op = operation.Unwrap(op) + hookOp, ok := op.(*mockRunHookOp) + c.Assert(ok, jc.IsTrue) + c.Assert(hookOp.hookInfo, gc.DeepEquals, hook.Info{ + Kind: "pebble-change-updated", + WorkloadName: "test", + NoticeID: "123", + NoticeType: "change-update", + NoticeKey: "42", + }) +} diff --git a/worker/uniter/hook/hook.go b/worker/uniter/hook/hook.go index 4179b836234..9d2c4831862 100644 --- a/worker/uniter/hook/hook.go +++ b/worker/uniter/hook/hook.go @@ -92,7 +92,7 @@ func (hi Info) Validate() error { return errors.Errorf("%q hook has a remote unit but no application", hi.Kind) } return nil - case hooks.PebbleCustomNotice: + case hooks.PebbleCustomNotice, hooks.PebbleChangeUpdated: if hi.WorkloadName == "" { return errors.Errorf("%q hook requires a workload name", hi.Kind) } diff --git a/worker/uniter/hook/hook_test.go b/worker/uniter/hook/hook_test.go index 1c5843763aa..30a7bbc63fc 100644 --- a/worker/uniter/hook/hook_test.go +++ b/worker/uniter/hook/hook_test.go @@ -52,6 +52,12 @@ var validateTests = []struct { }, { hook.Info{Kind: hooks.PebbleCustomNotice, WorkloadName: "test"}, `"pebble-custom-notice" hook requires a notice ID, type, and key`, + }, { + hook.Info{Kind: hooks.PebbleChangeUpdated}, + `"pebble-change-updated" hook requires a workload name`, + }, { + hook.Info{Kind: hooks.PebbleChangeUpdated, WorkloadName: "test"}, + `"pebble-change-updated" hook requires a notice ID, type, and key`, }, { hook.Info{Kind: hooks.PreSeriesUpgrade}, `"pre-series-upgrade" hook requires a target base`, diff --git a/worker/uniter/pebblenotices.go b/worker/uniter/pebblenotices.go index f59e5d400fe..99e5d2c9897 100644 --- a/worker/uniter/pebblenotices.go +++ b/worker/uniter/pebblenotices.go @@ -136,6 +136,8 @@ func (n *pebbleNoticer) processNotice(containerName string, notice *client.Notic switch notice.Type { case client.CustomNotice: eventType = container.CustomNoticeEvent + case client.ChangeUpdateNotice: + eventType = container.ChangeUpdatedEvent default: n.logger.Debugf("container %q: ignoring %s notice", containerName, notice.Type) return nil diff --git a/worker/uniter/pebblenotices_test.go b/worker/uniter/pebblenotices_test.go index 76fd7e4ac6a..3dfbe32e746 100644 --- a/worker/uniter/pebblenotices_test.go +++ b/worker/uniter/pebblenotices_test.go @@ -113,6 +113,25 @@ func (s *pebbleNoticerSuite) TestWaitNotices(c *gc.C) { }) } +func (s *pebbleNoticerSuite) TestChangeUpdate(c *gc.C) { + s.setUpWorker(c, []string{"c1"}) + defer workertest.CleanKill(c, s.worker) + + s.clients["c1"].AddNotice(c, &client.Notice{ + ID: "1", + Type: "change-update", + Key: "42", + LastRepeated: time.Now(), + }) + s.waitWorkloadEvent(c, container.WorkloadEvent{ + Type: container.ChangeUpdatedEvent, + WorkloadName: "c1", + NoticeID: "1", + NoticeType: "change-update", + NoticeKey: "42", + }) +} + func (s *pebbleNoticerSuite) TestWaitNoticesError(c *gc.C) { s.setUpWorker(c, []string{"c1"}) defer workertest.CleanKill(c, s.worker) diff --git a/worker/uniter/runner/context/contextfactory.go b/worker/uniter/runner/context/contextfactory.go index 75a87ebd0a2..7ce3c7aa894 100644 --- a/worker/uniter/runner/context/contextfactory.go +++ b/worker/uniter/runner/context/contextfactory.go @@ -288,7 +288,7 @@ func (f *contextFactory) HookContext(hookInfo hook.Info) (*HookContext, error) { ctx.workloadName = hookInfo.WorkloadName hookName = fmt.Sprintf("%s-%s", hookInfo.WorkloadName, hookName) switch hookInfo.Kind { - case hooks.PebbleCustomNotice: + case hooks.PebbleCustomNotice, hooks.PebbleChangeUpdated: ctx.noticeID = hookInfo.NoticeID ctx.noticeType = hookInfo.NoticeType ctx.noticeKey = hookInfo.NoticeKey From 1ca477fc2989b5db201886025352a0988141d48a Mon Sep 17 00:00:00 2001 From: Harry Pidcock Date: Fri, 5 Apr 2024 12:57:17 +1000 Subject: [PATCH 5/7] Move from https://dev.midipix.org/compat/musl-compat to https://github.com/juju/musl-compat --- scripts/dqlite/scripts/dqlite/dqlite-build.sh | 2 +- snap/snapcraft.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dqlite/scripts/dqlite/dqlite-build.sh b/scripts/dqlite/scripts/dqlite/dqlite-build.sh index f395a2cf244..a55c449ba65 100755 --- a/scripts/dqlite/scripts/dqlite/dqlite-build.sh +++ b/scripts/dqlite/scripts/dqlite/dqlite-build.sh @@ -50,7 +50,7 @@ build() { sudo ln -s /usr/include/linux /usr/local/musl/include/linux || true # Grab the queue.h file that does not ship with musl - sudo wget https://dev.midipix.org/compat/musl-compat/raw/main/f/include/sys/queue.h -O /usr/local/musl/include/sys/queue.h + sudo wget https://raw.githubusercontent.com/juju/musl-compat/main/include/sys/queue.h -O /usr/local/musl/include/sys/queue.h # Install compile dependencies for statically linking everything: # -------------------------------------------------------------- diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index dc80462204d..80f8748f66d 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -96,7 +96,7 @@ parts: ln -s /usr/include/linux /usr/local/musl/include/linux musl-compat: - source: https://dev.midipix.org/compat/musl-compat.git + source: https://github.com/juju/musl-compat.git source-type: git source-depth: 1 plugin: nil From 186d08e1c1d47bcfa6f4a3c5e7d18a75baa323a3 Mon Sep 17 00:00:00 2001 From: jujubot Date: Fri, 5 Apr 2024 16:37:42 +0000 Subject: [PATCH 6/7] Increment juju to 3.4.3 --- scripts/win-installer/setup.iss | 2 +- snap/snapcraft.yaml | 2 +- version/version.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/win-installer/setup.iss b/scripts/win-installer/setup.iss index a566850ec62..e8d5f27b17a 100644 --- a/scripts/win-installer/setup.iss +++ b/scripts/win-installer/setup.iss @@ -4,7 +4,7 @@ #if GetEnv('JUJU_VERSION') != "" #define MyAppVersion=GetEnv('JUJU_VERSION') #else -#define MyAppVersion="3.4.2" +#define MyAppVersion="3.4.3" #endif #define MyAppName "Juju" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 80f8748f66d..d5db1762df8 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: juju -version: 3.4.2 +version: 3.4.3 summary: Juju - a model-driven operator lifecycle manager for K8s and machines license: AGPL-3.0 description: | diff --git a/version/version.go b/version/version.go index 3e506bd7d49..9bec65e2db4 100644 --- a/version/version.go +++ b/version/version.go @@ -18,7 +18,7 @@ import ( // The presence and format of this constant is very important. // The debian/rules build recipe uses this value for the version // number of the release package. -const version = "3.4.2" +const version = "3.4.3" // UserAgentVersion defines a user agent version used for communication for // outside resources. From d94f97a6e781663c3364672f1903485699dbbc8e Mon Sep 17 00:00:00 2001 From: Jack Shaw Date: Mon, 8 Apr 2024 19:18:44 +0100 Subject: [PATCH 7/7] Removesuperfluous base->series->base conversions The function imagemetadata.ImageRelease took a series as a param and instantly converts it to a base However, most callers converted a base to a series to call this function Remove this pointless conversion. This is part of the work to remove series from Juju --- environs/imagemetadata/simplestreams.go | 8 ++------ juju/testing/instance.go | 7 +------ provider/ec2/environ.go | 8 +------- provider/openstack/provider.go | 8 +------- provider/vsphere/image_metadata.go | 5 +++-- provider/vsphere/vm_template.go | 7 ++++++- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/environs/imagemetadata/simplestreams.go b/environs/imagemetadata/simplestreams.go index 6a9d848fed9..bd1d878bd28 100644 --- a/environs/imagemetadata/simplestreams.go +++ b/environs/imagemetadata/simplestreams.go @@ -156,12 +156,8 @@ const ( ReleasedStream = "released" ) -// ImageRelease maps a legacy series to an image version. -func ImageRelease(imSeries string) (string, error) { - base, err := corebase.GetBaseFromSeries(imSeries) - if err != nil { - return "", errors.Trace(err) - } +// ImageRelease maps a base to an image version. +func ImageRelease(base corebase.Base) (string, error) { if base.OS != "centos" { return base.Channel.Track, nil } diff --git a/juju/testing/instance.go b/juju/testing/instance.go index fb60897c404..fa20dccea2a 100644 --- a/juju/testing/instance.go +++ b/juju/testing/instance.go @@ -12,7 +12,6 @@ import ( "github.com/juju/juju/api" "github.com/juju/juju/cloudconfig/instancecfg" "github.com/juju/juju/core/arch" - corebase "github.com/juju/juju/core/base" "github.com/juju/juju/core/constraints" "github.com/juju/juju/core/instance" "github.com/juju/juju/core/model" @@ -185,11 +184,7 @@ func FillInStartInstanceParams(env environs.Environ, machineId string, isControl preferredBase := config.PreferredBase(env.Config()) if params.ImageMetadata == nil { - preferredSeries, err := corebase.GetSeriesFromBase(preferredBase) - if err != nil { - return errors.Trace(err) - } - vers, err := imagemetadata.ImageRelease(preferredSeries) + vers, err := imagemetadata.ImageRelease(preferredBase) if err != nil { return errors.Trace(err) } diff --git a/provider/ec2/environ.go b/provider/ec2/environ.go index ee9660d4a98..08ed6f12b99 100644 --- a/provider/ec2/environ.go +++ b/provider/ec2/environ.go @@ -33,7 +33,6 @@ import ( "github.com/juju/juju/cloudconfig/providerinit" "github.com/juju/juju/controller" "github.com/juju/juju/core/arch" - corebase "github.com/juju/juju/core/base" "github.com/juju/juju/core/constraints" corecontext "github.com/juju/juju/core/context" "github.com/juju/juju/core/instance" @@ -491,12 +490,7 @@ func (e *environ) AgentMetadataLookupParams(region string) (*simplestreams.Metad // ImageMetadataLookupParams returns parameters which are used to query image simple-streams metadata. func (e *environ) ImageMetadataLookupParams(region string) (*simplestreams.MetadataLookupParams, error) { base := config.PreferredBase(e.ecfg()) - baseSeries, err := corebase.GetSeriesFromBase(base) - if err != nil { - return nil, errors.Trace(err) - } - - release, err := imagemetadata.ImageRelease(baseSeries) + release, err := imagemetadata.ImageRelease(base) if err != nil { return nil, errors.Trace(err) } diff --git a/provider/openstack/provider.go b/provider/openstack/provider.go index 075808b9fd9..169a2005e9b 100644 --- a/provider/openstack/provider.go +++ b/provider/openstack/provider.go @@ -42,7 +42,6 @@ import ( "github.com/juju/juju/cloudconfig/instancecfg" "github.com/juju/juju/cloudconfig/providerinit" "github.com/juju/juju/cmd/juju/interact" - corebase "github.com/juju/juju/core/base" "github.com/juju/juju/core/constraints" "github.com/juju/juju/core/instance" "github.com/juju/juju/core/network" @@ -2302,12 +2301,7 @@ func (e *Environ) AgentMetadataLookupParams(region string) (*simplestreams.Metad // ImageMetadataLookupParams returns parameters which are used to query image simple-streams metadata. func (e *Environ) ImageMetadataLookupParams(region string) (*simplestreams.MetadataLookupParams, error) { base := config.PreferredBase(e.ecfg()) - baseSeries, err := corebase.GetSeriesFromBase(base) - if err != nil { - return nil, errors.Trace(err) - } - - release, err := imagemetadata.ImageRelease(baseSeries) + release, err := imagemetadata.ImageRelease(base) if err != nil { return nil, errors.Trace(err) } diff --git a/provider/vsphere/image_metadata.go b/provider/vsphere/image_metadata.go index 13d48c3ebe7..ba81352cff9 100644 --- a/provider/vsphere/image_metadata.go +++ b/provider/vsphere/image_metadata.go @@ -6,6 +6,7 @@ package vsphere import ( "github.com/juju/errors" + "github.com/juju/juju/core/base" "github.com/juju/juju/environs" "github.com/juju/juju/environs/imagemetadata" "github.com/juju/juju/environs/simplestreams" @@ -31,8 +32,8 @@ func init() { simplestreams.RegisterStructTags(OvaFileMetadata{}) } -func findImageMetadata(env environs.Environ, arch string, series string) (*OvaFileMetadata, error) { - vers, err := imagemetadata.ImageRelease(series) +func findImageMetadata(env environs.Environ, arch string, b base.Base) (*OvaFileMetadata, error) { + vers, err := imagemetadata.ImageRelease(b) if err != nil { return nil, errors.Trace(err) } diff --git a/provider/vsphere/vm_template.go b/provider/vsphere/vm_template.go index bac7b9efc0f..2b6a26997fc 100644 --- a/provider/vsphere/vm_template.go +++ b/provider/vsphere/vm_template.go @@ -14,6 +14,7 @@ import ( "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/vim25/types" + "github.com/juju/juju/core/base" "github.com/juju/juju/environs" "github.com/juju/juju/environs/imagemetadata" "github.com/juju/juju/provider/vsphere/internal/vsphereclient" @@ -181,7 +182,11 @@ func (v *vmTemplateManager) downloadAndImportTemplate( if err != nil { return nil, "", errors.Trace(err) } - img, err := findImageMetadata(v.env, arch, series) + b, err := base.GetBaseFromSeries(series) + if err != nil { + return nil, "", environs.ZoneIndependentError(err) + } + img, err := findImageMetadata(v.env, arch, b) if err != nil { return nil, "", environs.ZoneIndependentError(err) }