Skip to content

Commit

Permalink
Merge pull request juju#16312 from barrettj12/merge-3.2-3.3-20230922
Browse files Browse the repository at this point in the history
juju#16312

Merges the following patches:
- juju#16311
- juju#16310
- juju#16308
- juju#16306
- juju#16266
- juju#16292
- juju#16291
- juju#16286
- juju#16242
- juju#16284
- juju#16281
- juju#16273
- juju#16249

### Conflicts
- .github/workflows/microk8s-tests.yml
- .github/workflows/smoke.yml
- .github/workflows/upgrade.yml
  • Loading branch information
jujubot authored Sep 22, 2023
2 parents 2678b4b + c461d92 commit 3e561ad
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ updates:
schedule:
# Check for updates to GitHub Actions every weekday
interval: "daily"

target-branch: 2.9
2 changes: 1 addition & 1 deletion .github/workflows/microk8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
sudo systemctl restart docker
docker system info
- uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
- uses: balchua/microk8s-actions@e99a1ffcd3bb2682d941104cf6c1a215c657903f
with:
channel: '${{ matrix.microk8s }}'
# enable now to give microk8s more time to settle down.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Setup MicroK8s
if: matrix.cloud == 'microk8s'
uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
uses: balchua/microk8s-actions@e99a1ffcd3bb2682d941104cf6c1a215c657903f
with:
channel: "1.28-strict/stable"
addons: '["dns", "hostpath-storage", "rbac"]'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
- name: Setup k8s
if: env.RUN_TEST == 'RUN' && matrix.model_type == 'microk8s'
uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
uses: balchua/microk8s-actions@e99a1ffcd3bb2682d941104cf6c1a215c657903f
with:
channel: "1.28-strict/stable"
addons: '["dns", "hostpath-storage"]'
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,11 @@ microk8s-operator-update: host-install operator-image
## microk8s-operator-update: Push up the newly built operator image for use with microk8s
@${UPDATE_MICROK8S_OPERATOR}

.PHONY: k3s-operator-update
k3s-operator-update: host-install operator-image
## k3s-operator-update: Push up the newly built operator image for use with k3s
docker save "$(shell ${OPERATOR_IMAGE_PATH})" | k3s ctr images import -

.PHONY: check-k8s-model
check-k8s-model:
## check-k8s-model: Check if k8s model is present in show-model
Expand Down
2 changes: 1 addition & 1 deletion apiserver/authentication/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (p *PermissionDelegator) SubjectPermissions(
// We need to make very sure that the entity the request pertains to
// is the same entity this function was seeded with.
if tokenEntity.Tag().String() != e.Tag().String() {
return permission.NoAccess, fmt.Errorf("%w to use token permissions for one entity on another", errors.NotValid)
return permission.NoAccess, fmt.Errorf("%w to use token permissions for one entity on another", apiservererrors.ErrPerm)
}
return PermissionFromToken(p.Token, subject)
}
Expand Down
3 changes: 2 additions & 1 deletion apiserver/authentication/jwt/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/juju/juju/apiserver/authentication"
"github.com/juju/juju/apiserver/authentication/jwt"
"github.com/juju/juju/apiserver/common"
apiservererrors "github.com/juju/juju/apiserver/errors"
apitesting "github.com/juju/juju/apiserver/testing"
"github.com/juju/juju/core/permission"
"github.com/juju/juju/testing"
Expand Down Expand Up @@ -141,7 +142,7 @@ func (s *loginTokenSuite) TestPermissionsForDifferentEntity(c *gc.C) {
User: names.NewUserTag("wallyworld"),
}
perm, err := authInfo.Delegator.SubjectPermissions(badUser, modelTag)
c.Assert(errors.Is(err, errors.NotValid), jc.IsTrue)
c.Assert(errors.Is(err, apiservererrors.ErrPerm), jc.IsTrue)
c.Assert(perm, gc.Equals, permission.NoAccess)

