Skip to content

Commit 208a1bd

Browse files
committed
Merge branch 'main' into kubernetes-1.31
2 parents 2d0705f + 874af5e commit 208a1bd

8 files changed

Lines changed: 119 additions & 15 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Build
22

33
on:
4+
push:
5+
branches:
6+
- kubernetes-*
47
pull_request:
58
branches:
69
- main
@@ -14,8 +17,6 @@ on:
1417
- "deploy/**"
1518
- "!tests/**"
1619
workflow_dispatch:
17-
schedule:
18-
- cron: "28 17 * * 0"
1920

2021
permissions:
2122
contents: read

.github/workflows/e2e_test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: e2e_test
22

33
on:
4+
push:
5+
branches:
6+
- kubernetes-*
47
pull_request:
58
branches:
69
- main

cloud-controller-manager/osc/cloud/cloud.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func New(ctx context.Context, clusterID string) (*Cloud, error) {
2727
if err != nil {
2828
return nil, fmt.Errorf("init cloud: %w", err)
2929
}
30+
if err := api.OAPI().CheckCredentials(ctx); err != nil {
31+
return nil, fmt.Errorf("init cloud: %w", err)
32+
}
3033
c := &Cloud{api: api, Metadata: metadata, clusterID: clusterID}
3134

3235
id := c.Metadata.InstanceID

cloud-controller-manager/osc/oapi/interfaces.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727

2828
// OAPI is the interface for OAPI calls.
2929
type OAPI interface {
30+
CheckCredentials(ctx context.Context) error
31+
3032
ReadVms(ctx context.Context, req osc.ReadVmsRequest) ([]osc.Vm, error)
3133

3234
ReadLoadBalancers(ctx context.Context, req osc.ReadLoadBalancersRequest) ([]osc.LoadBalancer, error)

cloud-controller-manager/osc/oapi/mocks/mock_oapi.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud-controller-manager/osc/oapi/oapi.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ package oapi
1818

1919
import (
2020
"context"
21+
"errors"
22+
"fmt"
23+
"net/http"
24+
"slices"
2125

2226
osc "github.com/outscale/osc-sdk-go/v2"
27+
"k8s.io/klog/v2"
2328
)
2429

2530
const (
@@ -30,6 +35,36 @@ func (c *OscClient) APIClient() *osc.APIClient {
3035
return c.api
3136
}
3237

38+
var (
39+
authErrorCodes = []string{"1", "5", "7", "14", "20", "4120"}
40+
ErrInvalidCredentials = errors.New("authentication error (invalid credentials ?)")
41+
)
42+
43+
func (c *OscClient) CheckCredentials(ctx context.Context) error {
44+
logger := klog.FromContext(ctx)
45+
req := osc.ReadVmsRequest{}
46+
logger.V(4).Info("Check credentials", "OAPI", "ReadVms")
47+
_, httpRes, err := c.api.VmApi.ReadVms(c.WithAuth(ctx)).ReadVmsRequest(req).Execute()
48+
switch {
49+
case err == nil || httpRes.StatusCode == http.StatusTooManyRequests:
50+
return nil
51+
case httpRes == nil:
52+
logger.V(3).Error(err, "OAPI error", "OAPI", "ReadVms")
53+
return fmt.Errorf("check credentials: %w", err)
54+
default:
55+
logger.V(3).Info(fmt.Sprintf("OAPI error response: %+v", err), "OAPI", "ReadVms", "http_status", httpRes.Status)
56+
var oapiErr osc.GenericOpenAPIError
57+
if errors.As(err, &oapiErr) {
58+
if errs, ok := oapiErr.Model().(osc.ErrorResponse); ok && len(errs.GetErrors()) > 0 {
59+
if slices.Contains(authErrorCodes, errs.GetErrors()[0].GetCode()) {
60+
err = ErrInvalidCredentials
61+
}
62+
}
63+
}
64+
return fmt.Errorf("check credentials: %w", err)
65+
}
66+
}
67+
3368
func (c *OscClient) ReadVms(ctx context.Context, req osc.ReadVmsRequest) ([]osc.Vm, error) {
3469
resp, httpRes, err := c.api.VmApi.ReadVms(c.WithAuth(ctx)).ReadVmsRequest(req).Execute()
3570
err = logAndExtractError(ctx, "ReadVms", req, httpRes, err)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package oapi_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/outscale/cloud-provider-osc/cloud-controller-manager/osc/oapi"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestCheckCredentials(t *testing.T) {
11+
t.Run("Invalid credentials are rejected with an error", func(t *testing.T) {
12+
t.Setenv("OSC_ACCESS_KEY", "foo")
13+
t.Setenv("OSC_SECRET_KEY", "bar")
14+
api, err := oapi.NewClient("eu-west-2")
15+
require.NoError(t, err)
16+
err = api.OAPI().CheckCredentials(t.Context())
17+
require.ErrorIs(t, err, oapi.ErrInvalidCredentials)
18+
})
19+
}

docs/development.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,47 @@ make build-image image-tag image-push helm_deploy test-e2e
109109

110110
# Release
111111

112-
1. Update [CHANGELOG.md](CHANGELOG.md)
113-
2. Update chart version (if needed) in [Chart.yaml](../deploy/k8s-osc-ccm/Chart.yaml)
114-
3. Update cloud-provider-osc version in [values.yaml](../deploy/k8s-osc-ccm/values.yaml)
115-
4. Update prerequisites section in [deploy/README.md](../deploy/README.md)
116-
5. Generate helm doc `make helm-docs`
117-
6. Update [deploy/osc-ccm-manifest.yml](../deploy/osc-ccm-manifest.yml) `make helm-manifest`
118-
7. Commit version with `git commit -am "cloud-controller-manager vX.Y.Z"`
119-
8. Create PR and merge it to main
120-
9. Tag the release
112+
## Helm release
113+
114+
1. In [CHANGELOG.md](CHANGELOG.md), add a new vX.Y.Z-helm version
115+
2. Update chart version (if needed) in [Chart.yaml](../deploy/k8s-osc-ccm/Chart.yaml)
116+
3. Update cloud-provider-osc version in [values.yaml](../deploy/k8s-osc-ccm/values.yaml) (listing all active container versions)
117+
4. Generate helm doc `make helm-docs`
118+
5. Update manifests `make helm-manifest`
119+
6. Commit version with `git commit -am "cloud-controller-manager vX.Y.Z"`
120+
7. Create PR and merge it to main
121+
8. Tag & push the release
121122
```shell
122-
git tag -a vX.X.X -m "🔖 Release vX.X.X"
123+
export HELM_VERSION=vX.Y.Z-helm
124+
git tag -a $HELM_VERSION -m "🔖 Helm $HELM_VERSION"
125+
git push origin $HELM_VERSION
123126
```
124-
10. Push the tag
127+
11. Publish the release on Github
128+
129+
## Container release
130+
131+
There must be a release for each active Kubernetes release.
132+
Each Kubernetes release has its own release branch (kubernetes-1.31, kubernetes-1.32, kubernetes-1.33, kubernetes-1.34)
133+
134+
Versioning is vX.Y.Z, where X.Y are the major/minor version numbers of each Kubernetes release.
135+
Z is the version of the CCM, is increased at each release, and is the same for every Kubernetes release branch.
136+
137+
1. In [CHANGELOG.md](CHANGELOG.md), add a new version for every release branch
138+
2. In [README.md](README.md), update the recommended version for each Kubernetes release
139+
3. Create PR and merge it to main
140+
4. Merge main into each release branch
125141
```shell
126-
git push origin vX.X.X
142+
git co kubernetes-X.Y
143+
git merge main
144+
git push origin kubernetes-X.Y
127145
```
128-
11. Publish the release on Github
146+
5. Check that CI is OK on every release branch
147+
6. Tag release for each release branch
148+
```shell
149+
git co kubernetes-X.Y
150+
git pull --rebase
151+
export VERSION=vX.Y.Z
152+
git tag -a $VERSION -m "🔖 CCM $VERSION"
153+
git push origin $VERSION
154+
```
155+
7. Publish the releases on Github

0 commit comments

Comments
 (0)