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

support multiple resources in the editor (#549) #551

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

adietish
Copy link
Collaborator

@adietish adietish commented Jan 6, 2023

fixes #549

@adietish adietish self-assigned this Jan 6, 2023
@adietish adietish force-pushed the issue-549 branch 17 times, most recently from 489ec3b to 3101398 Compare January 12, 2023 21:37
@adietish adietish force-pushed the issue-549 branch 11 times, most recently from ad22275 to 9a815e7 Compare January 18, 2023 12:14
@adietish adietish force-pushed the issue-549 branch 13 times, most recently from 1b626ec to 395ed53 Compare February 10, 2023 15:09
Signed-off-by: Andre Dietisheim <adietish@redhat.com>
@sonarcloud
Copy link

sonarcloud bot commented Feb 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@adietish
Copy link
Collaborator Author

adietish commented Feb 10, 2023

@sbouchet, @robstryker. @jeffmaury: Please test this PR. Thanks!

I wrote down 3 scenarios.
Feel free to whatever you want and try to trash the editor :)
Further down there's a yaml document with 5 resources: 2 pods, 2 services, 1 ingress. You can edit this document in the editor and push it to the cluster. It should create the resources.
Pull notifications are not supported in multi-resource mode. You should only get notified if you can push something (in case you modified the document or the resource was deleted on the cluster).

Scenarios

Create resources

  1. EXEC: open new editor via File > New > YML file
  2. EXEC: paste one of the documents that you find below
  3. ASSERT: Push notification appears
  4. EXEC: hit Push

Expected Result:

  1. ASSERT: in tree: new pods "banana-app", "apple-app" appear in [context] > Workloads > Pods
  2. ASSERT: in the tree: new services "banana-service", "apple-service" appear in [context] > Nework > Services
  3. ASSERT: in the tree: new Ingress "example-ingress" appear in [context] > Nework > Ingress

Update resources

  1. ASSERT: Have resources created as in test before
  2. EXEC: in the editor go to apple-service, metadata. Add a label:
metadata:
  name: apple-service
  labels:
    smurf: grumpy
  1. ASSERT: Push notification appears "update 'apple-service'"
  2. EXEC: hit "Push" in notification

Expected Result:
Updated notification is displayed "updated 'apple-service' appears"

Delete and Recreate

  1. ASSERT: Have resources created as in test before
  2. EXEC: in tree: go Workloads > Services > apple-service & delete it
  3. ASSERT: editor shows "Push" notification "create apple-service"
  4. EXEC: hit "Push"

Expected Result:
in tree: Workloads > Services > apple-service appears

Multi-resource document (2 pods, 2 service, 1 ingress)

kind: Pod
apiVersion: v1
metadata:
  name: apple-app
  labels:
    app: apple
spec:
  containers:
    - name: apple-app
      image: hashicorp/http-echo
      args:
        - "-text=apple"
---
kind: Service
apiVersion: v1
metadata:
  name: apple-service
spec:
  selector:
    app: apple 
  ports:
    - port: 5678 # Default port for image
---
kind: Pod
apiVersion: v1
metadata:
  name: banana-app
  labels:
    app: banana
spec:
  containers:
    - name: banana-app
      image: hashicorp/http-echo
      args:
        - "-text=banana"
---
kind: Service
apiVersion: v1
metadata:
  name: banana-service
spec:
  selector:
    app: banana
  ports:
    - port: 5678 # Default port for image
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - http:
        paths:
          - pathType: Exact
            path: /apple
            backend:
              service:
                name: apple-service
                port:
                  number: 5678
          - pathType: Exact
            path: /banana
            backend:
              service:
                name: banana-service
                port:
                  number: 5678

@jeffmaury
Copy link
Member

Tried but once all resources have been created, I modified one and was asked for Push and got an error as a result.

kube

@adietish
Copy link
Collaborator Author

adietish commented Feb 13, 2023

@jeffmaury

I modified one and was asked for Push and got an error as a result.

Thanks for spotting this, I could replicate it. It is not related to the support for multiple resources in an editor, it also happens when you edit a pod in his very own editor. This does not happen for me when I add a label to one of the services.
I'll thus takle this in a separate issue: #561

This error seems related to the spec object in the pod. The error complains about prohibited changes in spec. Adding a label in one of the Services (which do not have a spec) works fine.
Interestingly kubectl apply works here. Digging into this I found longs threads in the kubernetes-client where differences in their #createOrReplace method and kubectls apply were discussed.

Copy link
Member

@jeffmaury jeffmaury left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@sbouchet sbouchet left a comment

Choose a reason for hiding this comment

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

Played around to create/modify/delete resources on minikube. LGTM

@adietish adietish merged commit 661eb95 into redhat-developer:main Feb 14, 2023
@adietish adietish deleted the issue-549 branch February 14, 2023 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Support Multi Resource Files
4 participants