badUser = jwt.TokenEntity{
Expand Down
7 changes: 4 additions & 3 deletions cmd/juju/application/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ func (s *BaseRefreshSuite) setup(c *gc.C, currentCharmURL, latestCharmURL *charm
cookieFile := filepath.Join(c.MkDir(), "cookies")
s.PatchEnvironment("JUJU_COOKIEFILE", cookieFile)

s.testPlatform = corecharm.MustParsePlatform("amd64/ubuntu/22.04")
s.testBase = corebase.MakeDefaultBase("ubuntu", "22.04")
var err error
s.testBase, err = corebase.GetBaseFromSeries(currentCharmURL.Series)
c.Assert(err, jc.ErrorIsNil)
s.testPlatform = corecharm.MustParsePlatform(fmt.Sprintf("%s/%s/%s", arch.DefaultArchitecture, s.testBase.OS, s.testBase.Channel))

s.deployResources = func(
applicationID string,
Expand Down Expand Up @@ -845,7 +847,6 @@ func (s *RefreshSuccessStateSuite) TestForcedSeriesUpgrade(c *gc.C) {
`series:`,
` - trusty`,
` - wily`,
` - bionic`,
},
"\n",
)
Expand Down
3 changes: 3 additions & 0 deletions cmd/juju/commands/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (m jujuMain) Run(args []string) int {

if err = juju.InitJujuXDGDataHome(); err != nil {
cmd.WriteError(ctx.Stderr, err)
if errors.Is(err, errors.NotFound) {
ctx.Warningf("Installing juju from a snap, the .local/share directory should be manually created as it is strictly confined.")
}
return 2
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/juju/featureflag v1.0.0
github.com/juju/gnuflag v1.0.0
github.com/juju/gojsonschema v1.0.0
github.com/juju/gomaasapi/v2 v2.0.2
github.com/juju/gomaasapi/v2 v2.1.0
github.com/juju/http/v2 v2.0.0
github.com/juju/idmclient/v2 v2.0.0
github.com/juju/jsonschema v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -810,8 +810,8 @@ github.com/juju/gojsonreference v0.0.0-20150204194633-f0d24ac5ee33 h1:huRsqE0iXm
github.com/juju/gojsonreference v0.0.0-20150204194633-f0d24ac5ee33/go.mod h1:UxUZdlQkjnbl3YoCZT1y5uxmvG2KMwqgffBFccD7qHI=
github.com/juju/gojsonschema v1.0.0 h1:v0hVxinRWko/SwRYCZ99fBH20Q1JtDqKtplcovXewt0=
github.com/juju/gojsonschema v1.0.0/go.mod h1:w3BDUH3gGgrcrAyvEbBy3lNb1vmdqG31UMn3njL8oGc=
github.com/juju/gomaasapi/v2 v2.0.2 h1:0u3G5iK3+1+cLZjvG90NR6FID4PAMRi/Mk2JrICF3pU=
github.com/juju/gomaasapi/v2 v2.0.2/go.mod h1:ZsohFbU4xShV1aSQYQ21hR1lKj7naNGY0SPuyelcUmk=
github.com/juju/gomaasapi/v2 v2.1.0 h1:K9M4OjDVSS7UWjHGvYvdpXJWQE72uyDo4do1czDjlIA=
github.com/juju/gomaasapi/v2 v2.1.0/go.mod h1:ZsohFbU4xShV1aSQYQ21hR1lKj7naNGY0SPuyelcUmk=
github.com/juju/http/v2 v2.0.0 h1:xexT4KO4jY0UEkhLZPwQGaEGCfgWWjw3jBPrLRumhKI=
github.com/juju/http/v2 v2.0.0/go.mod h1:hqjfdSwUaD23PurU7FZyY/rsqVL90RF3w4Xl0iPILRA=
github.com/juju/httpprof v0.0.0-20141217160036-14bf14c30767/go.mod h1:+MaLYz4PumRkkyHYeXJ2G5g5cIW0sli2bOfpmbaMV/g=
Expand Down
19 changes: 18 additions & 1 deletion juju/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package juju

import (
"os"
"path/filepath"

"github.com/juju/errors"
Expand All @@ -12,6 +13,17 @@ import (
"github.com/juju/juju/juju/osenv"
)

func checkJujuHomeFolderExists() bool {
_, err := os.Stat(osenv.JujuXDGDataHomeDir())
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}

// InitJujuXDGDataHome initializes the charm cache, environs/config and utils/ssh packages
// to use default paths based on the $JUJU_DATA or $HOME environment variables.
// This function should be called before running a Juju CLI command.
Expand All @@ -23,7 +35,12 @@ func InitJujuXDGDataHome() error {

sshDir := osenv.JujuXDGDataHomePath("ssh")
if err := ssh.LoadClientKeys(sshDir); err != nil {
return errors.Annotate(err, "cannot load ssh client keys")
// If the ssh directory doesn't exist, we don't want to check that Juju home directory it exists
if !checkJujuHomeFolderExists() {
return errors.NewNotFound(err, "cannot create juju home directory")
} else {
return errors.Annotate(err, "cannot load ssh client keys")
}
}
ssh.SetGoCryptoKnownHostsFile(filepath.Join(sshDir, "gocrypto_known_hosts"))

Expand Down
2 changes: 1 addition & 1 deletion tests/suites/spaces_ec2/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ assert_net_iface_for_endpoint_matches() {
exp_if_name=${3}

# shellcheck disable=SC2086,SC2016
got_if=$(juju exec -a ${app_name} "network-get ${endpoint_name}" | grep "interfacename: ens" | awk '{print $2}')
got_if=$(juju exec -a ${app_name} "network-get ${endpoint_name}" | grep "interfacename: en" | awk '{print $2}')
if [ "$got_if" != "$exp_if_name" ]; then
# shellcheck disable=SC2086,SC2016,SC2046
echo $(red "Expected network interface for ${app_name}:${endpoint_name} to be ${exp_if_name}; got ${got_if}")
Expand Down

0 comments on commit 3e561ad

Please sign in to comment.