Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Enable Patching of WorkStatus #28

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/workstatus-creation.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test workstatus creation
name: test workstatus operations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I would change the name of this file too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Did it by #29 .

on:
workflow_call:
Expand All @@ -15,8 +15,8 @@ on:
- 'v*'

jobs:
test-workstatus-creation:
name: Test workstatus creation
test-workstatus-operations:
name: Test workstatus operations
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
Expand All @@ -43,34 +43,34 @@ jobs:
run: |
test/e2e/run.sh

- name: show docker images
- name: Show docker images
if: always()
run: docker images

- name: show kubeconfig contexts
- name: Show kubeconfig contexts
if: always()
run: kubectl config get-contexts

- name: show clustermanagementaddons
- name: Show clustermanagementaddons
if: always()
run: kubectl --context kind-hub get clustermanagementaddons

- name: show managedclusteraddons
- name: Show managedclusteraddons
if: always()
run: kubectl --context kind-hub get managedclusteraddons -A

- name: show manifestworks in hub
- name: Show manifestworks in hub
if: always()
run: kubectl --context kind-hub get manifestwork -oyaml -A

- name: show workloads in cluster1
- name: Show workloads in cluster1
if: always()
run: kubectl --context kind-cluster1 get all -A

- name: show logs of the agent in cluster1
- name: Show logs of the agent in cluster1
if: always()
run: kubectl --context kind-cluster1 -n open-cluster-management-agent-addon logs deployment.apps/status-agent

- name: show workstatus objects in hub
- name: Show workstatus objects in hub
if: always()
run: kubectl --context kind-hub get workstatus -oyaml -A
1 change: 0 additions & 1 deletion api/v1alpha1/workstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type WorkStatusList struct {

// Manifest represents a resource to be deployed
type RawStatus struct {
// +kubebuilder:validation:EmbeddedResource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an inferior choice for how to solve the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be happy to learn about a better solution.

// +kubebuilder:pruning:PreserveUnknownFields
runtime.RawExtension `json:",inline"`
}
Expand Down
1 change: 0 additions & 1 deletion config/crd/bases/control.kubestellar.io_workstatuses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ spec:
status:
description: Manifest represents a resource to be deployed
type: object
x-kubernetes-embedded-resource: true
x-kubernetes-preserve-unknown-fields: true
type: object
served: true
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The only exceptions are
- `clusteradm` is needed to run the test;
- `helm` is *not* needed to run the test.

## Use the test
## Use the tests

In the root directory of this git repo:
```
Expand Down
1 change: 1 addition & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ ${SRC_DIR}/cleanup.sh
source "${SRC_DIR}/setup-shell.sh"
${SRC_DIR}/setup-ocm.sh
${SRC_DIR}/workstatus-creation.sh
${SRC_DIR}/workstatus-patching.sh
5 changes: 4 additions & 1 deletion test/e2e/workstatus-creation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ EOF
:
wait-for-cmd '[ "$(kubectl --context kind-hub -n cluster1 get workstatus appsv1-deployment-nginx-nginx -o jsonpath="{.status.availableReplicas}" 2>/dev/null)" == 1 ]'

: SUCCESS: Test passed
:
: -------------------------------------------------------------------------
: SUCCESS: Workstatus creation test passed
:
70 changes: 70 additions & 0 deletions test/e2e/workstatus-patching.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
# Copyright 2024 The KubeStellar Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -x # echo so that users can understand what is happening
set -e # exit on error

:
: -------------------------------------------------------------------------
: Create a WorkStatus object in hub
:
kubectl --context kind-hub apply -f - <<EOF
apiVersion: control.kubestellar.io/v1alpha1
kind: WorkStatus
metadata:
labels:
managed-by.kubestellar.io/singletonstatus: "true"
managed-by.kubestellar.io/wds1.nginx-singleton-bindingpolicy: "true"
name: test
namespace: default
spec:
sourceRef:
group: apps
kind: Deployment
name: nginx-deployment
namespace: nginx
resource: deployments
version: v1
EOF

:
: -------------------------------------------------------------------------
: Patch when there is no status set
:
kubectl --context kind-hub patch workstatus test --type=merge \
--patch '{"metadata":{"annotations":{"version": "v2"}}}'
wait-for-cmd '[ $(kubectl --context kind-hub get workstatus test -o=jsonpath='{.metadata.annotations.version}') = "v2" ]'

:
: -------------------------------------------------------------------------
: Fill in then show the status
:
kubectl --context kind-hub patch workstatus test --type=merge \
--patch='{"status":{"conditions":[{"type":"Available","status":"True","reason":"DeploymentAvailable","message":"Deployment has minimum availability."}]}}' \
--subresource=status
kubectl --context kind-hub get workstatus test -o=jsonpath='{.status}'

:
: -------------------------------------------------------------------------
: Patch when there is some status set
:
kubectl --context kind-hub patch workstatus test --type=merge \
--patch '{"metadata":{"annotations":{"version": "v3"}}}'
wait-for-cmd '[ $(kubectl --context kind-hub get workstatus test -o=jsonpath='{.metadata.annotations.version}') = "v3" ]'

:
: -------------------------------------------------------------------------
: SUCCESS: Workstatus patching test passed
:
Loading