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

PackageVariant debugging from Nephio #4001

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

johnbelamaric
Copy link
Contributor

This commit adds a workaround for an issue with Kptfile rendering that is causing a controller battle between PackageVariant controller and the Nephio controllers.

It also adds some instrumentation to help debug some issues with PackageVariant cloning.

This commit adds a workaround for an issue with Kptfile rendering that
is causing a controller battle between PackageVariant controller and the
Nephio controllers.

It also adds some instrumentation to help debug some issues with
PackageVariant cloning.
@johnbelamaric johnbelamaric requested a review from a team as a code owner July 7, 2023 19:19
@johnbelamaric johnbelamaric requested a review from droot July 7, 2023 19:19
@johnbelamaric
Copy link
Contributor Author

e2e flaked out. Definitely see occasional issues with the packagerev finalizers, which then causes timeouts. I wonder if it is the test git server failing somehow.

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

This looks good to me.

// HACK ALERT - TODO(jbelamaric): Fix this
// Currently nephio controllers and package variant controller are rendering Kptfiles slightly differently in YAML
// not sure why, need to investigate more. It may be due to different versions of kyaml. So, here, just for Kptfiles,
// we will parse and compare semantically.
Copy link
Contributor

Choose a reason for hiding this comment

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

I asked chatgpt to help :) and it generated the following.

package main

import (
	"fmt"
	"reflect"

	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/util/yaml"
)

func main() {
	// Example YAML strings
	yamlString1 := `
apiVersion: v1
kind: Pod
metadata:
  name: pod-1
spec:
  containers:
  - name: container-1
    image: nginx:latest
  - name: container-2
    image: redis:latest
`
	yamlString2 := `
apiVersion: v1
kind: Pod
metadata:
  name: pod-2
spec:
  containers:
  - name: container-1
    image: nginx:latest
  - name: container-2
    image: redis:latest
`

	// Convert YAML strings to unstructured objects
	obj1, err := yaml.ToUnstructured([]byte(yamlString1))
	if err != nil {
		panic(err)
	}

	obj2, err := yaml.ToUnstructured([]byte(yamlString2))
	if err != nil {
		panic(err)
	}

	// Compare unstructured objects
	equal := reflect.DeepEqual(obj1, obj2)
	fmt.Println("Objects are equal:", equal)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:)

@johnbelamaric johnbelamaric merged commit e6d7572 into kptdev:main Jul 7, 2023
15 checks passed
johnbelamaric added a commit to mortent/kpt that referenced this pull request Sep 18, 2023
This commit adds a workaround for an issue with Kptfile rendering that
is causing a controller battle between PackageVariant controller and the
Nephio controllers.

It also adds some instrumentation to help debug some issues with
PackageVariant cloning.
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.

None yet

2 participants