Skip to content

Commit

Permalink
Merge pull request juju#17171 from wallyworld/k8s-pool-notfound
Browse files Browse the repository at this point in the history
juju#17171

We've started using bespoke, domain specific not found errors. There was a place in the k8s storage provisioning code where the older generic not found error was still being checked. This fixes that.

## QA steps

bootstrap k8s
deploy postgresql-k8s

check storage
```
Storage Unit Storage ID Type Pool Mountpoint Size Status Message
postgresql-k8s/0 pgdata/0 filesystem kubernetes /var/lib/postgresql/data 1.0 GiB attached Successfully provisioned volume pvc-43da2f5a-7e38-424a-9691-2fb15cb7090d
```

## Links

**Jira card:** JUJU-5848
  • Loading branch information
jujubot authored Apr 9, 2024
2 parents 92e7069 + 430b477 commit b37ca55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/juju/juju/core/objectstore"
"github.com/juju/juju/core/resources"
"github.com/juju/juju/core/status"
storageerrors "github.com/juju/juju/domain/storage/errors"
"github.com/juju/juju/environs/config"
"github.com/juju/juju/internal/docker"
"github.com/juju/juju/internal/storage"
Expand Down Expand Up @@ -161,6 +162,9 @@ func (m *mockStoragePoolGetter) GetStoragePoolByName(_ context.Context, name str
if err := m.NextErr(); err != nil {
return nil, err
}
if name == "notpool" {
return nil, storageerrors.PoolNotFoundError
}
return storage.NewConfig(name, k8sconstants.StorageProviderType, map[string]interface{}{"foo": "bar"})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func CharmStorageParams(
}

providerType, attrs, err := poolStorageProvider(ctx, storagePoolGetter, registry, maybePoolName)
if err != nil && (!errors.Is(err, errors.NotFound) || poolName != "") {
if err != nil && (!errors.Is(err, storageerrors.PoolNotFoundError) || poolName != "") {
return nil, errors.Trace(err)
}
if err == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
jujuresource "github.com/juju/juju/core/resources"
"github.com/juju/juju/core/status"
"github.com/juju/juju/core/watcher/eventsource"
envconfig "github.com/juju/juju/environs/config"
"github.com/juju/juju/internal/docker"
"github.com/juju/juju/rpc/params"
"github.com/juju/juju/state"
Expand Down Expand Up @@ -680,3 +681,20 @@ func (s *CAASApplicationProvisionerSuite) TestProvisionerConfig(c *gc.C) {
c.Assert(result.ProvisionerConfig, gc.NotNil)
c.Assert(result.ProvisionerConfig.UnmanagedApplications.Entities, gc.DeepEquals, []params.Entity{{Tag: "application-controller"}})
}

func (s *CAASApplicationProvisionerSuite) TestCharmStorageParamsPoolNotFound(c *gc.C) {
cfg, err := envconfig.New(envconfig.NoDefaults, coretesting.FakeConfig())
c.Assert(err, jc.ErrorIsNil)
p, err := caasapplicationprovisioner.CharmStorageParams(
context.Background(), coretesting.ControllerTag.Id(),
"notpool", cfg, "", s.storagePoolGetter, s.registry,
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(p, jc.DeepEquals, &params.KubernetesFilesystemParams{
StorageName: "charm",
Size: 1024,
Provider: "kubernetes",
Attributes: map[string]any{"storage-class": "notpool"},
Tags: map[string]string{"juju-controller-uuid": coretesting.ControllerTag.Id(), "juju-model-uuid": coretesting.ModelTag.Id()},
})
}

0 comments on commit b37ca55

Please sign in to comment.